2
Copyright 2009-2013, Marten de Vries
4
This file is part of OpenTeacher.
6
OpenTeacher is free software: you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
11
OpenTeacher is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with OpenTeacher. If not, see <http://www.gnu.org/licenses/>.
20
var calculateNote, calculateAverageNote;
23
function formatNote(note) {
25
//makes sure '10,0' isn't returned, since that's not a valid
26
//dutch note. (It would mean that 10.8 would be possible,
30
return note.toFixed(1).replace(".", ",");
33
function calculateNumber(test) {
34
var results = map(function (result) {
35
return result.result === "right" ? 1 : 0;
37
var total = results.length;
38
var amountRight = sum(results);
40
return amountRight / total * 9 + 1;
43
calculateNote = function (test) {
44
return formatNote(calculateNumber(test));
47
calculateAverageNote = function (tests) {
48
var notes = map(calculateNumber, tests);
49
return formatNote(sum(notes) / tests.length);