From: Benjamin Auder Date: Sun, 25 Feb 2018 17:29:32 +0000 (+0100) Subject: 'update' X-Git-Url: https://git.auder.net/variants/current/doc/css/img/assets/index.css?a=commitdiff_plain;h=c8f686978d7aa317d3496852ce72611aca9eca20;p=qomet.git 'update' --- diff --git a/public/javascripts/components/statements.js b/public/javascripts/components/statements.js index 6e12eb6..65bab5f 100644 --- a/public/javascripts/components/statements.js +++ b/public/javascripts/components/statements.js @@ -41,7 +41,9 @@ Vue.component("statements", { const dotPos = q.index.indexOf("."); return dotPos === -1 ? q.index : q.index.substring(0,dotPos); }); - let domTree = questionGroups.map( (qg,i) => { + let domTree = Object.keys(questionGroups).map( idx => { + let qg = questionGroups[idx]; + const i = parseInt(idx); // Re-order questions 1.1.1 then 1.1.2 then... const orderedQg = qg.sort( (a,b) => { let aParts = a.split('.').map(Number); diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 781424a..7006933 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -39,13 +39,13 @@ new Vue({ newEvaluation: { name: "" }, evaluationArray: evaluationArray, mode: "view", //or "edit" (some evaluation) - evaluationIndex: 0, //current edited evaluation index + evaluationIndex: -1, //current edited evaluation index evaluation: { }, //copy of evaluation at editing index in array questionsText: "", //questions in an evaluation, in text format }, mounted: function() { $('.modal').modal(); - Materialize.updateTextFields(); //textareas, time field... + //Materialize.updateTextFields(); //textareas, time field... }, methods: { // GENERAL: diff --git a/views/course.pug b/views/course.pug index cfe56a4..4e44ec7 100644 --- a/views/course.pug +++ b/views/course.pug @@ -18,7 +18,7 @@ block content a.waves-effect.waves-light.btn(href="#!" @click="addEvaluation()") span Submit i.material-icons.right send - .row + .row(style="margin-bottom:0") .col.s12.m10.offset-m1 h4.title(@click="toggleDisplay('students')") Students .card(v-show="display=='students'") @@ -36,7 +36,7 @@ block content td {{ student.number }} td {{ student.name }} td {{ student.group }} - .row + .row(style="margin-bottom:0") .col.s12.m10.offset-m1 h4.title(@click="toggleDisplay('evaluations')") Evaluations .card(v-show="display=='evaluations'") @@ -57,59 +57,58 @@ block content td {{ evaluation.name }} td {{ evaluation.mode }} td {{ evaluation.questions.length }} - if teacher - .row - .col.s12.m10.offset-m1 - h4 {{ evaluation.name }} - .card(v-show="mode=='view'") - .center-align - button.waves-effect.waves-light.btn.on-left(@click="mode='edit'") Edit - button.waves-effect.waves-light.btn(@click="redirect(evaluation.name)") View - div - .introduction(v-html="evaluation.introduction") - statements(:questions="evaluation.questions" :display="solution") - .card(v-show="mode=='edit'") - form(@submit.prevent) - p - input#active(type="checkbox" v-model="evaluation.active") - label(for="active") evaluation is active - div - h4 Questions mode: - span(title="Exam mode, secured (class only): students cannot lose focus or exit fullscreen") - input#secure(name="status" type="radio" value="secure" v-model="evaluation.mode") - label(for="secure") secure - span(title="Exam mode, watched (class only): teachers are notified when students lose focus or resize window") - input#watch(name="status" type="radio" value="watch" v-model="evaluation.mode") - label(for="watch") watch - span(title="Exam mode, unwatched: students can browse the web freely") - input#exam(name="status" type="radio" value="exam" v-model="evaluation.mode") - label(for="exam") exam - span(title="Questions list open to the world (useful mode after an exam, or for a 'questions bank'") - input#open(name="status" type="radio" value="open" v-model="evaluation.mode") - label(for="open") open - p - input#fixed(type="checkbox" v-model="evaluation.fixed") - label(for="fixed") Fixed questions order - div - h4 Display type: - span(title="Show only one question at a time (with potential sub-questions)") - input#displayOne(name="display" type="radio" value="one" v-model="evaluation.display") - label(for="displayOne") one - span(title="Always show all questions (with an optional navigator)") - input#displayAll(name="display" type="radio" value="all" v-model="evaluation.display") - label(for="displayAll") all - .input-field - input#time(type="number" v-model.number="evaluation.time") - label(for="time") Time (minutes) - .input-field - textarea#introduction.materialize-textarea(v-model="evaluation.introduction") - label(for="introduction") Introduction - .input-field - textarea#evaluationEdition.materialize-textarea(v-model="evaluationText") - label(for="evaluationEdition") evaluation in text format - .center-align - button.waves-effect.waves-light.btn.on-left(@click="updateEvaluation()") Send - button.waves-effect.waves-light.btn(@click="mode='view'") Cancel + if teacher + div(v-show="evaluationIndex >= 0") + h4 {{ evaluation.name }} + .card(v-show="mode=='view'") + .center-align + button.waves-effect.waves-light.btn.on-left(@click="mode='edit'") Edit + button.waves-effect.waves-light.btn(@click="redirect(evaluation.name)") View + div + .introduction(v-html="evaluation.introduction") + statements(:questions="evaluation.questions" :display="'solution'") + .card(v-show="mode=='edit'") + form(@submit.prevent) + p + input#active(type="checkbox" v-model="evaluation.active") + label(for="active") evaluation is active + div + h4 Questions mode: + span(title="Exam mode, secured (class only): students cannot lose focus or exit fullscreen") + input#secure(name="status" type="radio" value="secure" v-model="evaluation.mode") + label(for="secure") secure + span(title="Exam mode, watched (class only): teachers are notified when students lose focus or resize window") + input#watch(name="status" type="radio" value="watch" v-model="evaluation.mode") + label(for="watch") watch + span(title="Exam mode, unwatched: students can browse the web freely") + input#exam(name="status" type="radio" value="exam" v-model="evaluation.mode") + label(for="exam") exam + span(title="Questions list open to the world (useful mode after an exam, or for a 'questions bank'") + input#open(name="status" type="radio" value="open" v-model="evaluation.mode") + label(for="open") open + p + input#fixed(type="checkbox" v-model="evaluation.fixed") + label(for="fixed") Fixed questions order + div + h4 Display type: + span(title="Show only one question at a time (with potential sub-questions)") + input#displayOne(name="display" type="radio" value="one" v-model="evaluation.display") + label(for="displayOne") one + span(title="Always show all questions (with an optional navigator)") + input#displayAll(name="display" type="radio" value="all" v-model="evaluation.display") + label(for="displayAll") all + .input-field + input#time(type="number" v-model.number="evaluation.time") + label(for="time") Time (minutes) + .input-field + textarea#introduction.materialize-textarea(v-model="evaluation.introduction") + label(for="introduction") Introduction + .input-field + textarea#evaluationEdition.materialize-textarea(v-model="questionsText") + label(for="evaluationEdition") evaluation in text format + .center-align + button.waves-effect.waves-light.btn.on-left(@click="updateEvaluation()") Send + button.waves-effect.waves-light.btn(@click="mode='view'") Cancel block append javascripts script(src="//cdnjs.cloudflare.com/ajax/libs/PapaParse/4.3.6/papaparse.min.js") @@ -120,5 +119,6 @@ block append javascripts const admin = #{teacher}; script(src="/javascripts/utils/sha1.js") script(src="/javascripts/utils/validation.js") + script(src="/javascripts/utils/libsRefresh.js") script(src="/javascripts/components/statements.js") script(src="/javascripts/course.js")