/** * /sQuiz/sQuiz_module_connectGraph.js * @version 1.3 * @desc sQuiz class for connectGraphs * @author Fándly Gergő Zoltán (gergo@systemtest.tk, systemtest.tk) * @copy 2017 Fándly Gergő Zoltán * License: sQuiz for creating small jQuery based quizs in an implementable way Copyright (C) 2017 Fándly Gergő Zoltán This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . **/ (function($){ $.sQuiz_module_connectGraph=function(parent, quiz){ this.parent=parent; this.quiz=quiz; this.container=parent.element.children("#sqTestArea"); this.qidMap={}; this.currentlyClicked=null; }; $.sQuiz_module_connectGraph.prototype={ submit: function(){ var self=this; this.parent.stopTimer(); var sub={}; sub.answered=[]; sub.correct=true; jsPlumb.reset(); $(this.container).children("div[data-qid=pair1]").children("i").each(function(){ if($(this).data("connectedTo")==undefined || $(this).data("connectedTo")=="--NULL--"){ sub.answered.push({pair1: $(this).data("value"), pair2: "null"}); $(this).addClass("sq-red"); sub.correct=false; } else{ for(var i=0; i"+val.pair1+"

"; qid++; }); var qidp1=qid; var p2=this.quiz.answers.slice(); while(p2.length>0){ var index=Math.floor(Math.random()*p2.length); pair2+=" "+p2[index].pair2+"

"; qid++; p2.splice(index, 1); } this.container.html("

"+this.quiz.question+"


"+pair1+"
"+pair2+"
"); this.parent.element.slideDown(function(){ var typic={ anchor: "Center", connectorStyle: { stroke: "rgb(0,0,0)", strokeWidth: 10 }, endpoint: "Dot", endpointStyle: { fill: "rgb(0,0,0)", radius: 12 } }; for(var i=0; i