@ -15,7 +15,7 @@
var sankoreLang = {
var sankoreLang = {
edit : "Modifier" ,
edit : "Modifier" ,
display : "Affich er" ,
display : "Ferm er" ,
question : "La question" ,
question : "La question" ,
example _question : "Ceci est un exemple de question" ,
example _question : "Ceci est un exemple de question" ,
answer : "Ceci est une réponse possible" ,
answer : "Ceci est une réponse possible" ,
@ -61,7 +61,8 @@ var sankoreLang = {
"<p>Pour supprimer un exercice, cliquez sur la croix à droite du numéro de ”Options”.</p>" +
"<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>"
"<p>Le bouton “Afficher” vous permet d’utiliser l’activité.</p>" ,
theme : "Thème"
} ;
} ;
var questionArray ;
var questionArray ;
@ -85,10 +86,11 @@ function init(){
$ ( "#wgt_reload" ) . text ( sankoreLang . reload ) ;
$ ( "#wgt_reload" ) . text ( sankoreLang . reload ) ;
$ ( "#wgt_help" ) . text ( sankoreLang . help ) ;
$ ( "#wgt_help" ) . text ( sankoreLang . help ) ;
$ ( "#help" ) . html ( sankoreLang . help _content ) ;
$ ( "#help" ) . html ( sankoreLang . help _content ) ;
$ ( ".style_select option[value='1']" ) . text ( sankoreLang . slate ) ;
$ ( "#style_select option[value='1']" ) . text ( sankoreLang . slate ) ;
$ ( ".style_select option[value='2']" ) . text ( sankoreLang . pad ) ;
$ ( "#style_select option[value='2']" ) . text ( sankoreLang . pad ) ;
$ ( ".style_select option[value='3']" ) . text ( sankoreLang . none ) ;
$ ( "#style_select option[value='3']" ) . text ( sankoreLang . none ) ;
var tmpl = $ ( "div.inline label" ) . html ( ) ;
$ ( "div.inline label" ) . html ( sankoreLang . theme + tmpl )
//popup message
//popup message
var popupText = $ ( "<div id='popupWordInfo' class='popupWordInfo'></div>" ) . appendTo ( "#data" ) ;
var popupText = $ ( "<div id='popupWordInfo' class='popupWordInfo'></div>" ) . appendTo ( "#data" ) ;
@ -127,14 +129,14 @@ function init(){
if ( window . widget ) {
if ( window . widget ) {
window . widget . onleave = function ( ) {
window . widget . onleave = function ( ) {
sankore . setPreference ( "qstArrayData" , JSON . stringify ( questionArray ) ) ;
sankore . setPreference ( "qstArrayData" , JSON . stringify ( questionArray ) ) ;
sankore . setPreference ( "choisir_style" , $ ( ". style_select" ) . find ( "option:selected" ) . val ( ) ) ;
sankore . setPreference ( "choisir_style" , $ ( "# style_select" ) . find ( "option:selected" ) . val ( ) ) ;
}
}
}
}
if ( window . sankore )
if ( window . sankore )
if ( sankore . preference ( "choisir_style" , "" ) ) {
if ( sankore . preference ( "choisir_style" , "" ) ) {
changeStyle ( sankore . preference ( "choisir_style" , "" ) ) ;
changeStyle ( sankore . preference ( "choisir_style" , "" ) ) ;
$ ( ". style_select" ) . val ( sankore . preference ( "choisir_style" , "" ) ) ;
$ ( "# style_select" ) . val ( sankore . preference ( "choisir_style" , "" ) ) ;
} else
} else
changeStyle ( "3" )
changeStyle ( "3" )
@ -143,21 +145,21 @@ function init(){
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
$ ( this ) . addClass ( "selected" ) ;
$ ( this ) . addClass ( "selected" ) ;
$ ( "#wgt_edit" ) . removeClass ( "selected" ) ;
$ ( "#wgt_edit" ) . removeClass ( "selected" ) ;
$ ( ".style_select " ) . css ( "display" , "none" ) ;
$ ( "#parameters " ) . css ( "display" , "none" ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_edit" ) . css ( "display" , "block" ) ;
$ ( "#wgt_edit" ) . css ( "display" , "block" ) ;
displayData ( true ) ;
displayData ( true ) ;
mode = true ;
mode = true ;
if ( window . sankore ) {
if ( window . sankore ) {
sankore . setPreference ( "qstArrayData" , JSON . stringify ( questionArray ) ) ;
sankore . setPreference ( "qstArrayData" , JSON . stringify ( questionArray ) ) ;
sankore . setPreference ( "choisir_style" , $ ( ". style_select" ) . find ( "option:selected" ) . val ( ) ) ;
sankore . setPreference ( "choisir_style" , $ ( "# style_select" ) . find ( "option:selected" ) . val ( ) ) ;
}
}
}
}
} else {
} else {
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
if ( ! $ ( this ) . hasClass ( "selected" ) ) {
$ ( this ) . addClass ( "selected" ) ;
$ ( this ) . addClass ( "selected" ) ;
$ ( "#wgt_display" ) . removeClass ( "selected" ) ;
$ ( "#wgt_display" ) . removeClass ( "selected" ) ;
$ ( ".style_select " ) . css ( "display" , "block" ) ;
$ ( "#parameters " ) . css ( "display" , "block" ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( this ) . css ( "display" , "none" ) ;
$ ( "#wgt_display" ) . css ( "display" , "block" ) ;
$ ( "#wgt_display" ) . css ( "display" , "block" ) ;
editData ( ) ;
editData ( ) ;
@ -165,15 +167,17 @@ function init(){
}
}
}
}
} ) ;
} ) ;
$ ( "#wgt_help" ) . click ( function ( ) {
$ ( "#wgt_help" ) . click ( function ( ) {
var tmp = $ ( this ) ;
var tmp = $ ( this ) ;
if ( $ ( this ) . hasClass ( "open" ) ) {
if ( $ ( this ) . hasClass ( "open" ) ) {
$ ( this ) . removeClass ( "help_pad" ) . removeClass ( "help_wood" )
$ ( "#help" ) . slideUp ( "100" , function ( ) {
$ ( "#help" ) . slideUp ( "100" , function ( ) {
tmp . removeClass ( "open" ) ;
tmp . removeClass ( "open" ) ;
$ ( "#data" ) . show ( ) ;
$ ( "#data" ) . show ( ) ;
} ) ;
} ) ;
} else {
} else {
( $ ( "#style_select" ) . val ( ) == 1 ) ? $ ( this ) . removeClass ( "help_pad" ) . addClass ( "help_wood" ) : $ ( this ) . removeClass ( "help_wood" ) . addClass ( "help_pad" ) ;
$ ( "#data" ) . hide ( ) ;
$ ( "#data" ) . hide ( ) ;
$ ( "#help" ) . slideDown ( "100" , function ( ) {
$ ( "#help" ) . slideDown ( "100" , function ( ) {
tmp . addClass ( "open" ) ;
tmp . addClass ( "open" ) ;
@ -192,10 +196,10 @@ function init(){
}
}
} ) ;
} ) ;
$ ( ". style_select option[value='1']" ) . text ( sankoreLang . slate ) ;
$ ( "# style_select option[value='1']" ) . text ( sankoreLang . slate ) ;
$ ( ". style_select option[value='2']" ) . text ( sankoreLang . pad ) ;
$ ( "# style_select option[value='2']" ) . text ( sankoreLang . pad ) ;
$ ( ". style_select" ) . change ( function ( event ) {
$ ( "# style_select" ) . change ( function ( event ) {
changeStyle ( $ ( this ) . find ( "option:selected" ) . val ( ) ) ;
changeStyle ( $ ( this ) . find ( "option:selected" ) . val ( ) ) ;
} )
} )
@ -477,71 +481,71 @@ function init(){
// show questions and answers in display mode
// show questions and answers in display mode
function addToPage ( array ) {
function addToPage ( array ) {
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 ) {
for ( var j in array [ i ] . answers ) {
switch ( type ) {
switch ( type ) {
case "1" :
case "1" :
var local _state = "" ;
var local _state = "" ;
var local _color = "" ;
var local _color = "" ;
if ( begin ) {
if ( begin ) {
local _state = array [ i ] . answers [ j ] . state ;
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;'" : "" ) ;
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 + "' " + local _state + " 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' " + local _color + "><span id='answerText'>" + array [ i ] . answers [ j ] . text + "</span></div>" ) . appendTo ( newAnswer ) ;
var ansContent = $ ( "<div class='ansContentDisplay' " + local _color + "><span id='answerText'>" + array [ i ] . answers [ j ] . text + "</span></div>" ) . appendTo ( newAnswer ) ;
newAnswer . appendTo ( ansDiv ) ;
newAnswer . appendTo ( ansDiv ) ;
break ;
break ;
case "2" :
case "2" :
local _state = "" ;
local _state = "" ;
local _color = "" ;
local _color = "" ;
if ( begin ) {
if ( begin ) {
local _state = ( array [ i ] . answers [ j ] . state ) ? "checked" : "" ;
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;'" : "" ) ;
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 + "' " + local _state + " 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' " + local _color + "><span id='answerText'>" + array [ i ] . answers [ j ] . text + "</span></div>" ) . appendTo ( newAnswer ) ;
ansContent = $ ( "<div class='ansContentDisplay' " + local _color + "><span id='answerText'>" + array [ i ] . answers [ j ] . text + "</span></div>" ) . appendTo ( newAnswer ) ;
newAnswer . appendTo ( ansDiv ) ;
newAnswer . appendTo ( ansDiv ) ;
break ;
break ;
case "3" :
case "3" :
local _state = "" ;
local _state = "" ;
local _color = "" ;
local _color = "" ;
if ( begin ) {
if ( begin ) {
local _state = ( array [ i ] . answers [ j ] . state ) ? "selected" : "" ;
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" : "" ) ;
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 ) ;
ansInput = $ ( "<option value='" + array [ i ] . answers [ j ] . value + "' " + local _state + ">" + array [ i ] . answers [ j ] . text + "</option>" ) . appendTo ( selInput ) ;
if ( local _state && local _color )
if ( local _state && local _color )
selInput . css ( "background-color" , local _color ) ;
selInput . css ( "background-color" , local _color ) ;
break ;
break ;
}
}
ansCount ++ ;
ansCount ++ ;
}
qstDiv . appendTo ( "#data" ) ;
counter ++ ;
}
}
qstDiv . appendTo ( "#data" ) ;
begin = false ;
counter ++ ;
}
begin = false ;
}
}
}
}
@ -746,10 +750,10 @@ function changeStyle(val){
$ ( "#wgt_reload" ) . removeClass ( "pad_color" ) . removeClass ( "pad_reload" ) ;
$ ( "#wgt_reload" ) . removeClass ( "pad_color" ) . removeClass ( "pad_reload" ) ;
$ ( "#wgt_help" ) . removeClass ( "pad_color" ) . removeClass ( "pad_help" ) ;
$ ( "#wgt_help" ) . removeClass ( "pad_color" ) . removeClass ( "pad_help" ) ;
$ ( "#wgt_edit" ) . removeClass ( "pad_color" ) . removeClass ( "pad_edit" ) ;
$ ( "#wgt_edit" ) . removeClass ( "pad_color" ) . removeClass ( "pad_edit" ) ;
$ ( "#wgt_display" ) . removeClass ( "pad_color" ) . removeClass ( "pad_edit" ) ;
$ ( "#wgt_name" ) . removeClass ( "pad_color" ) ;
$ ( "#wgt_name" ) . removeClass ( "pad_color" ) ;
$ ( ".style_select" ) . removeClass ( "pad_select" ) . removeClass ( "none_select" ) . val ( val ) ;
$ ( "#wgt_display" ) . addClass ( "display_wood" ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) ;
$ ( "#style_select" ) . val ( val ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) . addClass ( "radius_ft" ) ;
break ;
break ;
case "2" :
case "2" :
$ ( ".b_top_left" ) . addClass ( "btl_pad" ) . removeClass ( "without_back" ) ;
$ ( ".b_top_left" ) . addClass ( "btl_pad" ) . removeClass ( "without_back" ) ;
@ -763,10 +767,10 @@ function changeStyle(val){
$ ( "#wgt_reload" ) . addClass ( "pad_color" ) . addClass ( "pad_reload" ) ;
$ ( "#wgt_reload" ) . addClass ( "pad_color" ) . addClass ( "pad_reload" ) ;
$ ( "#wgt_help" ) . addClass ( "pad_color" ) . addClass ( "pad_help" ) ;
$ ( "#wgt_help" ) . addClass ( "pad_color" ) . addClass ( "pad_help" ) ;
$ ( "#wgt_edit" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_edit" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_display" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_name" ) . addClass ( "pad_color" ) ;
$ ( "#wgt_name" ) . addClass ( "pad_color" ) ;
$ ( ".style_select" ) . addClass ( "pad_select" ) . removeClass ( "none_select" ) . val ( val ) ;
$ ( "#wgt_display" ) . removeClass ( "display_wood" ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) ;
$ ( "#style_select" ) . val ( val ) ;
$ ( "body, html" ) . removeClass ( "without_radius" ) . removeClass ( "radius_ft" ) ;
break ;
break ;
case "3" :
case "3" :
$ ( ".b_top_left" ) . addClass ( "without_back" ) . removeClass ( "btl_pad" ) ;
$ ( ".b_top_left" ) . addClass ( "without_back" ) . removeClass ( "btl_pad" ) ;
@ -780,10 +784,10 @@ function changeStyle(val){
$ ( "#wgt_help" ) . addClass ( "pad_color" ) . addClass ( "pad_help" ) ;
$ ( "#wgt_help" ) . addClass ( "pad_color" ) . addClass ( "pad_help" ) ;
$ ( "#wgt_reload" ) . addClass ( "pad_color" ) . addClass ( "pad_reload" ) ;
$ ( "#wgt_reload" ) . addClass ( "pad_color" ) . addClass ( "pad_reload" ) ;
$ ( "#wgt_edit" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_edit" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_display" ) . addClass ( "pad_color" ) . addClass ( "pad_edit" ) ;
$ ( "#wgt_name" ) . addClass ( "pad_color" ) ;
$ ( "#wgt_name" ) . addClass ( "pad_color" ) ;
$ ( ".style_select" ) . addClass ( "none_select" ) . val ( val ) ;
$ ( "#wgt_display" ) . removeClass ( "display_wood" ) ;
$ ( "body, html" ) . addClass ( "without_radius" ) ;
$ ( "#style_select" ) . val ( val ) ;
$ ( "body, html" ) . addClass ( "without_radius" ) . removeClass ( "radius_ft" ) ;
break ;
break ;
}
}
}
}