-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestion.pde
55 lines (47 loc) · 1.36 KB
/
Question.pde
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
class Question {
String questionTitle;
StringList answers;
IntList solutions;
Question(String questionTitle, StringList answers, IntList solutions) {
this.questionTitle = questionTitle;
this.answers = answers;
this.solutions = solutions;
}
ValidationResult validate(IntList selected) {
ValidationResult result = new ValidationResult();
for (int i = 0; i < answers.size(); i++) {
if (selected.hasValue(i)) {
if (solutions.hasValue(i)) {
// Selected and is solution
result.amountCorrect++;
result.answersSelectedCorrectly.append(i);
}
else {
// Selected but is not a solution
result.amountFalse++;
result.answersSelectedFalsely.append(i);
}
}
else if (solutions.hasValue(i)) {
// Not selected but is a solution
result.amountFalse++;
result.answersNotSelectedFalsely.append(i);
}
}
return result;
}
}
class ValidationResult {
int amountCorrect;
int amountFalse;
IntList answersSelectedCorrectly;
IntList answersSelectedFalsely;
IntList answersNotSelectedFalsely;
ValidationResult() {
this.amountCorrect = 0;
this.amountFalse = 0;
this.answersSelectedCorrectly = new IntList();
this.answersSelectedFalsely = new IntList();
this.answersNotSelectedFalsely = new IntList();
}
}