fixed sankore-806

preferencesAboutTextFull
maximXbs 12 years ago
parent 85634590a9
commit 06e9406170
  1. 199
      resources/library/interactivities/Choisir.wgt/locales/fr/scripts/selQuestionApp.js
  2. 173
      resources/library/interactivities/Choisir.wgt/locales/ru/scripts/selQuestionApp.js
  3. 57
      resources/library/interactivities/Choisir.wgt/scripts/selQuestionApp.js

@ -21,7 +21,7 @@ var sankoreLang = {
answer:"Ceci est une réponse possible", answer:"Ceci est une réponse possible",
q:"Q", q:"Q",
add_new_question:" Ajouter une nouvelle question ...", add_new_question:" Ajouter une nouvelle question ...",
options:"Options", options:"Les options",
close:"Fermer", close:"Fermer",
delete_question:"Supprimer la question", delete_question:"Supprimer la question",
delete_answer:"Supprimer la proposition", delete_answer:"Supprimer la proposition",
@ -40,28 +40,8 @@ var sankoreLang = {
slate: "ardoise", slate: "ardoise",
pad: "tablette", pad: "tablette",
none: "aucun", none: "aucun",
help: "Aide", help: "aide",
help_content: "<p><h2>Choisir</h2></p>"+ help_content: "Ceci est un exemple de contenu de l'aide ..."
"<p><h3>Question à choix multiples (QCM).</h3></p>"+
"<p>Une question est posée avec plusieurs choix de réponses possibles. Le but est de choisir la bonne réponse.</p>"+
"<p>Le bouton “Recharger” réinitialise les exercices.</p>"+
"<p>Le bouton “Modifier” vous permet :</p>"+
"<ul><li>de choisir le thème de l’interactivité : tablette, ardoise ou aucun (par défaut aucun),</li>"+
"<li>de modifier un exercice ou d’en créer de nouveaux dans la même activité.</li></ul>"+
"<p>En mode édition, pour créer un nouvel exercice, cliquez sur “Ajouter une nouvelle question …”, puis.</p>"+
"<ul><li>insérez la question en cliquant sur le champ de texte “Saisir la question ici ...”,</li>"+
"<li>cliquez sur ”Options” pour choisir l’affichage des propositions (une seule bonne réponse, plusieurs bonnes réponses, liste déroulante). Cliquez sur “Fermer”,</li>"+
"<li>cliquez sur ”Ajouter une proposition” et saisissez la proposition dans le champ de texte,</li>"+
"<li>définissez la ou les propositions correctes en cliquant sur la case à cocher à gauche des bonnes réponses.</li>"+
"<li>Pour supprimer une proposition, cliquez sur la croix située à droite de celle-ci.</li></ul>"+
"<p>Pour supprimer un exercice, cliquez sur la croix à droite du numéro de ”Options”.</p>"+
"<p>Le bouton “Afficher” vous permet d’utiliser l’activité.</p>"
}; };
var questionArray; var questionArray;
@ -101,23 +81,26 @@ function init(){
//import saved data //import saved data
if(window.sankore){ if(window.sankore){
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]"){ if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]")
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData","")); questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
for(var i in questionArray){ else
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'"); questionArray = jQuery.parseJSON('[{"text":"' + sankoreLang.example_question + '","type":"1","id":538,"rightAns":"2","answers":[{"id":953,"text":"' + sankoreLang.answer + ' 1.","value":1,"state":"","was":false},{"id":526,"text":"' + sankoreLang.answer + ' 2.","value":2,"state":"","was":false},{"id":473,"text":"' + sankoreLang.answer + ' 3.","value":3,"state":"","was":false}]}]');
for(var j in questionArray[i].answers)
addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type); for(i in questionArray){
} addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
displayData(true); for(j in questionArray[i].answers)
} addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type);
else{
displayData(false);
begin = false;
} }
displayData();
} }
else{ else{
displayData(false); questionArray = jQuery.parseJSON('[{"text":"' + sankoreLang.example_question + '","type":"1","id":538,"rightAns":"2","answers":[{"id":953,"text":"' + sankoreLang.answer + ' 1.","value":1,"state":"","was":false},{"id":526,"text":"' + sankoreLang.answer + ' 2.","value":2,"state":"","was":false},{"id":473,"text":"' + sankoreLang.answer + ' 3.","value":3,"state":"","was":false}]}]');
begin = false; for(i in questionArray){
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
for(j in questionArray[i].answers)
addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type);
}
displayData();
} }
//saving widget data into sankore object for a correct import //saving widget data into sankore object for a correct import
@ -452,10 +435,10 @@ function init(){
//toggle button click trigger //toggle button click trigger
//toggleButton.trigger("click"); //toggleButton.trigger("click");
//show data in display mode //show data in display mode
function displayData(flag){ function displayData(){
$("#addQstDiv").hide(); $("#addQstDiv").hide();
$(".qstDiv").hide(); $(".qstDiv").hide();
addToPage(questionArray, flag); addToPage(questionArray);
} }
//set widget in edit mode //set widget in edit mode
@ -473,92 +456,72 @@ function init(){
} }
// show questions and answers in display mode // show questions and answers in display mode
function addToPage(array, flag){ function addToPage(array){
if(flag){ var counter = 1;
var counter = 1; for(var i in array){
for(var i in array){
var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>"); var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>");
var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv); var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn); var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv); var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv);
var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv); var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv);
var ansCount = 1; var ansCount = 1;
var type = array[i].type; var type = array[i].type;
var selInput = $("<select>"); var selInput = $("<select>");
if(type == 3){ if(type == 3){
var newAnswer = $("<div class='newAnswer'>"); var newAnswer = $("<div class='newAnswer'>");
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
var selectSpan = $("<span id='answerText'>").appendTo(newAnswer); var selectSpan = $("<span id='answerText'>").appendTo(newAnswer);
selInput.appendTo(selectSpan); selInput.appendTo(selectSpan);
$("<option value='0'>" + sankoreLang.select_text + "</option>").appendTo(selInput); $("<option value='0'>" + sankoreLang.select_text + "</option>").appendTo(selInput);
}
for(var j in array[i].answers){
switch(type){
case "1":
var local_state = "";
var local_color = "";
if(begin){
local_state = array[i].answers[j].state;
local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
newAnswer = $("<div class='newAnswer'>");
var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
var ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
var ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
break;
case "2":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"checked":"";
local_color = (array[i].rightAns.replace(/,/g,"").indexOf(array[i].answers[j].value + " ", 0) != -1)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
break;
case "3":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"selected":"";
local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"#6c0":""):((array[i].answers[j].was)?"red":"");
}
ansInput = $("<option value='" + array[i].answers[j].value + "' " + local_state + ">" + array[i].answers[j].text + "</option>").appendTo(selInput);
if(local_state && local_color)
selInput.css("background-color",local_color);
break;
}
ansCount++;
}
qstDiv.appendTo("#data");
counter++;
} }
begin = false; for(var j in array[i].answers){
} else { switch(type){
counter = 1; case "1":
qstDiv = $("<div class='qstDivDisplay'>"); var local_state = "";
spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv); var local_color = "";
qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn); if(begin){
qstContent = $("<div class='qstContentDisplay'>" + sankoreLang.example_question + "</div>").appendTo(qstDiv); local_state = array[i].answers[j].state;
ansDiv = $("<div class='ansDiv'>").appendTo(qstDiv); local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
ansCount = 1; newAnswer = $("<div class='newAnswer'>");
for(j = 0; j < 3; j++){ var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
newAnswer = $("<div class='newAnswer'>"); var ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansInput = $("<input type='radio' name='1' style='float: left; margin-right: 10px;'/>").appendTo(newAnswer); var ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer); newAnswer.appendTo(ansDiv);
ansContent = $("<div class='ansContentDisplay'>" + sankoreLang.answer + " " + ansCount + ".</div>").appendTo(newAnswer); break;
newAnswer.appendTo(ansDiv); case "2":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"checked":"";
local_color = (array[i].rightAns.replace(/,/g,"").indexOf(array[i].answers[j].value + " ", 0) != -1)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
break;
case "3":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"selected":"";
local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"#6c0":""):((array[i].answers[j].was)?"red":"");
}
ansInput = $("<option value='" + array[i].answers[j].value + "' " + local_state + ">" + array[i].answers[j].text + "</option>").appendTo(selInput);
if(local_state && local_color)
selInput.css("background-color",local_color);
break;
}
ansCount++; ansCount++;
} }
qstDiv.appendTo("#data"); qstDiv.appendTo("#data");
counter++;
} }
begin = false;
} }
} }

@ -81,23 +81,26 @@ function init(){
//import saved data //import saved data
if(window.sankore){ if(window.sankore){
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]"){ if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]")
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData","")); questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
for(var i in questionArray){ else
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'"); questionArray = jQuery.parseJSON('[{"text":"' + sankoreLang.example_question + '","type":"1","id":538,"rightAns":"2","answers":[{"id":953,"text":"' + sankoreLang.answer + ' 1.","value":1,"state":"","was":false},{"id":526,"text":"' + sankoreLang.answer + ' 2.","value":2,"state":"","was":false},{"id":473,"text":"' + sankoreLang.answer + ' 3.","value":3,"state":"","was":false}]}]');
for(var j in questionArray[i].answers)
addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type); for(i in questionArray){
} addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
displayData(true); for(j in questionArray[i].answers)
} addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type);
else{
displayData(false);
begin = false;
} }
displayData();
} }
else{ else{
displayData(false); questionArray = jQuery.parseJSON('[{"text":"' + sankoreLang.example_question + '","type":"1","id":538,"rightAns":"2","answers":[{"id":953,"text":"' + sankoreLang.answer + ' 1.","value":1,"state":"","was":false},{"id":526,"text":"' + sankoreLang.answer + ' 2.","value":2,"state":"","was":false},{"id":473,"text":"' + sankoreLang.answer + ' 3.","value":3,"state":"","was":false}]}]');
begin = false; for(i in questionArray){
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
for(j in questionArray[i].answers)
addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type);
}
displayData();
} }
//saving widget data into sankore object for a correct import //saving widget data into sankore object for a correct import
@ -432,10 +435,10 @@ function init(){
//toggle button click trigger //toggle button click trigger
//toggleButton.trigger("click"); //toggleButton.trigger("click");
//show data in display mode //show data in display mode
function displayData(flag){ function displayData(){
$("#addQstDiv").hide(); $("#addQstDiv").hide();
$(".qstDiv").hide(); $(".qstDiv").hide();
addToPage(questionArray, flag); addToPage(questionArray);
} }
//set widget in edit mode //set widget in edit mode
@ -453,92 +456,72 @@ function init(){
} }
// show questions and answers in display mode // show questions and answers in display mode
function addToPage(array, flag){ function addToPage(array){
if(flag){ var counter = 1;
var counter = 1; for(var i in array){
for(var i in array){
var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>"); var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>");
var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv); var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn); var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv); var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv);
var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv); var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv);
var ansCount = 1; var ansCount = 1;
var type = array[i].type; var type = array[i].type;
var selInput = $("<select>"); var selInput = $("<select>");
if(type == 3){ if(type == 3){
var newAnswer = $("<div class='newAnswer'>"); var newAnswer = $("<div class='newAnswer'>");
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
var selectSpan = $("<span id='answerText'>").appendTo(newAnswer); var selectSpan = $("<span id='answerText'>").appendTo(newAnswer);
selInput.appendTo(selectSpan); selInput.appendTo(selectSpan);
$("<option value='0'>" + sankoreLang.select_text + "</option>").appendTo(selInput); $("<option value='0'>" + sankoreLang.select_text + "</option>").appendTo(selInput);
}
for(var j in array[i].answers){
switch(type){
case "1":
var local_state = "";
var local_color = "";
if(begin){
local_state = array[i].answers[j].state;
local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
newAnswer = $("<div class='newAnswer'>");
var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
var ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
var ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
break;
case "2":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"checked":"";
local_color = (array[i].rightAns.replace(/,/g,"").indexOf(array[i].answers[j].value + " ", 0) != -1)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
break;
case "3":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"selected":"";
local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"#6c0":""):((array[i].answers[j].was)?"red":"");
}
ansInput = $("<option value='" + array[i].answers[j].value + "' " + local_state + ">" + array[i].answers[j].text + "</option>").appendTo(selInput);
if(local_state && local_color)
selInput.css("background-color",local_color);
break;
}
ansCount++;
}
qstDiv.appendTo("#data");
counter++;
} }
begin = false; for(var j in array[i].answers){
} else { switch(type){
counter = 1; case "1":
qstDiv = $("<div class='qstDivDisplay'>"); var local_state = "";
spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv); var local_color = "";
qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn); if(begin){
qstContent = $("<div class='qstContentDisplay'>" + sankoreLang.example_question + "</div>").appendTo(qstDiv); local_state = array[i].answers[j].state;
ansDiv = $("<div class='ansDiv'>").appendTo(qstDiv); local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
ansCount = 1; newAnswer = $("<div class='newAnswer'>");
for(j = 0; j < 3; j++){ var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
newAnswer = $("<div class='newAnswer'>"); var ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansInput = $("<input type='radio' name='1' style='float: left; margin-right: 10px;'/>").appendTo(newAnswer); var ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer); newAnswer.appendTo(ansDiv);
ansContent = $("<div class='ansContentDisplay'>" + sankoreLang.answer + " " + ansCount + ".</div>").appendTo(newAnswer); break;
newAnswer.appendTo(ansDiv); case "2":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"checked":"";
local_color = (array[i].rightAns.replace(/,/g,"").indexOf(array[i].answers[j].value + " ", 0) != -1)?((array[i].answers[j].was)?"style='background-color: #6c0;'":""):((array[i].answers[j].was)?"style='background-color: red;'":"");
}
newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' " + local_state + " style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay' " + local_color + "><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
break;
case "3":
local_state = "";
local_color = "";
if(begin){
local_state = (array[i].answers[j].state)?"selected":"";
local_color = (array[i].answers[j].value == array[i].rightAns)?((array[i].answers[j].was)?"#6c0":""):((array[i].answers[j].was)?"red":"");
}
ansInput = $("<option value='" + array[i].answers[j].value + "' " + local_state + ">" + array[i].answers[j].text + "</option>").appendTo(selInput);
if(local_state && local_color)
selInput.css("background-color",local_color);
break;
}
ansCount++; ansCount++;
} }
qstDiv.appendTo("#data"); qstDiv.appendTo("#data");
counter++;
} }
begin = false;
} }
} }

@ -81,23 +81,26 @@ function init(){
//import saved data //import saved data
if(window.sankore){ if(window.sankore){
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]"){ if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]")
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData","")); questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
for(var i in questionArray){ else
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'"); questionArray = jQuery.parseJSON('[{"text":"' + sankoreLang.example_question + '","type":"1","id":538,"rightAns":"2","answers":[{"id":953,"text":"' + sankoreLang.answer + ' 1.","value":1,"state":"","was":false},{"id":526,"text":"' + sankoreLang.answer + ' 2.","value":2,"state":"","was":false},{"id":473,"text":"' + sankoreLang.answer + ' 3.","value":3,"state":"","was":false}]}]');
for(var j in questionArray[i].answers)
addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type); for(i in questionArray){
} addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
displayData(true); for(j in questionArray[i].answers)
} addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type);
else{
displayData(false);
begin = false;
} }
displayData();
} }
else{ else{
displayData(false); questionArray = jQuery.parseJSON('[{"text":"' + sankoreLang.example_question + '","type":"1","id":538,"rightAns":"2","answers":[{"id":953,"text":"' + sankoreLang.answer + ' 1.","value":1,"state":"","was":false},{"id":526,"text":"' + sankoreLang.answer + ' 2.","value":2,"state":"","was":false},{"id":473,"text":"' + sankoreLang.answer + ' 3.","value":3,"state":"","was":false}]}]');
begin = false; for(i in questionArray){
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
for(j in questionArray[i].answers)
addAnsBlock(questionArray[i].answers[j].id, questionArray[i].id, questionArray[i].answers[j].text, true, questionArray[i].rightAns, questionArray[i].type);
}
displayData();
} }
//saving widget data into sankore object for a correct import //saving widget data into sankore object for a correct import
@ -432,10 +435,10 @@ function init(){
//toggle button click trigger //toggle button click trigger
//toggleButton.trigger("click"); //toggleButton.trigger("click");
//show data in display mode //show data in display mode
function displayData(flag){ function displayData(){
$("#addQstDiv").hide(); $("#addQstDiv").hide();
$(".qstDiv").hide(); $(".qstDiv").hide();
addToPage(questionArray, flag); addToPage(questionArray);
} }
//set widget in edit mode //set widget in edit mode
@ -453,8 +456,7 @@ function init(){
} }
// show questions and answers in display mode // show questions and answers in display mode
function addToPage(array, flag){ function addToPage(array){
if(flag){
var counter = 1; var counter = 1;
for(var i in array){ for(var i in array){
@ -520,25 +522,6 @@ function init(){
counter++; counter++;
} }
begin = false; begin = false;
} else {
counter = 1;
qstDiv = $("<div class='qstDivDisplay'>");
spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
qstContent = $("<div class='qstContentDisplay'>" + sankoreLang.example_question + "</div>").appendTo(qstDiv);
ansDiv = $("<div class='ansDiv'>").appendTo(qstDiv);
ansCount = 1;
for(j = 0; j < 3; j++){
newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='radio' name='1' style='float: left; margin-right: 10px;'/>").appendTo(newAnswer);
ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay'>" + sankoreLang.answer + " " + ansCount + ".</div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv);
ansCount++;
}
qstDiv.appendTo("#data");
}
} }
} }

Loading…
Cancel
Save