Dump from SVN

This commit is contained in:
Fándly Gergő
2019-08-08 16:56:20 +03:00
parent 8d0e3cdd7b
commit b100fead3a
80 changed files with 5217 additions and 0 deletions

5
include/fontawesome-all.min.css vendored Normal file

File diff suppressed because one or more lines are too long

2
include/jquery-3.3.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

13
include/jquery-ui.min.js vendored Normal file

File diff suppressed because one or more lines are too long

7
include/jsplumb.min.js vendored Normal file

File diff suppressed because one or more lines are too long

273
include/sQuiz/sQuiz.js Normal file
View File

@ -0,0 +1,273 @@
/**
* /sQuiz/sQuiz.js
* @version 1.4
* @desc sQuiz main class file
* @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 <https://www.gnu.org/licenses/>.
**/
(function($){
/**
* sQuiz(element, quiz)
* @desc Creating a new quiz based on a json file
* @param $ element Container in which the quiz will be running
* @param string quiz A JSON string/JSON object containing an sQuiz parameter list
*/
$.sQuiz=function(element, quiz){
this.element=(element instanceof $)?element:$(element);
this.quiz=(typeof quiz=="object")?quiz:JSON.parse(quiz);
this.current=-1;
this.currentQustion;
this.reg;
this.countdown;
this.elapsedPerTest=(this.quiz.timeLimitPerTest>0)?0:-2;
this.elapsed=(this.quiz.timeLimit>0)?0:-2;
this.answers=[];
this.quizDoneCallback;
this.quizDoneOptions;
};
$.sQuiz.prototype={
/**
* sQuiz.setRegionalization(lang)
* @desc Assing an Object which has all the needed vars for language (startQuiz, timeRemaining, etc. Full list in /sQuiz/lang.json), or leave it on default for English
* @param object lang Object storing language settings
*/
setRegionalization: function(lang){
this.reg=lang;
},
/**
* sQuiz.setQuizDoneCallback(callback)
* @desc Assign a function to run when the quiz is finished
* @param function callback Function to call
*/
setQuizDoneCallback: function(callback){
this.quizDoneCallback=callback;
},
/**
* sQuiz.setQuizDoneOptions(options)
* @desc Set options to offer when quiz is finished. Set download to true, to offer downloading. Set upload to true, to offer online submit to upload_url. Set custom to a JS function call to do self made stuff. Custom action's label regionalization is customAction.
* @param object options Object containing the settings
*/
setQuizDoneOptions: function(options){
this.quizDoneOptions=options;
},
/**
* sQuiz.secToTime(sec)
* @desc Function for converting seconds to traditional MM:SS format
* @param int sec Seconds to convert
* @return string
*/
secToTime: function(sec){
var mins=Math.floor(sec/60);
var secs=sec%60;
var minstr=(mins.toString().length==1)?"0"+mins.toString():mins.toString();
var secstr=(secs.toString().length==1)?"0"+secs.toString():secs.toString();
var time=minstr+":"+secstr;
return time;
},
/**
* sQuiz.quizDone()
* @desc Function to call when a test is finished
*/
quizDone: function(){
var points=0;
$.each(this.answers, function(key, val){
if(val.correct){
points++;
}
});
var self=this;
this.element.slideUp(function(){
var buttons="<div class=\"sq sq-menu\">";
if(self.quizDoneOptions.download==true){
buttons+="<button class=\"sq sq-big\" type=\"button\" id=\"sqDownloadResults\"><i class=\"fa fa-save\"></i>"+self.reg.downloadResults+"</button>";
}
if(self.quizDoneOptions.upload==true){
buttons+="<button class=\"sq sq-big\" type=\"button=\" id=\"sqUploadResults\"><i class=\"fa fa-upload\"></i>"+self.reg.uploadResults+"</button>";
}
if(self.quizDoneOptions.custom!=undefined){
buttons+="<button class=\"sq sq-big\" type=\"button=\" id=\"sqCustomAction\" onclick=\""+self.quizDoneOptions.custom+"\">"+self.reg.customAction+"</button>";
}
buttons+="</div>";
self.element.html("<h2>"+self.reg.quizFinished+"</h2><hr class=\"sq sq-placeholder\" style=\"height: 10vh\"><div class=\"sq sq-center\"><h3>"+self.reg.resultsGot+": <b>"+points.toString()+"/"+self.quiz.questions.length+"</b></h3><br><br>"+buttons);
$("#sqDownloadResults").on("click", function(){
var json=JSON.stringify(self.answers);
var send="text/json;charset=utf-8,"+encodeURIComponent(json);
$("<a href=\"data:"+send+"\" download=\""+self.quiz.name+"_answers_sQuiz.json\"></a>")[0].click();
});
$("#sqUploadResults").on("click", function(){
var json=JSON.stringify(self.answers);
var submitter=prompt(self.reg.yourname+":");
$.ajax({
url: (self.quizDoneOptions.upload_url!=undefined)?self.quizDoneOptions.upload_url:"",
type: "POST",
data: {
"submitResult": json,
"submitResult_submitter": submitter
},
success: function(res){
alert(self.reg.idForResult+": "+res);
}
});
});
self.element.slideDown();
});
if(this.quizDoneCallback!=undefined){
this.quizDoneCallback(this.answers, this.quiz);
}
},
/**
* sQuiz.nextQuestion()
* @desc Start the next question. Should be called only internally!
*/
nextQuestion: function(){
var self=this;
this.current++;
if(this.current>=this.quiz.questions.length){
this.quizDone();
}
else{
var type=this.quiz.questions[this.current].type;
this.element.slideUp(function(){
var timer="<p id=\"sqTimer\">"+(self.quiz.timeLimit>0?"<b>"+self.reg.timeLeft+":</b> <span id=\"sqTimeLeft\"></span><br>":"")+(self.quiz.timeLimitPerTest>0?"<b>"+self.reg.timeLeftPerTest+":</b> <span id=\"sqTimeLeftPerTest\"></span>":"")+"</p>";
var submitbutton="<br><br><div class=\"sq sq-center\"><button class=\"sq green sq-big\" id=\"sqSubmitButton\"><i class=\"fa fa-check\"></i>"+self.reg.submit+"</button></div>";
self.element.html(timer+"<hr class=\"sq-placeholder\"><div id=\"sqTestArea\" style=\"overflow: auto\"></div>"+submitbutton);
self.element.children("#sqTimeLeft").html(self.secToTime(self.timeLimit));
self.element.children("#sqTimeLeftPerTest").html(self.secToTime(self.timeLimitPerTest));
self.currentQuestion=new $["sQuiz_module_"+type](self, self.quiz.questions[self.current]);
$("#sqSubmitButton").on("click", function(){
self.currentQuestion.submit();
$("#sqSubmitButton").unbind();
$("#sqSubmitButton").fadeOut(function(){
$(this).html("<i class=\"fa fa-arrow-right\"></i>"+self.reg.nextQuestion);
$(this).fadeIn();
});
$("#sqSubmitButton").on("click", function(){
self.nextQuestion();
});
});
self.currentQuestion.load();
self.element.slideDown(function(){
self.startTimer();
});
});
}
},
/**
* sQuiz.init()
* @desc set up styles and so for the container
*/
init: function(){
var self=this;
if(this.reg==undefined){
this.reg={
"downloadResults":"Download results",
"uploadResults":"Upload results",
"customAction":"Custom action name goes here",
"quizFinished":"Quiz finished!",
"resultsGot":"You've got the following results",
"yourname":"Your name",
"idForResult":"Share this ID with anybody you want to know your results",
"timeLeft":"Time left for entire quiz",
"timeLeftPerTest":"Time left for this question",
"submit":"Submit",
"nextQuestion":"Next question",
"startQuiz":"Start quiz",
"answer":"Answer"
};
}
this.element.hide();
this.element.addClass("sq sq-container");
this.element.html("<hr class=\"sq sq-placeholder\" style=\"height: 20vh\"><h2>"+this.quiz.name+"</h2><p>"+this.quiz.description+"</p><hr><div class=\"sq sq-center\"><button class=\"sq sq-big\" id=\"sqStart\">"+this.reg.startQuiz+"</button></div>");
$("#sqStart").on("click", function(){
self.nextQuestion();
});
this.element.slideDown();
},
/**
* sQuiz.startTimer
* @desc Starts the countdown
*/
startTimer: function(){
if(this.quiz.timeLimitPerTest>0 || this.quiz.timeLimit>0){
var self=this;
this.elapsedPerTest=0;
if(self.quiz.timeLimitPerTest>0){
self.elapsedPerTest++;
self.element.children("#sqTimer").children("#sqTimeLeftPerTest").html(self.secToTime(self.quiz.timeLimitPerTest-self.elapsedPerTest));
if(self.elapsedPerTest>=self.quiz.timeLimitPerTest){
$("#sqSubmitButton")[0].click();
}
}
if(self.quiz.timeLimit>0){
self.elapsed++;
self.element.children("#sqTimer").children("#sqTimeLeft").html(self.secToTime(self.quiz.timeLimit-self.elapsed));
if(self.elapsed>=self.quiz.timeLimit){
$("#sqSubmitButton")[0].click();
}
}
this.countdown=window.setInterval(function(self){
if(self.quiz.timeLimitPerTest>0){
self.elapsedPerTest++;
self.element.children("#sqTimer").children("#sqTimeLeftPerTest").html(self.secToTime(self.quiz.timeLimitPerTest-self.elapsedPerTest));
if(self.elapsedPerTest>=self.quiz.timeLimitPerTest){
$("#sqSubmitButton")[0].click();
}
}
if(self.quiz.timeLimit>0){
self.elapsed++;
self.element.children("#sqTimer").children("#sqTimeLeft").html(self.secToTime(self.quiz.timeLimit-self.elapsed));
if(self.elapsed>=self.quiz.timeLimit){
$("#sqSubmitButton")[0].click();
}
}
}, 1000, self);
}
},
/**
* sQuiz.stopTimer
* @desc Stops the countdown
*/
stopTimer: function(){
clearInterval(this.countdown);
}
}
}(jQuery));

View File

@ -0,0 +1,155 @@
/**
* /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 <https://www.gnu.org/licenses/>.
**/
(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<self.quiz.answers.length; i++){
if(self.quiz.answers[i].pair1==$(this).data("value")){
if(self.quiz.answers[i].pair2==$(this).data("connectedTo")){
$(this).addClass("sq-green");
self.container.children("div[data-qid=pair2]").children("i[data-value='"+$(this).data("connectedTo")+"']").addClass("sq-green");
jsPlumb.connect({
source: $(this),
target: self.container.children("div[data-qid=pair2]").children("i[data-value='"+$(this).data("connectedTo")+"']"),
anchor: "Center",
paintStyle: {
stroke: "rgba(74,230,74,0.9)",
strokeWidth: 10
},
endpoint: "Dot",
endpointStyle: {
fill: "rgba(74,230,74,0.9)",
radius: 12
},
detachable: false
});
}
else{
$(this).addClass("sq-red");
self.container.children("div[data-qid=pair2]").children("i[data-value='"+$(this).data("connectedTo")+"']").addClass("sq-red");
jsPlumb.connect({
source: $(this),
target: self.container.children("div[data-qid=pair2]").children("i[data-value='"+$(this).data("connectedTo")+"']"),
anchor: "Center",
paintStyle: {
stroke: "rgba(230,74,74,0.9)",
strokeWidth: 10
},
endpoint: "Dot",
endpointStyle: {
fill: "rgba(230,74,74,0.9)",
radius: 12
},
detachable: false
});
sub.correct=false;
}
sub.answered.push({pair: $(this).data("value"), pair2: $(this).data("connectedTo")});
break;
}
}
}
});
sub.elapsed=this.parent.elapsedPerTest;
this.parent.answers.push(sub);
},
load: function(){
var self=this;
jsPlumb.reset();
jsPlumb.setContainer(this.container);
var qid=0;
var pair1="";
var pair2="";
$.each(this.quiz.answers, function(key, val){
pair1+="<span style=\"font-size: 2em\">"+val.pair1+"</span> <i class=\"fa fa-circle fa-2x\" id=\"sqPoint"+qid.toString()+"\" data-qid=\""+qid.toString()+"\" data-value=\""+val.pair1+"\" data-connectedTo=\"--NULL--\"></i><br><br>";
qid++;
});
var qidp1=qid;
var p2=this.quiz.answers.slice();
while(p2.length>0){
var index=Math.floor(Math.random()*p2.length);
pair2+="<i class=\"fa fa-circle fa-2x\" id=\"sqPoint"+qid.toString()+"\" data-qid=\""+qid.toString()+"\" data-value=\""+p2[index].pair2+"\"></i> <span style=\"font-size: 2em\">"+p2[index].pair2+"</span><br><br>";
qid++;
p2.splice(index, 1);
}
this.container.html("<h2>"+this.quiz.question+"</h2><br><div data-qid=\"pair1\" style=\"float: left; text-align: right\">"+pair1+"</div><div data-qid=\"pair2\" style=\"float: right; text-align: left\">"+pair2+"</div>");
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<qidp1; i++){
jsPlumb.addEndpoint("sqPoint"+i.toString(), {isSource: true, isTarget: false}, typic);
}
for(var i=qidp1; i<qid; i++){
jsPlumb.addEndpoint("sqPoint"+i.toString(), {isSource: false, isTarget: true}, typic);
}
jsPlumb.bind("connection", function(info){
$(info.source).data("connectedTo", $(info.target).data("value"));
});
jsPlumb.bind("connectionDetached", function(info){
$(info.source).data("connectedTo", "--NULL--");
});
});
}
};
}(jQuery));

View File

@ -0,0 +1,115 @@
/**
* /sQuiz/sQuiz_module_fillIn.js
* @version 1.0
* @desc sQuiz class for fillIns
* @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 <https://www.gnu.org/licenses/>.
**/
(function($){
$.sQuiz_module_fillIn=function(parent, quiz){
this.parent=parent;
this.quiz=quiz;
this.container=parent.element.children("#sqTestArea");
this.qidMap={};
this.answers=[];
};
$.sQuiz_module_fillIn.prototype={
submit: function(){
var self=this;
this.parent.stopTimer();
var sub={};
this.container.children("div[data-qid=fillers]").children("span[data-qid=filler]").draggable("disable");
sub.answered=[];
sub.correct=true;
var i=0;
this.container.children("p[data-qid=text]").children("span[data-qid=fillable]").each(function(){
if($(this).data("filledWith")==undefined || $(this).data("filledWith")=="--NULL--"){
sub.answered.push("null");
sub.correct=false;
self.container.children("div[data-qid=fillers]").children("span[data-qid=filler][data-attached=false]").addClass("red");
}
else{
if($(this).data("filledWith")==self.answers[i]){
$(this).data("attached").addClass("green");
}
else{
$(this).data("attached").addClass("red");
sub.correct=false;
}
sub.answered.push($(this).data("filledWith"));
}
i++;
});
sub.elapsed=this.parent.elapsedPerTest;
this.parent.answers.push(sub);
},
load: function(){
var qid=0;
var replacer="<span data-qid=\"fillable\" class=\"sq sq-droppable\" data-filledWith=\"--NULL--\"></span>"
var fillable=this.quiz.text;
fillable=fillable.replace(new RegExp(/[\n]/g), "<br>");
fillable=fillable.replace(new RegExp(/\[\][^\[\]]+\[\/\]/g), replacer);
var fillers=[];
var res;
var reg=new RegExp(/\[\]([^\[\]]+)\[\/\]/g);
while((res=reg.exec(this.quiz.text))!==null){
fillers.push("<span data-qid=\"filler\" data-value=\""+res[1]+"\" data-attached=\"false\" class=\"sq sq-draggable\">"+res[1]+"</span>");
this.answers.push(res[1]);
}
var fillerstr="";
while(fillers.length>0){
var index=Math.floor(Math.random()*fillers.length);
fillerstr+=fillers[index];
fillers.splice(index, 1);
}
this.container.html("<h2>"+this.quiz.question+"</h2><br><p data-qid=\"text\" style=\"font-size: 1.3em\">"+fillable+"</p><hr class=\"sq sq-placeholder\"><div data-qid=\"fillers\">"+fillerstr+"</div>");
//init drag 'n' drop
this.container.children("p[data-qid=text]").children("span[data-qid=fillable]").droppable({
tolerance: "pointer",
drop: function(event, ui){
ui.draggable.position({
of: $(this),
my: "left top",
at: "left top"
});
$(this).data("filledWith", ui.draggable.data("value"));
$(this).data("attached", ui.draggable);
ui.draggable.data("attached", "true");
},
out: function(event, ui){
$(this).data("filledWith", "--NULL--");
ui.draggable.data("attached", "false");
}
});
this.container.children("div[data-qid=fillers]").children("span[data-qid=filler]").draggable({
cursor: "move"
});
}
};
}(jQuery));

View File

@ -0,0 +1,88 @@
/**
* /sQuiz/sQuiz_module_markOnMap.js
* @version 1.2
* @desc sQuiz class for markOnMaps
* @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 <https://www.gnu.org/licenses/>.
**/
(function($){
$.sQuiz_module_markOnMap=function(parent, quiz){
this.parent=parent;
this.quiz=quiz;
this.container=parent.element.children("#sqTestArea");
this.qidMap={};
};
$.sQuiz_module_markOnMap.prototype={
submit: function(){
var self=this;
this.parent.stopTimer();
var sub={};
//unbind handlers
this.container.children("div[data-qid=mapArea]").children("div[data-qid=markers]").children("i[data-qid=marker]").off();
sub.answers=[];
sub.correct=true;
this.container.children("div[data-qid=mapArea]").children("div[data-qid=markers]").children("i[data-qid=marker]").each(function(){
for(var i=0; i<self.quiz.markers.length; i++){
if(self.quiz.markers[i].posx==$(this).data("posx") && self.quiz.markers[i].posy==$(this).data("posy")){
var selected=$(this).data("selected");
if(self.quiz.markers[i].correct==selected){
$(this).addClass("sq-green");
}
else{
$(this).addClass("sq-red");
sub.correct=false;
}
sub.answers.push({posx: $(this).data("posx"), posy: $(this).data("posy"), selected: selected});
}
}
});
sub.elapsed=this.parent.elapsedPerTest;
this.parent.answers.push(sub);
},
load: function(){
var map="<img src=\""+this.quiz.map+"\" alt=\"map to fill\">";
var markers="";
$.each(this.quiz.markers, function(key, val){
markers+="<i class=\"fa fa-circle\" style=\"position: absolute; top: "+val.posy.toString()+"px; left: "+val.posx.toString()+"px\" data-posx=\""+val.posx.toString()+"\" data-posy=\""+val.posy.toString()+"\" data-qid=\"marker\" data-selected=\"false\"></i>";
});
this.container.html("<h2>"+this.quiz.question+"</h2><br><div class=\"sq sq-center sq-mapArea\" data-qid=\"mapArea\">"+map+"<div data-qid=\"markers\">"+markers+"</div></div>");
this.container.children("div[data-qid=mapArea]").children("div[data-qid=markers]").children("i[data-qid=marker]").on("click", function(){
if($(this).data("selected")==false){
$(this).removeClass("fa-circle");
$(this).addClass("fa-check-circle");
$(this).data("selected", true);
}
else{
$(this).removeClass("fa-check-circle");
$(this).addClass("fa-circle");
$(this).data("selected", false);
}
});
}
};
}(jQuery));

View File

@ -0,0 +1,58 @@
/**
* /sQuiz/sQuiz_module_simpleQuestion.js
* @version 1.2
* @desc sQuiz class for simpleQuestions
* @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 <https://www.gnu.org/licenses/>.
**/
(function($){
$.sQuiz_module_simpleQuestion=function(parent, quiz){
this.parent=parent;
this.quiz=quiz;
this.container=parent.element.children("#sqTestArea");
this.qidMap={};
};
$.sQuiz_module_simpleQuestion.prototype={
submit: function(){
var self=this;
this.parent.stopTimer();
var sub={};
sub.answered=this.container.children("input[data-qid="+this.qidMap["answer"]+"]").val();
if(sub.answered.toLowerCase()==this.quiz.answer){
this.container.children("input[data-qid="+this.qidMap["answer"]+"]").addClass("sq-green");
sub.correct=true;
}
else{
this.container.children("input[data-qid="+this.qidMap["answer"]+"]").addClass("sq-red");
sub.correct=false;
}
sub.timeElapsed=this.parent.elapsedPerTest;
this.parent.answers.push(sub);
},
load: function(){
var qid=0;
this.container.html("<h2>"+this.quiz.question+"</h2><br><p>"+this.parent.reg.answer+":</p><input type=\"text\" class=\"sq\" data-qid=\""+qid.toString()+"\" placeholder=\""+this.parent.reg.answer+"...\">");
this.qidMap["answer"]=qid;
$("input[data-qid="+this.qidMap["answer"]+"]").focus();
}
};
}(jQuery));

View File

@ -0,0 +1,81 @@
/**
* /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 <https://www.gnu.org/licenses/>.
**/
(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+="<i class=\"fa fa-square fa-2x\" data-qid=\""+qid.toString+"\" data-checked=\"false\"></i> <span style=\"font-size: 2em\">"+val.answer+"</span><br><br>";
qid++;
});
this.container.html("<h2>"+this.quiz.question+"</h2><br>"+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));

View File

@ -0,0 +1,137 @@
/**
* /sQuiz/style/sQuiz.css
* @version 1.1
* @desc Style file for sQuiz
* @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 <https://www.gnu.org/licenses/>.
**/
.sq.sq-container{
margin: auto;
background: rgba(163,127,91,0.7);
padding: 1em;
border-radius: 0.5em;
border: 1px solid rgba(118,88,59,0.9);
width: 95%;
}
.sq.sq-center{
margin: auto;
text-align: center;
}
hr.sq.sq-placeholder{
border: none;
height: 30px;
}
div.sq.sq-mapArea{
position: relative;
width: fit-content;
}
div.sq.sq-mapArea div{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
button.sq{
background: rgba(163,127,91,0.9);
padding: 1em;
border-radius: 0.5em;
border: 1px solid rgba(118,88,59,0.9);
}
button.sq:hover{
background: rgba(143,107,71,0.9);
}
button.sq.sq-big{
font-size: 3em;
padding: 1em;
padding-top: 4em;
padding-bottom: 4em;
width: 9em;
}
button.sq.red{
background: rgba(230,74,74,0.9);
border: 1px solid rgba(187,48,48,0.9);
}
button.sq.red:hover{
background: rgba(200,54,54,0.9);
}
button.sq.green{
background: rgba(74,230,74,0.9);
border: 1px solid rgba(48,487,48,0.9);
}
button.sq.green:hover{
background: rgba(54,200,54,0.9);
}
input.sq{
border-radius: 5px;
padding: 0.5em;
border: 1px solid rgba(118,88,59,0.9);
width: 90%;
font-size: 2em;
}
.sq-red{
color: rgba(230,74,74,0.9);
}
.sq-green{
color: rgba(74,230,74,0.9);
}
span.sq.sq-draggable{
height: 1.3em;
width: 10em;
padding: 0.5em;
margin: 1em;
overflow: auto;
cursor: move;
color: rgb(255,255,255);
background: rgb(130,130,130);
display: inline-block;
font-size: 1.3em;
border-radius: 0.3em;
}
span.sq.sq-draggable.red{
background: rgba(230,74,74,0.9);
}
span.sq.sq-draggable.green{
background: rgba(74,230,74,0.9);
}
span.sq.sq-droppable{
height: 2em;
width: 10.7em;
margin: 0 0.3em;
overflow: auto;
color: rgb(255,255,255);
border: 3px dashed rgb(130,130,130);
display: inline-block;
border-radius: 0.3em;
}
div.sq.sq-menu{
display: flex;
justify-content: space-around;
flex-wrap: wrap;
width: 99%;
}

95
include/script.js Normal file
View File

@ -0,0 +1,95 @@
/**
* /include/script.js
* @version 1.1
* @desc Main script file
* @author Fándly Gergő Zoltán (gergo@systemtest.tk, systemtest.tk)
* @copy 2018 Fándly Gergő Zoltán
* License:
Töri Érettsegi Előkeszítő, an app to prepare for the History tests in Romania for Hungarian students
Copyright (C) 2018 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 <https://www.gnu.org/licenses/>.
**/
function toggleMyContent(el){
if($(el).parent().children("div[data-name=mycontent]").css("display")=="none"){
$(el).parent().children("div[data-name=mycontent]").slideDown();
}
else{
$(el).parent().children("div[data-name=mycontent]").slideUp();
}
}
function search(el, entry){
$(entry).children().each(function(){
if($(this).text().toLowerCase().indexOf($(el).val().toLowerCase())!=-1){
$(this).slideDown();
}
else{
$(this).slideUp();
}
});
}
function loadTest(store){
$("#menu").slideUp();
var sQuiz=new $.sQuiz($("#quizArea"), store);
sQuiz.setRegionalization({
"downloadResults":"Eredmények letöltése",
"uploadResults":"Eredmények feltöltése",
"customAction":"Vissza tanulni!",
"quizFinished":"Gratulálok! Befejezted a kvízt!",
"resultsGot":"Elért eredményed",
"yourname":"Neved",
"idForResult":"Add oda ezt az azonosítót a tanárodnak, hogy megnézhesse eredményedet!",
"timeLeft":"Hátralévő idő a teljes kvízre",
"timeLeftPerTest":"Hátralévő idő erre a kérdésre",
"submit":"Beküldés",
"nextQuestion":"Következő kérdés",
"startQuiz":"Kvíz indítása",
"answer":"Válasz"
});
sQuiz.setQuizDoneCallback(function(res, quiz){
var all=quiz.questions.length;
var good=0;
$.each(res, function(key, val){
if(val.correct){
good++;
}
});
var ratio=100*good/all;
if(good==all){
$("#messageAfterQuiz").html("Tökéletes lett! Gratulálok! Csak így tovább!");
}
else if(ratio>90){
$("#messageAfterQuiz").html("Szinte hibátlan! Még gyakorolj!");
}
else if(ratio>70){
$("#messageAfterQuiz").html("Elmegy, de messze még a hibátlantól. Olvasd még át párszor a jegyzeteket!");
}
else if(ratio>40){
$("#messageAfterQuiz").html("Valamit tudsz, de még sokat kell tanulni!");
}
else{
$("#messageAfterQuiz").html("Nem ártana tanulnod...");
}
});
sQuiz.setQuizDoneOptions({
download: true,
custom: "$(&quot;#quizArea&quot;).slideUp(); $(&quot;#menu&quot;).slideDown(); $(&quot;#messageAfterQuiz&quot;).html(&quot;&quot;)"
});
sQuiz.init();
}

94
include/style.css Normal file
View File

@ -0,0 +1,94 @@
/**
* /include/style.css
* @version 1.0
* @desc Main style file
* @author Fándly Gergő Zoltán (gergo@systemtest.tk, systemtest.tk)
* @copy 2018 Fándly Gergő Zoltán
* License:
Töri Érettsegi Előkeszítő, an app to prepare for the History tests in Romania for Hungarian students
Copyright (C) 2018 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 <https://www.gnu.org/licenses/>.
**/
html{
background: url('../res/background.png') center center fixed no-repeat;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
background-size: cover;
}
.center{
margin: auto;
}
.centerchild{
text-align: center;
}
button{
background: rgba(163,127,91,0.9);
padding: 1em;
border-radius: 0.5em;
border: 1px solid rgba(118,88,59,0.9);
}
button:hover{
background: rgba(143,107,71,0.9);
}
footer{
background: rgba(163,127,91,0.7);
border-radius: 1em;
width: 80%;
margin: auto;
font-size: 0.8em;
text-align: center;
padding: 0.3em;
}
hr.placeholder{
border: none;
height: 30px;
}
div.container{
background: rgba(163,127,91,0.7);
padding: 1em;
border-radius: 0.5em;
border: 1px solid rgba(118,88,59,0.9);
width: 95%;
}
input{
border-radius: 5px;
padding: 0.5em;
border: 1px solid rgba(118,88,59,0.9);
}
ul.listing{
list-style: none;
}
ul.listing li{
padding: 1em;
background: rgba(136,108,56,0.9);
margin: 0.1em;
}
ul.listing a{
text-decoration: none;
color: rgb(0,0,0);
cursor: pointer;
}