1 //TODO: compute grades after exam (in teacher's view)
6 assessmentArray: assessmentArray
,
12 group: 1, //for detailed grades tables
13 grades: { }, //computed
20 gradeSettings: function() {
21 $("#gradeSettings").modal("open");
22 Materialize
.updateTextFields(); //total points field in grade settings overlap
24 download: function() {
25 // Download (all) grades as a CSV file
27 this.studentList(0).forEach( s
=> {
30 if (!!this.grades
[s
.number
])
32 Object
.keys(this.grades
[s
.number
]).forEach( assessmentName
=> {
33 s
[assessmentName
] = this.grades
[s
.number
][assessmentName
];
34 if (_
.isNumeric(s
[assessmentName
]) && !isNaN(s
[assessmentName
]))
36 finalGrade
+= s
[assessmentName
];
40 finalGrade
/= gradesCount
;
41 s
["final"] = finalGrade
; //TODO: forbid "final" as assessment name
44 data
.push(s
); //number,name,group,assessName1...assessNameN,final
46 let csv
= Papa
.unparse(data
, {
50 let downloadAnchor
= $("#download");
51 downloadAnchor
.attr("download", this.course
.code
+ "_results.csv");
52 downloadAnchor
.attr("href", "data:text/plain;charset=utf-8," + encodeURIComponent(csv
));
53 this.$refs
.download
.click()
54 //downloadAnchor.click(); //fails
56 showDetails: function(group
) {
58 $("#detailedGrades").modal("open");
60 groupList: function() {
62 this.course
.students
.forEach( s
=> {
66 return _
.range(1,maxGrp
+1);
68 grade: function(assessmentIndex
, studentNumber
) {
69 if (!this.grades
[assessmentIndex
] || !this.grades
[assessmentIndex
][studentNumber
])
70 return ""; //no grade yet
71 return this.grades
[assessmentIndex
][studentNumber
];
73 groupId: function(group
, prefix
) {
74 return (prefix
|| "") + "group" + group
;
76 togglePresence: function(number
, index
) {
78 // TODO: if no grade (thus automatic 0), toggle "exempt" state on student for current exam
79 // --> automatic update of grades view (just a few number to change)
81 computeGrades: function() {
83 // TODO: compute all grades using settings (points, coefficients, bonus/malus...).
84 // If some questions with free answers (open), display answers and ask teacher action.
85 // TODO: need a setting for that too (by student, by exercice, by question)