74e4c048a13a8a9d27592924aa5c918e76ca4488
1 //TODO: compute grades after exam (in teacher's view)
6 evaluationArray: evaluationArray
,
12 group: 1, //for detailed grades tables
13 grades: { }, //computed
17 $('ul.tabs').tabs(); //--> migrate to grade.js
21 gradeSettings: function() {
22 $("#gradeSettings").modal("open");
23 Materialize
.updateTextFields(); //total points field in grade settings overlap
25 download: function() {
26 // Download (all) grades as a CSV file
28 this.studentList(0).forEach( s
=> {
31 if (!!this.grades
[s
.number
])
33 Object
.keys(this.grades
[s
.number
]).forEach( evaluationName
=> {
34 s
[evaluationName
] = this.grades
[s
.number
][evaluationName
];
35 if (_
.isNumeric(s
[evaluationName
]) && !isNaN(s
[evaluationName
]))
37 finalGrade
+= s
[evaluationName
];
41 finalGrade
/= gradesCount
;
42 s
["final"] = finalGrade
; //TODO: forbid "final" as evaluation name
45 data
.push(s
); //number,name,group,assessName1...assessNameN,final
47 let csv
= Papa
.unparse(data
, {
51 let downloadAnchor
= $("#download");
52 downloadAnchor
.attr("download", this.course
.code
+ "_results.csv");
53 downloadAnchor
.attr("href", "data:text/plain;charset=utf-8," + encodeURIComponent(csv
));
54 this.$refs
.download
.click()
55 //downloadAnchor.click(); //fails
57 showDetails: function(group
) {
59 $("#detailedGrades").modal("open");
61 groupList: function() {
63 this.course
.students
.forEach( s
=> {
67 return _
.range(1,maxGrp
+1);
69 grade: function(evaluationIndex
, studentNumber
) {
70 if (!this.grades
[evaluationIndex
] || !this.grades
[evaluationIndex
][studentNumber
])
71 return ""; //no grade yet
72 return this.grades
[evaluationIndex
][studentNumber
];
74 groupId: function(group
, prefix
) {
75 return (prefix
|| "") + "group" + group
;
77 togglePresence: function(number
, index
) {
79 // TODO: if no grade (thus automatic 0), toggle "exempt" state on student for current exam
80 // --> automatic update of grades view (just a few number to change)
82 computeGrades: function() {
84 // TODO: compute all grades using settings (points, coefficients, bonus/malus...).
85 // If some questions with free answers (open), display answers and ask teacher action.
86 // TODO: need a setting for that too (by student, by exercice, by question)