summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/zelfoverhoor/TODO.txt1
-rw-r--r--modules/zelfoverhoor/docent.js19
2 files changed, 17 insertions, 3 deletions
diff --git a/modules/zelfoverhoor/TODO.txt b/modules/zelfoverhoor/TODO.txt
deleted file mode 100644
index 4997eb3..0000000
--- a/modules/zelfoverhoor/TODO.txt
+++ /dev/null
@@ -1 +0,0 @@
-- numbering of questions in docent edit view
diff --git a/modules/zelfoverhoor/docent.js b/modules/zelfoverhoor/docent.js
index 96ec38b..456ea2f 100644
--- a/modules/zelfoverhoor/docent.js
+++ b/modules/zelfoverhoor/docent.js
@@ -152,6 +152,14 @@ function closeQSetForm(){
currentlyEditing=null;
}
+function renumberQuestions(){
+ var parent=document.getElementById("newquestions");
+ var ch=parent.children,nc=ch.length;
+ for(var i=0;i<nc;i++){
+ ch[i].getElementsByClassName("questionindex")[0].innerHTML=i+1;
+ }
+}
+
function addNewQuestion(){
var parent=document.getElementById("newquestions");
@@ -161,7 +169,12 @@ function addNewQuestion(){
var span=document.createElement("span");
span.setAttribute("style","display:inline-block");
var b=document.createElement("b");
- b.appendChild(document.createTextNode("Vraag:"));
+ b.appendChild(document.createTextNode("Vraag "));
+ var span2=document.createElement("span2");
+ span2.classList.add("questionindex");
+ span2.innerHTML=parent.children.length+1;
+ b.appendChild(span2);
+ b.appendChild(document.createTextNode(":"));
span.appendChild(b);
span.appendChild(document.createElement("br"));
var qta=document.createElement("textarea");
@@ -183,8 +196,10 @@ function addNewQuestion(){
input.setAttribute("value","verwijder vraag");
input.setAttribute("style","vertical-align:50px");
input.addEventListener("click",function(){
- if(confirm("Weet je zeker dat je de volgende vraag wil verwijderen?\n"+qta.value)){
+ var index=div.getElementsByClassName("questionindex")[0].innerHTML;
+ if(confirm("Weet je zeker dat je vraag "+index+" wilt verwijderen?")){
parent.removeChild(div);
+ renumberQuestions();
}
});
span.appendChild(input);