From a00c93ac174b4c9b01ddd020f8a6d4a32e18f5b2 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 2 Mar 2018 12:17:29 +0100 Subject: zelfoverhoor: Insert questions halfway while editing --- modules/zelfoverhoor/docent.html | 2 +- modules/zelfoverhoor/docent.js | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'modules/zelfoverhoor') diff --git a/modules/zelfoverhoor/docent.html b/modules/zelfoverhoor/docent.html index c3c1d7b..501d007 100644 --- a/modules/zelfoverhoor/docent.html +++ b/modules/zelfoverhoor/docent.html @@ -21,7 +21,7 @@ td, th { padding: 4px; } .newquestioncontainer { - margin-bottom: 10px; + margin-bottom: 5px; } .newquestioncontainer > span { margin-right: 5px; diff --git a/modules/zelfoverhoor/docent.js b/modules/zelfoverhoor/docent.js index c14fb2e..b44d4b6 100644 --- a/modules/zelfoverhoor/docent.js +++ b/modules/zelfoverhoor/docent.js @@ -181,17 +181,33 @@ function renumberQuestions(){ function addNewQuestion(){ var parent=document.getElementById("newquestions"); + var number=parent.children.length; var div=document.createElement("div"); div.classList.add("newquestioncontainer"); + if(number>0){ + var insertbtn=document.createElement("input"); + insertbtn.setAttribute("type","button"); + insertbtn.setAttribute("value","Voeg vraag hier toe"); + insertbtn.setAttribute("style","margin-bottom:5px"); + insertbtn.addEventListener("click",function(){ + addNewQuestion(); + var newdiv=parent.children[parent.children.length-1]; + parent.insertBefore(newdiv,div); + renumberQuestions(); + }); + div.appendChild(insertbtn); + div.appendChild(document.createElement("br")); + } + var span=document.createElement("span"); span.setAttribute("style","display:inline-block"); var b=document.createElement("b"); b.appendChild(document.createTextNode("Vraag ")); - var span2=document.createElement("span2"); + var span2=document.createElement("span"); span2.classList.add("questionindex"); - span2.innerHTML=parent.children.length+1; + span2.innerHTML=number+1; b.appendChild(span2); b.appendChild(document.createTextNode(":")); span.appendChild(b); -- cgit v1.2.3-70-g09d2