+ // TODO: redundant code, next 4 funcs already exist in course.js
+ toggleDisplay: function(area) {
+ if (this.display == area)
+ this.display = "";
+ else
+ this.display = area;
+ },
+ studentList: function(group) {
+ return this.students
+ .filter( s => { return group==0 || s.group == group; })
+ .map( s => { return Object.assign({}, s); }) //not altering initial array
+ .sort( (a,b) => {
+ let res = a.name.localeCompare(b.name);
+ if (res == 0)
+ res += a.forename.localeCompare(b.forename);
+ return res;
+ });
+ },
+ groupList: function() {
+ let maxGrp = 1;
+ this.students.forEach( s => {
+ if (s.group > maxGrp)
+ maxGrp = s.group;
+ });
+ return _.range(1,maxGrp+1);
+ },
+ groupId: function(group, prefix) {
+ return (prefix || "") + "group" + group;
+ },
+ getColor: function(number, qIdx) {
+ // For the moment, green if correct and red if wrong; grey if unanswered yet
+ // TODO: in-between color for partially right (especially for multi-questions)
+ const paperIdx = this.assessment.papers.findIndex( item => { return item.number == number; });
+ if (paperIdx === -1)
+ return "grey"; //student didn't start yet
+ const inputIdx = this.assessment.papers[paperIdx].inputs.findIndex( item => {
+ const qNum = parseInt(item.index.split(".")[0]); //indexes separated by dots
+ return qIdx == qNum;
+ });
+ if (inputIdx === -1)
+ return "grey";
+ if (_.isEqual(this.assessment.papers[paperIdx].inputs[inputIdx].input, this.assessment.questions[qIdx].answer))
+ return "green";
+ return "red";
+ },
+ seeDetails: function(number, i) {
+ // UNIMPLEMENTED: see question details, with current answer(s)
+ },