X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=entities%2Fassessment.js;h=b4b6d8932811c33949d10eaf425971ac8b6900fb;hb=db5571d67f6b6b3b841fa1eeaf2099cecf2bcffc;hp=b4e30927204f5b4be77189cdd1dcbc32bc5ecc6d;hpb=2c545c26b465fe40dc308c321a11f5515cebc4c7;p=qomet.git diff --git a/entities/assessment.js b/entities/assessment.js index b4e3092..b4b6d89 100644 --- a/entities/assessment.js +++ b/entities/assessment.js @@ -13,7 +13,6 @@ const AssessmentEntity = * display: "one" or "all" (generally "all" for open questions, but...) * time: 0, //<=0 means "untimed"; otherwise, time in seconds * introduction: "", - * conclusion: "https://www.youtube.com/watch?v=6-9AjToJYuw", * coefficient: number, default 1 * questions: array of * index: for paper test, like 2.1.a (?!); and quiz: 0, 1, 2, 3... @@ -21,12 +20,14 @@ const AssessmentEntity = * options: array of varchar --> if present, question type == quiz! * fixed: bool, options in fixed order (default: false) * answer: array of integers (for quiz) or html text (for paper); striped in exam mode - * active: boolean, is question in current assessment? --> striped if inactive! + * active: boolean, is question in current assessment? * points: points for this question (default 1) * papers : array of * number: student number * inputs: array of indexed arrays of integers (or html text if not quiz) * startTime, endTime + * discoTime, totalDisco: last disconnect timestamp (if relevant) + total + * discoCount: total disconnections * password: random string identifying student for exam session TEMPORARY */ @@ -61,7 +62,6 @@ const AssessmentEntity = display: "one", time: 0, introduction: "", - conclusion: "", coefficient: 1, questions: [ ], papers: [ ], @@ -134,6 +134,8 @@ const AssessmentEntity = startTime: Date.now(), endTime: undefined, password: password, + totalDisco: 0, + discoCount: 0, inputs: [ ], //TODO: this is stage 1, stack indexed answers. // then build JSON tree for easier access / correct }}}, @@ -141,6 +143,47 @@ const AssessmentEntity = ); }, + // NOTE: no callbacks for 2 next functions, failures are not so important + // (because monitored: teachers can see what's going on) + + addDisco: function(aid, number, deltaTime) + { + db.assessments.update( + { + _id: aid, + "papers.number": number, + }, + { $inc: { + "papers.$.discoCount": 1, + "papers.$.totalDisco": deltaTime, + } }, + { $set: { "papers.$.discoTime": null } } + ); + }, + + setDiscoTime: function(aid, number) + { + db.assessments.update( + { + _id: aid, + "papers.number": number, + }, + { $set: { "papers.$.discoTime": Date.now() } } + ); + }, + + getDiscoTime: function(aid, number, cb) + { + db.assessments.findOne( + { _id: aid }, + (err,a) => { + if (!!err) + return cb(err, null); + const idx = a.papers.findIndex( item => { return item.number == number; }); + cb(null, a.papers[idx].discoTime); + } + ); + }, hasInput: function(aid, number, password, idx, cb) { @@ -194,17 +237,6 @@ const AssessmentEntity = ); }, - getConclusion: function(aid, callback) - { - db.assessments.findOne( - { _id: aid }, - { conclusion: 1}, - (err,res) => { - callback(err, !!res ? res.conclusion : null); - } - ); - }, - remove: function(aid, cb) { db.assessments.remove(