diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-11-23 22:32:48 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-11-23 22:32:48 +0100 |
commit | 330d1d5f3a21d9e79342802c0a9be5e399116a5a (patch) | |
tree | d1554f0cb9f840f15ca067c41b4e3a124d387495 | |
parent | 4d4d8f001db3a8d2025763819ef171a11505a6cf (diff) |
zelfoverhoor: Question numbering in edit form
-rw-r--r-- | modules/zelfoverhoor/TODO.txt | 1 | ||||
-rw-r--r-- | modules/zelfoverhoor/docent.js | 19 |
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); |