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",
q:"Q",
add_new_question:" Ajouter une nouvelle question ...",
options:"Options",
options:"Les options",
close:"Fermer",
delete_question:"Supprimer la question",
delete_answer:"Supprimer la proposition",
@ -40,28 +40,8 @@ var sankoreLang = {
slate: "ardoise",
pad: "tablette",
none: "aucun",
help: "Aide",
help_content: "<p><h2>Choisir</h2></p>"+
"<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>"
help: "aide",
help_content: "Ceci est un exemple de contenu de l'aide ..."
};
var questionArray;
@ -101,23 +81,26 @@ function init(){
//import saved data
if(window.sankore){
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]"){
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
for(var i in questionArray){
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
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);
}
displayData(true);
}
else{
displayData(false);
begin = false;
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]")
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
else
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(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();
}
else{
displayData(false);
begin = 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}]}]');
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
@ -452,10 +435,10 @@ function init(){
//toggle button click trigger
//toggleButton.trigger("click");
//show data in display mode
function displayData(flag){
function displayData(){
$("#addQstDiv").hide();
$(".qstDiv").hide();
addToPage(questionArray, flag);
addToPage(questionArray);
}
//set widget in edit mode
@ -473,92 +456,72 @@ function init(){
}
// show questions and answers in display mode
function addToPage(array, flag){
if(flag){
var counter = 1;
for(var i in array){
function addToPage(array){
var counter = 1;
for(var i in array){
var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>");
var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv);
var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv);
var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>");
var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv);
var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv);
var ansCount = 1;
var type = array[i].type;
var selInput = $("<select>");
if(type == 3){
var newAnswer = $("<div class='newAnswer'>");
newAnswer.appendTo(ansDiv);
var selectSpan = $("<span id='answerText'>").appendTo(newAnswer);
selInput.appendTo(selectSpan);
$("<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++;
var ansCount = 1;
var type = array[i].type;
var selInput = $("<select>");
if(type == 3){
var newAnswer = $("<div class='newAnswer'>");
newAnswer.appendTo(ansDiv);
var selectSpan = $("<span id='answerText'>").appendTo(newAnswer);
selInput.appendTo(selectSpan);
$("<option value='0'>" + sankoreLang.select_text + "</option>").appendTo(selInput);
}
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);
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;
}
}

@ -81,23 +81,26 @@ function init(){
//import saved data
if(window.sankore){
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]"){
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
for(var i in questionArray){
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
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);
}
displayData(true);
}
else{
displayData(false);
begin = false;
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]")
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
else
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(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();
}
else{
displayData(false);
begin = 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}]}]');
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
@ -432,10 +435,10 @@ function init(){
//toggle button click trigger
//toggleButton.trigger("click");
//show data in display mode
function displayData(flag){
function displayData(){
$("#addQstDiv").hide();
$(".qstDiv").hide();
addToPage(questionArray, flag);
addToPage(questionArray);
}
//set widget in edit mode
@ -453,92 +456,72 @@ function init(){
}
// show questions and answers in display mode
function addToPage(array, flag){
if(flag){
var counter = 1;
for(var i in array){
function addToPage(array){
var counter = 1;
for(var i in array){
var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>");
var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv);
var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv);
var qstDiv = $("<div class='qstDivDisplay' id='" + array[i].id + "qstDivDisplay'>");
var spanOptConn = $("<div class='spanOptConn'>").appendTo(qstDiv);
var qstNumber = $("<span class='qstNumber'>" + sankoreLang.question + " " + counter + "</span>").appendTo(spanOptConn);
var qstContent = $("<div class='qstContentDisplay'>" + array[i].text + "</div>").appendTo(qstDiv);
var ansDiv = $("<div class='ansDiv' id='" + array[i].id + "ansDiv'>").appendTo(qstDiv);
var ansCount = 1;
var type = array[i].type;
var selInput = $("<select>");
if(type == 3){
var newAnswer = $("<div class='newAnswer'>");
newAnswer.appendTo(ansDiv);
var selectSpan = $("<span id='answerText'>").appendTo(newAnswer);
selInput.appendTo(selectSpan);
$("<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++;
var ansCount = 1;
var type = array[i].type;
var selInput = $("<select>");
if(type == 3){
var newAnswer = $("<div class='newAnswer'>");
newAnswer.appendTo(ansDiv);
var selectSpan = $("<span id='answerText'>").appendTo(newAnswer);
selInput.appendTo(selectSpan);
$("<option value='0'>" + sankoreLang.select_text + "</option>").appendTo(selInput);
}
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);
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;
}
}

@ -81,23 +81,26 @@ function init(){
//import saved data
if(window.sankore){
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]"){
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
for(var i in questionArray){
addQstBlock(questionArray[i].id, questionArray[i].text, questionArray[i].type,"style='display: none;'");
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);
}
displayData(true);
}
else{
displayData(false);
begin = false;
if(sankore.preference("qstArrayData","") && sankore.preference("qstArrayData","") != "[]")
questionArray = jQuery.parseJSON(sankore.preference("qstArrayData",""));
else
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(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();
}
else{
displayData(false);
begin = 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}]}]');
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
@ -432,10 +435,10 @@ function init(){
//toggle button click trigger
//toggleButton.trigger("click");
//show data in display mode
function displayData(flag){
function displayData(){
$("#addQstDiv").hide();
$(".qstDiv").hide();
addToPage(questionArray, flag);
addToPage(questionArray);
}
//set widget in edit mode
@ -453,8 +456,7 @@ function init(){
}
// show questions and answers in display mode
function addToPage(array, flag){
if(flag){
function addToPage(array){
var counter = 1;
for(var i in array){
@ -520,25 +522,6 @@ function init(){
counter++;
}
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