From 7068ba98fb668d7ec32ab3be39b2928cf2601522 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 23 Nov 2017 22:18:50 +0100 Subject: zelfoverhoor: Improve qs interface --- modules/zelfoverhoor/qs.html | 5 +++-- modules/zelfoverhoor/qs.js | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/modules/zelfoverhoor/qs.html b/modules/zelfoverhoor/qs.html index 32c9099..7191aeb 100644 --- a/modules/zelfoverhoor/qs.html +++ b/modules/zelfoverhoor/qs.html @@ -43,7 +43,7 @@ var questionset=/*###QUESTIONSET###*/;



- Vraag:
+ Vraag: ()


@@ -56,8 +56,9 @@ var questionset=/*###QUESTIONSET###*/;
Je hebt alle vragen gehad!
-

Je had vragen goed van de in totaal vragen.

+

Je had goed van de in totaal .

Gefeliciteerd met je prestatie! :D

+

Niet erg, gewoon nog een keer proberen!

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(/\n/g,"
"); +} + +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){ -- cgit v1.2.3-70-g09d2