Commit 5728826d authored by 李维's avatar 李维

可以显示连线组历史记录

parent 3ec21225
...@@ -925,8 +925,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -925,8 +925,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 连线组 - 历史记录 // 连线组 - 历史记录
showConnectionGroup(configItem, resultData) { showConnectionGroup(configItem, resultData) {
console.log(configItem, resultData)
const debugMode = false; const debugMode = false;
const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex]; const resultIconShowData = this.data.hotZoneItemArr[configItem.linkResultShowHotZoneIndex];
const resultIconRect = this.newRectNode(resultIconShowData, layer_2, debugMode); const resultIconRect = this.newRectNode(resultIconShowData, layer_2, debugMode);
...@@ -951,24 +949,48 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -951,24 +949,48 @@ export default class SceneComponent extends MyCocosSceneComponent {
resultIconRect.addChild(errIcon); resultIconRect.addChild(errIcon);
} }
resultData[0].results.forEach((resData, index) => { // 连线点都显示出来
const startHotZoneData = this.data.hotZoneItemArr[configItem.contentList[index].selectStartHotZoneIndex]; const startRects = [];
const endRects = [];
configItem.contentList.forEach(item => {
if(item.selectStartHotZoneIndex >= 0 && this.data.hotZoneItemArr[item.selectStartHotZoneIndex]) {
const iconStart = this.getSprNode("icon_connect_start");
const startHotZoneData = this.data.hotZoneItemArr[item.selectStartHotZoneIndex];
const startRect = this.newRectNode(startHotZoneData, layer_4, debugMode); const startRect = this.newRectNode(startHotZoneData, layer_4, debugMode);
iconStart.zIndex = layer_2;
iconStart.x = startRect.width / 2;
iconStart.y = startRect.height / 2;
startRect.addChild(iconStart);
startRects.push(startRect)
} else {
startRects.push(null)
}
const endHotZoneData = this.data.hotZoneItemArr[configItem.contentList[resData.currentEndIndex].selectEndHotZoneIndex]; if(item.selectEndHotZoneIndex >= 0 && this.data.hotZoneItemArr[item.selectEndHotZoneIndex]) {
const endHotZoneData = this.data.hotZoneItemArr[item.selectEndHotZoneIndex];
const endRect = this.newRectNode(endHotZoneData, layer_5, debugMode); const endRect = this.newRectNode(endHotZoneData, layer_5, debugMode);
const iconStart = this.getSprNode("icon_connect_start");
const iconEnd = this.getSprNode("icon_connect_end"); const iconEnd = this.getSprNode("icon_connect_end");
iconStart.zIndex = layer_2;
iconEnd.zIndex = layer_2; iconEnd.zIndex = layer_2;
iconStart.x = startRect.width / 2;
iconStart.y = startRect.height / 2;
iconEnd.x = endRect.width / 2; iconEnd.x = endRect.width / 2;
iconEnd.y = endRect.height / 2; iconEnd.y = endRect.height / 2;
endRect.addChild(iconEnd); endRect.addChild(iconEnd);
startRect.addChild(iconStart); endRects.push(endRect)
} else {
endRects.push(null)
}
});
// 根据用户结果还原显示
resultData[0].results.forEach((resData, index) => {
if(resData.startIndex < 0 || resData.currentEndIndex < 0) {
return
}
const startRect = startRects[resData.startIndex];
const endRect = endRects[resData.currentEndIndex];
if(!startRect || !endRect) {
return
}
const lineNode = new cc.Node(); const lineNode = new cc.Node();
lineNode.name = 'connect1_' + index; lineNode.name = 'connect1_' + index;
...@@ -987,11 +1009,16 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -987,11 +1009,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 画线 // 画线
ctx.stroke(); ctx.stroke();
// 结果显示节点
if(configItem.contentList[index].selectEndHotZoneShowIndex && configItem.contentList[index].selectEndHotZoneShowIndex >= 0 && this.data.hotZoneItemArr[configItem.contentList[index].selectEndHotZoneShowIndex] && resData.currentEndText) {
const linkedTextData = this.data.hotZoneItemArr[configItem.contentList[index].selectEndHotZoneShowIndex];
const textNodePartent = this.newRectNode(linkedTextData, layer_4, debugMode);
const textNode = this.newTextNode(resData.currentEndText ? resData.currentEndText : "");
textNode.x = textNodePartent.width / 2;
textNode.y = textNodePartent.height / 2;
textNodePartent.addChild(textNode)
}
}); });
} }
// 判断对错 - 历史记录 // 判断对错 - 历史记录
...@@ -1806,13 +1833,14 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -1806,13 +1833,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
}; };
contentData.contentList.forEach((option, index) => { contentData.contentList.forEach((option, index) => {
const resultConnectIndex = currentConnectionList.findIndex(item=>item.linkedIndex == index)
const detailItem = { const detailItem = {
startIndex: index, startIndex: index,
startText: option.startTextShow ? option.startTextShow : "", startText: option.startTextShow ? option.startTextShow : "",
correctEndIndex: index, correctEndIndex: index,
correctEndText: option.endTextShow ? option.endTextShow : "", correctEndText: option.endTextShow ? option.endTextShow : "",
currentEndIndex: currentConnectionList[index].linkedIndex, currentEndIndex: resultConnectIndex,
currentEndText: currentConnectionList[index].textShow, currentEndText: resultConnectIndex >= 0 ? currentConnectionList[resultConnectIndex].textShow : "",
right: true right: true
} }
if(currentConnectionList[index].linkedIndex == index) { if(currentConnectionList[index].linkedIndex == index) {
...@@ -2037,7 +2065,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -2037,7 +2065,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
currentConnectionList.push({ currentConnectionList.push({
rect: startRect, rect: startRect,
linkedIndex: -1, linkedIndex: -1,
textShow: option.textShow ? option.textShow : "", textShow: option.linkedShowText ? option.linkedShowText : "",
}) })
}); });
......
...@@ -1123,8 +1123,8 @@ export const historyData = { ...@@ -1123,8 +1123,8 @@ export const historyData = {
"startText": "", "startText": "",
"correctEndIndex": 0, "correctEndIndex": 0,
"correctEndText": "", "correctEndText": "",
"currentEndIndex": 1, "currentEndIndex": 2,
"currentEndText": "", "currentEndText": "a",
"right": false "right": false
}, },
{ {
...@@ -1132,8 +1132,8 @@ export const historyData = { ...@@ -1132,8 +1132,8 @@ export const historyData = {
"startText": "", "startText": "",
"correctEndIndex": 1, "correctEndIndex": 1,
"correctEndText": "", "correctEndText": "",
"currentEndIndex": 2, "currentEndIndex": 0,
"currentEndText": "", "currentEndText": "b",
"right": false "right": false
}, },
{ {
...@@ -1141,7 +1141,7 @@ export const historyData = { ...@@ -1141,7 +1141,7 @@ export const historyData = {
"startText": "", "startText": "",
"correctEndIndex": 2, "correctEndIndex": 2,
"correctEndText": "", "correctEndText": "",
"currentEndIndex": 0, "currentEndIndex": -1,
"currentEndText": "", "currentEndText": "",
"right": false "right": false
} }
...@@ -1177,7 +1177,7 @@ export const historyData = { ...@@ -1177,7 +1177,7 @@ export const historyData = {
"totalScore": 0, "totalScore": 0,
"isAllRight": false, "isAllRight": false,
"isAllWrong": true, "isAllWrong": true,
"startTimestamp": 1689000426243, "startTimestamp": 1689057128454,
"submitTimestamp": 1689000433908, "submitTimestamp": 1689057136559,
"answeringTime": 7665 "answeringTime": 8105
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment