fixed choisir

preferencesAboutTextFull
unknown 13 years ago
parent c8d3b20838
commit 4ae1829345
  1. 2
      resources/library/interactivities/Choisir.wgt/css/basic.css
  2. 4
      resources/library/interactivities/Choisir.wgt/index.html
  3. 4
      resources/library/interactivities/Choisir.wgt/locales/fr/index.html
  4. 93
      resources/library/interactivities/Choisir.wgt/locales/fr/scripts/selQuestionApp.js
  5. 4
      resources/library/interactivities/Choisir.wgt/locales/ru/index.html
  6. 93
      resources/library/interactivities/Choisir.wgt/locales/ru/scripts/selQuestionApp.js
  7. 93
      resources/library/interactivities/Choisir.wgt/scripts/selQuestionApp.js

@ -457,7 +457,7 @@ body{
#wgt_name{ #wgt_name{
height: 44px; height: 44px;
width: 220px; width: 260px;
margin: 10px 10px 0 10px; margin: 10px 10px 0 10px;
padding: 0; padding: 0;
float: left; float: left;

@ -8,8 +8,8 @@ and open the template in the editor.
<title></title> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/basic.css"/> <link rel="stylesheet" type="text/css" href="css/basic.css"/>
<link rel="stylesheet" href="css/fonts/Lobster/stylesheet.css"> <!--<link rel="stylesheet" href="css/fonts/Lobster/stylesheet.css">
<link rel="stylesheet" href="css/fonts/SF-Toontime/stylesheet.css"> <link rel="stylesheet" href="css/fonts/SF-Toontime/stylesheet.css">-->
<script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="scripts/selQuestionApp.js"></script> <script type="text/javascript" src="scripts/selQuestionApp.js"></script>
<script type="text/javascript"> <script type="text/javascript">

@ -8,8 +8,8 @@ and open the template in the editor.
<title></title> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../css/basic.css"/> <link rel="stylesheet" type="text/css" href="../../css/basic.css"/>
<link rel="stylesheet" href="../../css/fonts/Lobster/stylesheet.css"> <!--<link rel="stylesheet" href="../../css/fonts/Lobster/stylesheet.css">
<link rel="stylesheet" href="../../css/fonts/SF-Toontime/stylesheet.css"> <link rel="stylesheet" href="../../css/fonts/SF-Toontime/stylesheet.css">-->
<script type="text/javascript" src="../../scripts/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="../../scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="scripts/selQuestionApp.js"></script> <script type="text/javascript" src="scripts/selQuestionApp.js"></script>
<script type="text/javascript"> <script type="text/javascript">

@ -41,10 +41,10 @@ var sankoreLang = {
pad: "Pad" pad: "Pad"
}; };
var questionArray; var questionArray;
var currentQstId = ""; var currentQstId = "";
var lang = ""; //locale language var lang = ""; //locale language
var begin = true;
function init(){ function init(){
@ -84,11 +84,15 @@ function init(){
} }
displayData(true); displayData(true);
} }
else else{
displayData(false); displayData(false);
begin = false;
}
} }
else else{
displayData(false); displayData(false);
begin = false;
}
//saving widget data into sankore object for a correct import //saving widget data into sankore object for a correct import
if (window.widget) { if (window.widget) {
@ -133,8 +137,12 @@ function init(){
$("#wgt_reload").text(sankoreLang.reload).click(function(){ $("#wgt_reload").text(sankoreLang.reload).click(function(){
if($("#wgt_edit").css("display") == "none") if($("#wgt_edit").css("display") == "none")
$("#wgt_display").trigger("click"); $("#wgt_display").trigger("click");
else else{
window.location.reload(); editData();
mode = false;
displayData(true);
mode = true;
}
}); });
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
@ -302,11 +310,13 @@ function init(){
} }
} else { } else {
if(event.target.type == "radio"){ if(event.target.type == "radio"){
checkingAnswers("radio", getNeededElement(questionArray, currentQstId).answers, event.target.value);
if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns) if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns)
$(event.target).next().next().find("span").css("background-color","#6c0"); $(event.target).next().next().find("span").css("background-color","#6c0");
else else
$(event.target).next().next().find("span").css("background-color","red"); $(event.target).next().next().find("span").css("background-color","red");
} else { } else {
checkingAnswers("box", getNeededElement(questionArray, currentQstId).answers, event.target.value, event.target.checked);
if(getNeededElement(questionArray, currentQstId).rightAns.replace(/,/g,"").indexOf(event.target.value + " ", 0) != -1) if(getNeededElement(questionArray, currentQstId).rightAns.replace(/,/g,"").indexOf(event.target.value + " ", 0) != -1)
$(event.target).next().next().find("span").css("background-color","#6c0"); $(event.target).next().next().find("span").css("background-color","#6c0");
else else
@ -378,10 +388,13 @@ function init(){
$("select").live('change', function(evt){ $("select").live('change', function(evt){
if(mode){ if(mode){
checkingAnswers("sel", getNeededElement(questionArray, currentQstId).answers, event.target.value);
if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns) if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns)
$(event.target).css("background-color","#6c0"); $(event.target).css("background-color","#6c0");
else else
$(event.target).css("background-color","red"); $(event.target).css("background-color","red");
if(event.target.value == 0)
$(event.target).css("background-color","");
flagForSelect = false; flagForSelect = false;
} }
}); });
@ -403,6 +416,12 @@ function init(){
//set widget in edit mode //set widget in edit mode
function editData(){ function editData(){
for(var i in questionArray)
for(var j in questionArray[i].answers){
questionArray[i].answers[j].state = "";
questionArray[i].answers[j].was = false
}
$(".qstDivDisplay").remove(); $(".qstDivDisplay").remove();
$("#addQstDiv").show('fast'); $("#addQstDiv").show('fast');
@ -434,21 +453,41 @@ function init(){
for(var j in array[i].answers){ for(var j in array[i].answers){
switch(type){ switch(type){
case "1": 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'>"); newAnswer = $("<div class='newAnswer'>");
var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' style='float: left; margin-right: 10px;'/>").appendTo(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 ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
var ansContent = $("<div class='ansContentDisplay'><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer); var ansContent = $("<div class='ansContentDisplay'><span id='answerText' " + local_color + ">" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
break; break;
case "2": 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'>"); newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' style='float: left; margin-right: 10px;'/>").appendTo(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); ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay'><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer); ansContent = $("<div class='ansContentDisplay'><span id='answerText' " + local_color + ">" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
break; break;
case "3": case "3":
ansInput = $("<option value='" + array[i].answers[j].value + "'>" + array[i].answers[j].text + "</option>").appendTo(selInput); 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; break;
} }
ansCount++; ansCount++;
@ -456,6 +495,7 @@ function init(){
qstDiv.appendTo("#data"); qstDiv.appendTo("#data");
counter++; counter++;
} }
begin = false;
} else { } else {
counter = 1; counter = 1;
qstDiv = $("<div class='qstDivDisplay'>"); qstDiv = $("<div class='qstDivDisplay'>");
@ -606,6 +646,35 @@ function refreshQst(){
$("#addQsqSpan1").text(sankoreLang.q + ++count); $("#addQsqSpan1").text(sankoreLang.q + ++count);
} }
//check answers
function checkingAnswers(type, array, value, state){
switch(type){
case "radio":
for(var i in array)
if(array[i].value == value){
array[i].state = "checked";
array[i].was = true;
} else
array[i].state = "";
break;
case "box":
for(i in array)
if(array[i].value == value){
array[i].state = state;
array[i].was = true;
}
break;
case "sel":
for(i in array)
if(array[i].value == value){
array[i].state = "selected";
array[i].was = true;
} else
array[i].state = "";
break;
}
}
//question constructor //question constructor
function Question(){ function Question(){
@ -629,6 +698,10 @@ function Answer(){
this.text = ""; this.text = "";
this.value = ""; this.value = "";
this.state = "";
this.was = false;
} }
//changing the style //changing the style

@ -8,8 +8,8 @@ and open the template in the editor.
<title></title> <title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../css/basic.css"/> <link rel="stylesheet" type="text/css" href="../../css/basic.css"/>
<link rel="stylesheet" href="../../css/fonts/Lobster/stylesheet.css"> <!--<link rel="stylesheet" href="../../css/fonts/Lobster/stylesheet.css">
<link rel="stylesheet" href="../../css/fonts/SF-Toontime/stylesheet.css"> <link rel="stylesheet" href="../../css/fonts/SF-Toontime/stylesheet.css">-->
<script type="text/javascript" src="../../scripts/jquery-1.6.2.min.js"></script> <script type="text/javascript" src="../../scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="scripts/selQuestionApp.js"></script> <script type="text/javascript" src="scripts/selQuestionApp.js"></script>
<script type="text/javascript"> <script type="text/javascript">

@ -41,10 +41,10 @@ var sankoreLang = {
pad: "Планшет" pad: "Планшет"
}; };
var questionArray; var questionArray;
var currentQstId = ""; var currentQstId = "";
var lang = ""; //locale language var lang = ""; //locale language
var begin = true;
function init(){ function init(){
@ -84,11 +84,15 @@ function init(){
} }
displayData(true); displayData(true);
} }
else else{
displayData(false); displayData(false);
begin = false;
}
} }
else else{
displayData(false); displayData(false);
begin = false;
}
//saving widget data into sankore object for a correct import //saving widget data into sankore object for a correct import
if (window.widget) { if (window.widget) {
@ -133,8 +137,12 @@ function init(){
$("#wgt_reload").text(sankoreLang.reload).click(function(){ $("#wgt_reload").text(sankoreLang.reload).click(function(){
if($("#wgt_edit").css("display") == "none") if($("#wgt_edit").css("display") == "none")
$("#wgt_display").trigger("click"); $("#wgt_display").trigger("click");
else else{
window.location.reload(); editData();
mode = false;
displayData(true);
mode = true;
}
}); });
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
@ -302,11 +310,13 @@ function init(){
} }
} else { } else {
if(event.target.type == "radio"){ if(event.target.type == "radio"){
checkingAnswers("radio", getNeededElement(questionArray, currentQstId).answers, event.target.value);
if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns) if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns)
$(event.target).next().next().find("span").css("background-color","#6c0"); $(event.target).next().next().find("span").css("background-color","#6c0");
else else
$(event.target).next().next().find("span").css("background-color","red"); $(event.target).next().next().find("span").css("background-color","red");
} else { } else {
checkingAnswers("box", getNeededElement(questionArray, currentQstId).answers, event.target.value, event.target.checked);
if(getNeededElement(questionArray, currentQstId).rightAns.replace(/,/g,"").indexOf(event.target.value + " ", 0) != -1) if(getNeededElement(questionArray, currentQstId).rightAns.replace(/,/g,"").indexOf(event.target.value + " ", 0) != -1)
$(event.target).next().next().find("span").css("background-color","#6c0"); $(event.target).next().next().find("span").css("background-color","#6c0");
else else
@ -378,10 +388,13 @@ function init(){
$("select").live('change', function(evt){ $("select").live('change', function(evt){
if(mode){ if(mode){
checkingAnswers("sel", getNeededElement(questionArray, currentQstId).answers, event.target.value);
if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns) if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns)
$(event.target).css("background-color","#6c0"); $(event.target).css("background-color","#6c0");
else else
$(event.target).css("background-color","red"); $(event.target).css("background-color","red");
if(event.target.value == 0)
$(event.target).css("background-color","");
flagForSelect = false; flagForSelect = false;
} }
}); });
@ -403,6 +416,12 @@ function init(){
//set widget in edit mode //set widget in edit mode
function editData(){ function editData(){
for(var i in questionArray)
for(var j in questionArray[i].answers){
questionArray[i].answers[j].state = "";
questionArray[i].answers[j].was = false
}
$(".qstDivDisplay").remove(); $(".qstDivDisplay").remove();
$("#addQstDiv").show('fast'); $("#addQstDiv").show('fast');
@ -434,21 +453,41 @@ function init(){
for(var j in array[i].answers){ for(var j in array[i].answers){
switch(type){ switch(type){
case "1": 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'>"); newAnswer = $("<div class='newAnswer'>");
var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' style='float: left; margin-right: 10px;'/>").appendTo(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 ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
var ansContent = $("<div class='ansContentDisplay'><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer); var ansContent = $("<div class='ansContentDisplay'><span id='answerText' " + local_color + ">" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
break; break;
case "2": 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'>"); newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' style='float: left; margin-right: 10px;'/>").appendTo(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); ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay'><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer); ansContent = $("<div class='ansContentDisplay'><span id='answerText' " + local_color + ">" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
break; break;
case "3": case "3":
ansInput = $("<option value='" + array[i].answers[j].value + "'>" + array[i].answers[j].text + "</option>").appendTo(selInput); 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; break;
} }
ansCount++; ansCount++;
@ -456,6 +495,7 @@ function init(){
qstDiv.appendTo("#data"); qstDiv.appendTo("#data");
counter++; counter++;
} }
begin = false;
} else { } else {
counter = 1; counter = 1;
qstDiv = $("<div class='qstDivDisplay'>"); qstDiv = $("<div class='qstDivDisplay'>");
@ -606,6 +646,35 @@ function refreshQst(){
$("#addQsqSpan1").text(sankoreLang.q + ++count); $("#addQsqSpan1").text(sankoreLang.q + ++count);
} }
//check answers
function checkingAnswers(type, array, value, state){
switch(type){
case "radio":
for(var i in array)
if(array[i].value == value){
array[i].state = "checked";
array[i].was = true;
} else
array[i].state = "";
break;
case "box":
for(i in array)
if(array[i].value == value){
array[i].state = state;
array[i].was = true;
}
break;
case "sel":
for(i in array)
if(array[i].value == value){
array[i].state = "selected";
array[i].was = true;
} else
array[i].state = "";
break;
}
}
//question constructor //question constructor
function Question(){ function Question(){
@ -629,6 +698,10 @@ function Answer(){
this.text = ""; this.text = "";
this.value = ""; this.value = "";
this.state = "";
this.was = false;
} }
//changing the style //changing the style

@ -41,10 +41,10 @@ var sankoreLang = {
pad: "Pad" pad: "Pad"
}; };
var questionArray; var questionArray;
var currentQstId = ""; var currentQstId = "";
var lang = ""; //locale language var lang = ""; //locale language
var begin = true;
function init(){ function init(){
@ -84,11 +84,15 @@ function init(){
} }
displayData(true); displayData(true);
} }
else else{
displayData(false); displayData(false);
begin = false;
}
} }
else else{
displayData(false); displayData(false);
begin = false;
}
//saving widget data into sankore object for a correct import //saving widget data into sankore object for a correct import
if (window.widget) { if (window.widget) {
@ -133,8 +137,12 @@ function init(){
$("#wgt_reload").text(sankoreLang.reload).click(function(){ $("#wgt_reload").text(sankoreLang.reload).click(function(){
if($("#wgt_edit").css("display") == "none") if($("#wgt_edit").css("display") == "none")
$("#wgt_display").trigger("click"); $("#wgt_display").trigger("click");
else else{
window.location.reload(); editData();
mode = false;
displayData(true);
mode = true;
}
}); });
$(".style_select option[value='1']").text(sankoreLang.slate); $(".style_select option[value='1']").text(sankoreLang.slate);
@ -302,11 +310,13 @@ function init(){
} }
} else { } else {
if(event.target.type == "radio"){ if(event.target.type == "radio"){
checkingAnswers("radio", getNeededElement(questionArray, currentQstId).answers, event.target.value);
if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns) if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns)
$(event.target).next().next().find("span").css("background-color","#6c0"); $(event.target).next().next().find("span").css("background-color","#6c0");
else else
$(event.target).next().next().find("span").css("background-color","red"); $(event.target).next().next().find("span").css("background-color","red");
} else { } else {
checkingAnswers("box", getNeededElement(questionArray, currentQstId).answers, event.target.value, event.target.checked);
if(getNeededElement(questionArray, currentQstId).rightAns.replace(/,/g,"").indexOf(event.target.value + " ", 0) != -1) if(getNeededElement(questionArray, currentQstId).rightAns.replace(/,/g,"").indexOf(event.target.value + " ", 0) != -1)
$(event.target).next().next().find("span").css("background-color","#6c0"); $(event.target).next().next().find("span").css("background-color","#6c0");
else else
@ -378,10 +388,13 @@ function init(){
$("select").live('change', function(evt){ $("select").live('change', function(evt){
if(mode){ if(mode){
checkingAnswers("sel", getNeededElement(questionArray, currentQstId).answers, event.target.value);
if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns) if(event.target.value == getNeededElement(questionArray, currentQstId).rightAns)
$(event.target).css("background-color","#6c0"); $(event.target).css("background-color","#6c0");
else else
$(event.target).css("background-color","red"); $(event.target).css("background-color","red");
if(event.target.value == 0)
$(event.target).css("background-color","");
flagForSelect = false; flagForSelect = false;
} }
}); });
@ -403,6 +416,12 @@ function init(){
//set widget in edit mode //set widget in edit mode
function editData(){ function editData(){
for(var i in questionArray)
for(var j in questionArray[i].answers){
questionArray[i].answers[j].state = "";
questionArray[i].answers[j].was = false
}
$(".qstDivDisplay").remove(); $(".qstDivDisplay").remove();
$("#addQstDiv").show('fast'); $("#addQstDiv").show('fast');
@ -434,21 +453,41 @@ function init(){
for(var j in array[i].answers){ for(var j in array[i].answers){
switch(type){ switch(type){
case "1": 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'>"); newAnswer = $("<div class='newAnswer'>");
var ansInput = $("<input type='radio' name='" + counter + "' value='" + array[i].answers[j].value + "' style='float: left; margin-right: 10px;'/>").appendTo(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 ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
var ansContent = $("<div class='ansContentDisplay'><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer); var ansContent = $("<div class='ansContentDisplay'><span id='answerText' " + local_color + ">" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
break; break;
case "2": 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'>"); newAnswer = $("<div class='newAnswer'>");
ansInput = $("<input type='checkbox' value='" + array[i].answers[j].value + "' style='float: left; margin-right: 10px;'/>").appendTo(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); ansSpan = $("<span class='ansSpanDisplay'>" + ansCount + ".</span>").appendTo(newAnswer);
ansContent = $("<div class='ansContentDisplay'><span id='answerText'>" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer); ansContent = $("<div class='ansContentDisplay'><span id='answerText' " + local_color + ">" + array[i].answers[j].text + "</span></div>").appendTo(newAnswer);
newAnswer.appendTo(ansDiv); newAnswer.appendTo(ansDiv);
break; break;
case "3": case "3":
ansInput = $("<option value='" + array[i].answers[j].value + "'>" + array[i].answers[j].text + "</option>").appendTo(selInput); 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; break;
} }
ansCount++; ansCount++;
@ -456,6 +495,7 @@ function init(){
qstDiv.appendTo("#data"); qstDiv.appendTo("#data");
counter++; counter++;
} }
begin = false;
} else { } else {
counter = 1; counter = 1;
qstDiv = $("<div class='qstDivDisplay'>"); qstDiv = $("<div class='qstDivDisplay'>");
@ -606,6 +646,35 @@ function refreshQst(){
$("#addQsqSpan1").text(sankoreLang.q + ++count); $("#addQsqSpan1").text(sankoreLang.q + ++count);
} }
//check answers
function checkingAnswers(type, array, value, state){
switch(type){
case "radio":
for(var i in array)
if(array[i].value == value){
array[i].state = "checked";
array[i].was = true;
} else
array[i].state = "";
break;
case "box":
for(i in array)
if(array[i].value == value){
array[i].state = state;
array[i].was = true;
}
break;
case "sel":
for(i in array)
if(array[i].value == value){
array[i].state = "selected";
array[i].was = true;
} else
array[i].state = "";
break;
}
}
//question constructor //question constructor
function Question(){ function Question(){
@ -629,6 +698,10 @@ function Answer(){
this.text = ""; this.text = "";
this.value = ""; this.value = "";
this.state = "";
this.was = false;
} }
//changing the style //changing the style

Loading…
Cancel
Save