From 4d4d8f001db3a8d2025763819ef171a11505a6cf Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 23 Nov 2017 22:19:49 +0100 Subject: zelfoverhoor: Editing and various improvements --- modules/zelfoverhoor/TODO.txt | 1 + modules/zelfoverhoor/docent.html | 4 +- modules/zelfoverhoor/docent.js | 83 ++++++++++++++++++++++++++++++++-- modules/zelfoverhoor/zelfoverhoor.js | 88 +++++++++++++++++++++++++++--------- 4 files changed, 150 insertions(+), 26 deletions(-) create mode 100644 modules/zelfoverhoor/TODO.txt (limited to 'modules/zelfoverhoor') diff --git a/modules/zelfoverhoor/TODO.txt b/modules/zelfoverhoor/TODO.txt new file mode 100644 index 0000000..4997eb3 --- /dev/null +++ b/modules/zelfoverhoor/TODO.txt @@ -0,0 +1 @@ +- numbering of questions in docent edit view diff --git a/modules/zelfoverhoor/docent.html b/modules/zelfoverhoor/docent.html index 224384d..95a5da7 100644 --- a/modules/zelfoverhoor/docent.html +++ b/modules/zelfoverhoor/docent.html @@ -43,7 +43,8 @@ td, th {
diff --git a/modules/zelfoverhoor/docent.js b/modules/zelfoverhoor/docent.js index 7987351..96ec38b 100644 --- a/modules/zelfoverhoor/docent.js +++ b/modules/zelfoverhoor/docent.js @@ -1,4 +1,5 @@ var questionsets=null; +var currentlyEditing=null; function getQuestionSets(){ var xhr=new XMLHttpRequest(); @@ -26,6 +27,7 @@ function updateQuestionSetsList(){ } for(var i=0;i: {q: "question", a: "answer"}} var questiondb={}; // {: {id, name, description, questions: []}} @@ -55,6 +57,31 @@ function shuffle(a){ } } +function checkQsetJson(json,errfunc){ + var qset; + try { + qset=JSON.parse(json); + } catch(e){ + errfunc("Invalid json received"); + return null; + } + if(!qset.name||typeof qset.name!="string"|| + !qset.description||typeof qset.description!="string"|| + !qset.questions||!Array.isArray(qset.questions)){ + errfunc("Invalid data received"); + return null; + } + var i; + for(i=0;i