diff options
Diffstat (limited to 'modules/zelfoverhoor/qs.js')
-rw-r--r-- | modules/zelfoverhoor/qs.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/modules/zelfoverhoor/qs.js b/modules/zelfoverhoor/qs.js index 6b04487..43d68f0 100644 --- a/modules/zelfoverhoor/qs.js +++ b/modules/zelfoverhoor/qs.js @@ -15,15 +15,29 @@ function startQuiz(){ showCurrent(); } +function simpleFormat(text){ + return text + .replace(/&/g,"&") + .replace(/</g,"<") + .replace(/>/g,">") + .replace(/\n/g,"<br>"); +} + +function pluralVraag(n){ + if(n==1)return "vraag"; + else return "vragen"; +} + function showCurrent(){ document.getElementById("qcontainer").classList.remove("invisible"); document.getElementById("rescontainer").classList.add("invisible"); document.getElementById("answercontainer").classList.add("invisible"); document.getElementById("showAnswerButton").classList.remove("invisible"); + document.getElementById("progress").innerHTML=(currentidx+1)+"/"+questions.length; var qdiv=document.getElementById("question"); clearElement(qdiv); - qdiv.appendChild(document.createTextNode(questions[currentidx].q)); + qdiv.innerHTML=simpleFormat(questions[currentidx].q); } function showAnswer(){ @@ -32,19 +46,26 @@ function showAnswer(){ var adiv=document.getElementById("answer"); clearElement(adiv); - adiv.appendChild(document.createTextNode(questions[currentidx].a)); + adiv.innerHTML=simpleFormat(questions[currentidx].a); } function finishQuiz(){ document.getElementById("qcontainer").classList.add("invisible"); document.getElementById("rescontainer").classList.remove("invisible"); document.getElementById("numcorrect").innerHTML=numcorrect; + document.getElementById("numcorrectvraag").innerHTML=pluralVraag(numcorrect); document.getElementById("numtotal").innerHTML=questions.length; + document.getElementById("numtotalvraag").innerHTML=pluralVraag(questions.length); if(numcorrect==questions.length){ document.getElementById("allcorrectp").classList.remove("invisible"); } else { document.getElementById("allcorrectp").classList.add("invisible"); } + if(numcorrect==0){ + document.getElementById("allwrongp").classList.remove("invisible"); + } else { + document.getElementById("allwrongp").classList.add("invisible"); + } } function advance(corr){ |