-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCustomGradingResult.java
57 lines (47 loc) · 1.82 KB
/
CustomGradingResult.java
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
package com.github.guillaumederval.javagrading;
import static java.lang.Double.NaN;
/**
* Allow a test to return a custom feedback
*/
public class CustomGradingResult extends Exception {
public final String feedback;
public final TestStatus status;
public final double grade;
public final Exception origException;
/**
* @param status test status
* @param grade the grade. must be NaN to avoid defining a custom grade. Always set to NaN when status == IGNORED
* @param feedback a string describing the feedback, or null
* @param origException original exception, or null
*/
public CustomGradingResult(TestStatus status, double grade, String feedback, Exception origException) {
this.feedback = feedback;
this.status = status;
if(status != TestStatus.IGNORED)
this.grade = grade;
else
this.grade = NaN;
this.origException = origException;
}
public CustomGradingResult(TestStatus status, double grade, String feedback) {
this(status, grade, feedback, null);
}
public CustomGradingResult(TestStatus status, double grade) {
this(status, grade, null, null);
}
public CustomGradingResult(TestStatus status, String feedback) {
this(status, NaN, feedback,null);
}
public CustomGradingResult(TestStatus status, String feedback, Exception origException) {
this(status, NaN, feedback, origException);
}
public CustomGradingResult(TestStatus status, double grade, Exception origException) {
this(status, grade, null, origException);
}
public CustomGradingResult(TestStatus status, Exception origException) {
this(status, NaN, null, origException);
}
public CustomGradingResult(TestStatus status) {
this(status, NaN, null, null);
}
}