Send 12 task data.

This commit is contained in:
Haifeng Luo 2021-04-16 23:47:32 +08:00
parent 0a316ba6e2
commit 8136c9ff6b
11 changed files with 46 additions and 19 deletions

View File

@ -271,7 +271,7 @@ function initTask(subTask) {
};
function getResultAndMessage() {
var result = replayAnswer();
var result = replayAnswer();
return result;
}
@ -314,11 +314,11 @@ function initTask(subTask) {
function updateUndo() {
if(answer.length > 0){
$("#undo").off("click");
$("#undo").click(undo);
$("#undo").click(undo);
$("#undo").css({
cursor: "pointer",
opacity: 1
})
})
}else{
$("#undo").off("click");
$("#undo").css({
@ -340,6 +340,7 @@ function initTask(subTask) {
};
function vertexToggle(id,selected) {
console.log(id, selected)
if((id != "00" || !selected) && answer.length > 0 && Beav.Array.has(answer[answer.length - 1],"00")){
var info = graph.getVertexInfo(id);
info.selected = !selected;
@ -526,6 +527,7 @@ function initTask(subTask) {
}
}
answer.push(selectedVertices);
parent.postMessage(selectedVertices, "*");
updateUndo();
};
@ -568,7 +570,7 @@ function initTask(subTask) {
var id = currSelected[iVertex];
currGraph.setVertexInfo(id,{selected:true});
}
var vertices = currGraph.getAllVertices();
var nbSelected = 0;

View File

@ -273,6 +273,7 @@ function initTask(subTask) {
displayError(taskStrings.noBeaver);
return;
}
parent.postMessage(answer.prediction, "*");
answer.prediction[row][col] = 1 - answer.prediction[row][col];
if(answer.prediction[row][col]){
event.data.entry = 6;

View File

@ -326,6 +326,7 @@ function initTask(subTask) {
addEdges(levels,parents,graph);
invertEdges(graph);
parent.postMessage(graph.getAllEdges(), "*");
var vertexVisualInfo = getVertexVisualInfo(levels);
if(visual){
if(target){
@ -531,7 +532,7 @@ function initTask(subTask) {
draggedRect = null;
rectID = null;
}
updateGraph(true,false);
updateGraph(true,false);
};
function findRectangle(xc,yc) {
@ -938,9 +939,10 @@ function initTask(subTask) {
initGraph();
var targetVertexVisualInfo = updateGraph(false,true);
var currentVertexVisualInfo = updateGraph(false,false);
console.log(currentVertexVisualInfo);
result = compareGraphs(targetGraph,currentGraph,targetVertexVisualInfo,currentVertexVisualInfo,noVisual);
if(!noVisual){
if(result.successRate){
platform.validate("done");
@ -960,4 +962,4 @@ initWrapper(initTask, ["easy", "medium", "hard"]);
displayHelper.useFullWidth();
//console.log(JSON.stringify(typeof window.ontouchstart));
//console.log(JSON.stringify(typeof window.ontouchstart));

View File

@ -447,7 +447,7 @@ function initTask(subTask) {
minEdges = data[level].minEdges;
maxEdges = minEdges;
paperHeight = data[level].paperHeight;
paperWidth = data[level].paperWidth;
paperWidth = data[level].paperWidth;
displayHelper.customValidate = checkResult;
};
@ -625,7 +625,13 @@ function initTask(subTask) {
function saveAnswer() {
answer.connectedPairs = [];
var edges = graph.getAllEdges();
for(var iEdge = 0; iEdge < edges.length; iEdge++){
var initialGraph = Graph.fromJSON(JSON.stringify(JSON.parse(visualGraphJSON).minGraph));
var initialEdges = initialGraph.getAllEdges();
var newEdges = edges.filter(n => !initialEdges.includes(n));
parent.postMessage(newEdges, "*");
for(var iEdge = 0; iEdge < edges.length; iEdge++){
var edge = edges[iEdge];
var info = graph.getEdgeInfo(edge);
if(info["new"]){

View File

@ -279,9 +279,9 @@ function initTask(subTask) {
if(answer.selectedSpots[draggedID]){
answer.selectedSpots[draggedID] = null;
}
};
function onMove(dx,dy,x,y,event) {
if(draggedID != null){
var xi = answer.patternsPos[draggedID].x;
@ -305,7 +305,7 @@ function initTask(subTask) {
tx = (xf - srcPos[draggedID].x);
ty = (yf - srcPos[draggedID].y);
patterns[draggedID].transform("t"+tx+" "+ty+"r"+rot+" "+(srcPos[draggedID].x + cellSize/2)+" "+(srcPos[draggedID].y + cellSize*1.5));
highlightCells(xf,yf,draggedID);
patterns[draggedID].toFront();
}
@ -372,7 +372,7 @@ function initTask(subTask) {
var yMin = yp;
var yMax = yp + 3*cellSize;
if(x > xMin && y > yMin && x < xMax && y < yMax){
if((x > xp || y > yp + cellSize) &&
if((x > xp || y > yp + cellSize) &&
(x < xp + cellSize || y > yp + cellSize) &&
(x > xp || y < yp + 2*cellSize) &&
(x < xp + cellSize || y < yp + 2*cellSize)){
@ -601,6 +601,7 @@ function initTask(subTask) {
};
function checkResult(noVisual) {
parent.postMessage(answer.selectedSpots, "*");
if(answer.selectedSpots.length < nbPatterns){
if(!noVisual)
displayError(taskStrings.missingPattern(nbPatterns));

View File

@ -421,7 +421,7 @@ function initTask(subTask) {
displayError("");
}
removeCellHighlight();
parent.postMessage(answer, "*");
}else{
var pos = draggedData.pos;
var dx = dropSpot.x - pos.x + 1;
@ -436,6 +436,7 @@ function initTask(subTask) {
if(dropLabel){
dropLabel.remove();
}
parent.postMessage(answer, "*");
}
};

View File

@ -241,7 +241,7 @@ function initTask(subTask) {
}
if (level == "easy") {
defaultAnswer[0][1] = "spot_2_0";
defaultAnswer[1][0] = "spot_0_0";
defaultAnswer[1][0] = "spot_0_0";
}
return defaultAnswer;
};
@ -384,6 +384,7 @@ function initTask(subTask) {
cont.draggableElements[0].remove();
}
}
parent.postMessage(answer, "*");
},
actionIfDropped : function(srcCont, srcPos, dstCont, dstPos, dropType)
{

View File

@ -388,6 +388,7 @@ function initTask(subTask) {
break;
}
updateRoller(rollerID);
parent.postMessage(answer, "*");
};
function getSelectedRollerID() {
@ -479,6 +480,7 @@ function initTask(subTask) {
}
drawStamp(rollerID,stampID);
updateRoller(rollerID);
parent.postMessage(answer, "*");
}
};
@ -497,6 +499,7 @@ function initTask(subTask) {
rollersRaph[id][2].attr("opacity",1).toBack();
clearParameters(previous);
initParameters();
parent.postMessage(answer, "*");
}
}
};

View File

@ -479,13 +479,14 @@ function initTask(subTask) {
}
if(!undo){
var action = {action:"lower",row:row,col:col,previous:low};
answer.actions.push(action);
// answer.actions.push(action);
updateUndo();
}
getNbOfDisconnections();
updateCounter();
showWaterFlow();
getRotatingWheels();
parent.postMessage({rotation: answer.rotation, lowered: answer.lowered}, "*");
}
};
@ -545,10 +546,11 @@ function initTask(subTask) {
}
}
if(!undo){
answer.actions.push({action:"rotate",direction:direction});
// answer.actions.push({action:"rotate",direction:direction});
updateUndo();
}
rotationAnim(rotatingWheels,direction,Beav.Navigator.isIE8());
parent.postMessage({rotation: answer.rotation, lowered: answer.lowered}, "*");
}
};
@ -627,7 +629,7 @@ function initTask(subTask) {
}
}
}
var animHandle = new Raphael.animation({transform:"r "+angle+" "+handleRotCenter.x+" "+handleRotCenter.y},animTime,function(){
subTask.raphaelFactory.animate("anim_Handle2",handleRaph,animHandle2);
showWaterFlow();

View File

@ -188,6 +188,7 @@ function initTask(subTask) {
initTarget();
initClickHere();
updateResult();
parent.postMessage(answer, "*");
displayHelper.customValidate = checkResult;
displayError("");
if (typeof(enableRtl) != "undefined") {
@ -353,6 +354,7 @@ function initTask(subTask) {
if(answer.sequence.length < maxLength ){
answer.sequence.push(0);
updateResult();
parent.postMessage(answer, "*");
}
};
@ -362,6 +364,7 @@ function initTask(subTask) {
if(answer.sequence.length > 1){
answer.sequence.pop();
updateResult();
parent.postMessage(answer, "*");
}
};
@ -505,6 +508,7 @@ function initTask(subTask) {
removeHighlight();
answer.sequence[id] = (answer.sequence[id] + 1)%nbShapes;
updateResult();
parent.postMessage(answer, "*");
}
};
@ -515,6 +519,7 @@ function initTask(subTask) {
answer.transformation[rule][id] = (answer.transformation[rule][id] + 1)%nbTransformationShapes;
updateTransformation(rule);
updateResult();
parent.postMessage(answer, "*");
}
};
@ -552,6 +557,7 @@ function initTask(subTask) {
}
updateTransformation(rule);
updateResult();
parent.postMessage(answer, "*");
}
};

View File

@ -339,6 +339,7 @@ function initTask(subTask) {
if(Beav.Navigator.isIE8()){
updateResult();
}
parent.postMessage({sliders: answer.sliders}, "*");
};
function onMove(dx,dy,x,y,event) {
@ -365,7 +366,7 @@ function initTask(subTask) {
if(!Beav.Navigator.isIE8()){
updateResult();
}
};
function getSliderID(x,y) {
@ -449,6 +450,7 @@ function initTask(subTask) {
function reloadAnswerDisplay() {
updateResult();
parent.postMessage({sliders: answer.sliders}, "*");
};
function checkResult(noVisual) {