-
Notifications
You must be signed in to change notification settings - Fork 0
/
evalData.js
295 lines (280 loc) · 9.94 KB
/
evalData.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
//grades and statistics are generated here
function getAllMissingTests(className)
{
var data=[];
var big=getBig(className);
for(var j=0;j<big.length;j++)//nr of big ex
for(var k=0;k<big[j].groups.length;k++)//nr of groups
for(var l=0;l<big[j].groups[k].pupils.length;l++)
if(!theData[className].big[j].groups[k].pupils[l].returned)
data.push({exercisename: theData[className].big[j].name, pupilname: theData[className].big[j].groups[k].pupils[l].name, big: true });
var small=getSmall(className);
for(var j=0;j<small.length;j++)//nr of big ex
for(var k=0;k<small[j].groups.length;k++)//nr of groups
for(var l=0;l<small[j].groups[k].pupils.length;l++)
if(!theData[className].small[j].groups[k].pupils[l].returned)
data.push({exercisename: theData[className].small[j].name, pupilname: theData[className].small[j].groups[k].pupils[l].name, big: false});
return data;
}
function getMissingTests(className, bBig, testname)
{
var all=getAllMissingTests(className);
var data=[];
for(var i=0;i<all.length; i++)
if(all[i].big==bBig && all[i].exercisename==testname)
data.push({exercisename: all[i].exercisename, pupilname: all[i].pupilname});
return data;
}
function getMissingTestsFromPupilName(className, pupilname)
{
var all=getAllMissingTests(className);
var data=[];
for(var i=0;i<all.length; i++)
if(all[i].pupilname==pupilname)
data.push({exercisename: all[i].exercisename, pupilname: all[i].pupilname, big: all[i].big});
return data;
}
function getAllGrades(className, pupilName)
{
var data = {oral: [], small: [], big: []};
data.gradeRatio = theData[className].gradeRatio;
var oral = theData[className].oral;
for(var i = 0; i < oral.length; i++)
if(oral[i].name == pupilName)
data.oral.push(oral[i]);
var small = theData[className].small;
for(var i = 0; i < small.length; i++)
for(var j = 0; j < small[i].groups.length; j++)
for(var k = 0; k < small[i].groups[j].pupils.length; k++)
if(small[i].groups[j].pupils[k].name == pupilName)
{
var obj = {};
obj.points = small[i].groups[j].pupils[k].points;
obj.sum = small[i].groups[j].pupils[k].sum;
obj.grade = small[i].groups[j].pupils[k].grade;
obj.factor = small[i].factor;
obj.date = small[i].date;
obj.exerciseName = small[i].name;
data.small.push(obj);
}
var big = theData[className].big;
for(var i = 0; i < big.length; i++)
for(var j = 0; j < big[i].groups.length; j++)
for(var k = 0; k < big[i].groups[j].pupils.length; k++)
if(big[i].groups[j].pupils[k].name == pupilName)
{
var obj = {};
obj.points = big[i].groups[j].pupils[k].points;
obj.sum = big[i].groups[j].pupils[k].sum;
obj.grade = big[i].groups[j].pupils[k].grade;
obj.factor = big[i].factor;
obj.date = big[i].date;
obj.exerciseName = big[i].name;
data.big.push(obj);
}
return data;
}
function getDetailedClassInfo(className)
{
return theData[className];
}
function getHomeworkInfo(className, pupilName)
{
var hw = [];
for(var i = 0; i < theData[className].homework.length; i++)
if(theData[className].homework[i].name == pupilName)
hw.push(theData[className].homework[i]);
return hw;
}
function getMissingInfo(className,pupilName)
{
var miss=[];
for(var i = 0; i < theData[className].missing.length; i++)
if(theData[className].missing[i].name == pupilName)
miss.push(theData[className].missing[i]);
return miss;
}
function getFinalScores(className, pupilName)
{
var data = {small: null, big: null, end: null};
var grades = getAllGrades(className, pupilName);
var factor = 0;
var small = 0;
for(var i = 0; i < grades.oral.length; i++)
{
factor += grades.oral[i].factor;
small += grades.oral[i].grade * grades.oral[i].factor;
}
for(var i = 0; i < grades.small.length; i++)
{
if(grades.small[i].grade == "-")
continue;
factor += grades.small[i].factor;
small += grades.small[i].grade * grades.small[i].factor;
}
small /= factor;
var big = 0;
factor = 0;
for(var i = 0; i < grades.big.length; i++)
{
if(grades.big[i].grade == "-")
continue;
factor += grades.big[i].factor;
big += grades.big[i].grade * grades.big[i].factor;
}
big /= factor;
data.small = parseInt(small * 100) / 100;
if(isNaN(big))
{
data.end = data.small;
data.big = big;
}
else
{
data.big = parseInt(big * 100) / 100;
var gradeRatio = grades.gradeRatio.split("_");
var ratioSmall = parseFloat("0" + gradeRatio[1]);
var ratioBig = parseFloat("0" + gradeRatio[0]);
var end = (big * 100 * ratioBig + small * 100 * ratioSmall) / (ratioBig + ratioSmall) / 100;
data.end = parseInt(end * 100) / 100;
}
return data;
}
function evalExercise(className, exerciseName, bigExericse)
{
var data = {};
var dataSorted = {};
for(var i = 0; i < theData[className][bigExericse ? "big" : "small"].length; i++)
if(theData[className][bigExericse ? "big" : "small"][i].name == exerciseName)
data = theData[className][bigExericse ? "big" : "small"][i];
var pupils = getPupils(className);
dataSorted.name = data.name;
dataSorted.date = data.date;
dataSorted.factor = data.factor;
dataSorted.gradingKey = data.gradingKey;
dataSorted.exercises = [data.groups[0].exercises];
dataSorted.bBig=bigExericse;
if(data.groups.length == 2)
dataSorted.exercises.push(data.groups[1].exercises);
var maxpoints = 0;
for(var i = 0; i < data.groups[0].exercises.length; i++)
maxpoints += data.groups[0].exercises[i].points;
dataSorted.maxpoints = maxpoints;
dataSorted.pupils = [];
var averagepoints = [[], [], []]; //grp A, B, total
for(var i = 0; i < pupils.length; i++)
{
var pupilData = getPupilData(data, pupils[i].name);
if(pupilData == null)
continue;
dataSorted.pupils.push(pupilData);
var grpIndex = pupilData.group == "A" ? 0 : 1;
for(var j = 0; j < pupilData.points.length; j++)
if(averagepoints[grpIndex][j] == null)
averagepoints[grpIndex][j] = pupilData.points[j] / data.groups[grpIndex].pupils.length;
else
averagepoints[grpIndex][j] += pupilData.points[j] / data.groups[grpIndex].pupils.length;
if(averagepoints[1].length > 0)
for(var j = 0; j < averagepoints[0].length; j++)
averagepoints[2][j] = (averagepoints[0][j] * data.groups[0].pupils.length + averagepoints[1][j] * data.groups[1].pupils.length) / (data.groups[0].pupils.length + data.groups[1].pupils.length);
}
for(var i = 0; i < (averagepoints[1].length == 0 ? 1 : 3); i++)
for(var j = 0; j < averagepoints[0].length; j++)
if(i < 2)
averagepoints[i][j] = averagepoints[i][j] / data.groups[i].exercises[j].points * 100;
else
averagepoints[2][j] = (averagepoints[0][j] + averagepoints[1][j]) * 0.5;
dataSorted.averagepoints = averagepoints;
var gradeDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
var total = 0;
currentGradingType = getCurrentGradingType(className);
for(var i = 0; i < dataSorted.pupils.length; i++)
{
if(currentGradingType == "Note")
gradeDistribution[dataSorted.pupils[i].grade - 1]++;
else if (currentGradingType == "Punkte")
gradeDistribution[dataSorted.pupils[i].grade]++;
total += dataSorted.pupils[i].grade;
}
dataSorted.gradeDistribution = gradeDistribution;
dataSorted.average = Math.round(total / dataSorted.pupils.length * 1000) / 1000;
return dataSorted;
}
function getAverageGradeFromPunkte(gradeDistribution)
{
var av = 0;
var total = 0;
for(var i = 0; i < 16; i++)
total += gradeDistribution[i];
for(var i = 0; i < 5; i++)
for(var j = 0; j < 3; j++)
av += gradeDistribution[15 - i * 3 - j] * (i + 1);
av += gradeDistribution[0] * 6;
return Math.round(1000 * av / total) / 1000;
}
function getGradeDistributionFromPunkte(gradeDistribution)
{
var gradeDistribution2 = [0, 0, 0, 0, 0, 0];
for(var i = 0; i < 5; i++)
for(var j = 0; j < 3; j++)
gradeDistribution2[i] += gradeDistribution[15 - i * 3 - j];
gradeDistribution2[5] = gradeDistribution[0];
return gradeDistribution2;
}
function getPupilData(exerciseData, pupilName)
{
var indexGroup = 0;
var indexPupil = exerciseData.groups[0].pupils.map(function (d) {
return d.name;
}).indexOf(pupilName);
if(indexPupil == -1 && exerciseData.groups.length > 1)
{
indexGroup = 1;
indexPupil = exerciseData.groups[1].pupils.map(function (d) {
return d.name;
}).indexOf(pupilName);
}
if(indexPupil == -1)
return null;
return {name: exerciseData.groups[indexGroup].pupils[indexPupil].name, points: exerciseData.groups[indexGroup].pupils[indexPupil].points, sum: exerciseData.groups[indexGroup].pupils[indexPupil].sum, grade: exerciseData.groups[indexGroup].pupils[indexPupil].grade, group: (indexGroup == 0 ? "A" : "B"), returned:exerciseData.groups[indexGroup].pupils[indexPupil].returned };
}
function getPupilNote(className, pupilName)
{
for(var i = 0; i < theData[className].notes.length; i++)
if(theData[className].notes[i].name == pupilName)
return theData[className].notes[i].note
return "";
}
function getOralEvaluation(classname,pupilname)
{
pupilname="oral"+pupilname;
var pos=0;
var neu=0;
var neg=0;
var t=getPupilNote(classname,pupilname)
for(var i=0;i<t.length;i++)
{
if(t[i]=="+")
pos++;
else if(t[i]=="o")
neu++;
else if(t[i]=="-")
neg++;
}
var text="+: " + pos + "\no: " + neu + "\n-: " + neg + "\n";
text+=t;
return text;
}
function getPupilFilter(className,pupilName)
{
return getPupilNote(className,("filter_"+pupilName));
}
function getAllFilters(className)
{
var filters=[];
for(var i = 0; i < theData[className].notes.length; i++)
if(theData[className].notes[i].name.substring(0,7)=="filter_")
if(!filters.includes(theData[className].notes[i].note))
filters[filters.length]=theData[className].notes[i].note;
return filters;
}