@ -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 : "O ptions" ,
options : "Les o ptions" ,
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 ;
}
}
}
}