Skip to content

Commit

Permalink
grader: allow percentage scoring for non-subtask problems as well
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Aug 24, 2024
1 parent 8164e50 commit f058c44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public AggregationResult aggregate(List<TestCaseVerdict> testCaseVerdicts, doubl
if (verdict == Verdict.ACCEPTED) {
points = testCaseFullPoints;
} else if (verdict == Verdict.OK) {
points = testCaseVerdict.getPoints().orElse(0.0);
if (testCaseVerdict.getPoints().isPresent()) {
points = testCaseVerdict.getPoints().get();
} else if (testCaseVerdict.getPercentage().isPresent()) {
points = testCaseVerdict.getPercentage().get() * testCaseFullPoints / 100.0;
}
}
aggregatedPoints += points;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ void aggregate_partial_points() {
assertThat(result.getTestCasePoints()).containsExactly("25", "0", "30", "0");
}

@Test
void aggregate_partial_percentage() {
List<TestCaseVerdict> testCaseVerdicts = ImmutableList.of(
new TestCaseVerdict.Builder().verdict(Verdict.ACCEPTED).build(),
new TestCaseVerdict.Builder().verdict(Verdict.TIME_LIMIT_EXCEEDED).build(),
new TestCaseVerdict.Builder().verdict(Verdict.OK).percentage(50.0).build(),
new TestCaseVerdict.Builder().verdict(Verdict.WRONG_ANSWER).build());

AggregationResult result = aggregator.aggregate(testCaseVerdicts, 100.0);
assertThat(result.getSubtaskVerdict()).isEqualTo(SubtaskVerdict.of(Verdict.TIME_LIMIT_EXCEEDED, 37.5));
assertThat(result.getTestCasePoints()).containsExactly("25", "0", "12.5", "0");
}

@Test
void aggregate_partial_points_with_skipped() {
List<TestCaseVerdict> testCaseVerdicts = ImmutableList.of(
Expand Down

0 comments on commit f058c44

Please sign in to comment.