/**
* /sQuiz/sQuiz_module_simpleSelect.js
* @version 1.3
* @desc sQuiz class for simpleSelects
* @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_simpleSelect=function(parent, quiz){
this.parent=parent;
this.quiz=quiz;
this.container=parent.element.children("#sqTestArea");
this.qidMap={};
};
$.sQuiz_module_simpleSelect.prototype={
submit: function(){
var self=this;
this.parent.stopTimer();
this.container.children("i").off();
var sub={};
sub.answered=[];
sub.correct=true;
this.container.children("i").each(function(index){
var checked=($(this).data("checked")=="true")?true:false;
if(checked==self.quiz.answers[index].correct){
$(this).addClass("sq-green");
}
else{
sub.correct=false;
$(this).addClass("sq-red");
}
sub.answered.push(checked);
});
sub.elapsed=this.parent.elapsedPerTest;
this.parent.answers.push(sub);
},
load: function(){
var qid=0;
var answers="";
$.each(this.quiz.answers, function(key, val){
answers+=" "+val.answer+"
";
qid++;
});
this.container.html("
"+this.quiz.question+"
"+answers);
this.container.children("i").on("click", function(){
if($(this).hasClass("fa-square")){
$(this).removeClass("fa-square");
$(this).addClass("fa-check-square");
$(this).data("checked", "true");
}
else{
$(this).removeClass("fa-check-square");
$(this).addClass("fa-square");
$(this).data("checked", "false");
}
});
}
};
}(jQuery));