Skip to content
Snippets Groups Projects
Commit 9fd7b860 authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Add and fix multiple-choice content evaluation function

parent 53979997
Branches
Tags
No related merge requests found
......@@ -99,4 +99,36 @@ export class ListStatisticComponent implements OnInit {
}
return res;
}
evaluateMultiple(options: AnswerOption[], combCounts: Combination[]): number {
let combLength;
if (combCounts) {
combLength = combCounts.length;
} else {
return -1;
}
let correctCounts = 0;
let totalCounts = 0;
const optionsLength = options.length;
let correctIndexes = new Array<number>();
let res: number;
let cic = 0;
for (let i = 0; i < optionsLength; i++) {
if (options[i].points > 0) {
correctIndexes[cic] = i;
cic++;
}
}
for (let i = 0; i < combLength; i++) {
if (combCounts[i].selectedChoiceIndexes.length === correctIndexes.length) {
if (combCounts[i].selectedChoiceIndexes.toString() === correctIndexes.toString()) {
correctCounts += combCounts[i].count;
}
}
totalCounts += combCounts[i].count;
}
res = ((correctCounts / totalCounts) * 100);
this.contentCounter++;
return res;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment