From cf872d0275f72303e8fed9cb9c669df371b35a9b Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Wed, 14 Aug 2024 21:14:28 +0700 Subject: [PATCH] grader: Show percentage instead of points when appropriate (#645) --- .../main/java/judgels/gabriel/aggregators/MinAggregator.java | 5 +++-- .../java/judgels/gabriel/aggregators/MinAggregatorTests.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/aggregators/MinAggregator.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/aggregators/MinAggregator.java index 058db701c..7a1e65ba7 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/aggregators/MinAggregator.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/aggregators/MinAggregator.java @@ -21,16 +21,17 @@ public AggregationResult aggregate(List testCaseVerdicts, doubl aggregatedVerdict = verdict; } - String points; + String points = ""; if (verdict == Verdict.OK) { double okPoints = 0.0; if (testCaseVerdict.getPercentage().isPresent()) { okPoints = testCaseVerdict.getPercentage().get() * subtaskPoints / 100.0; + points = testCaseVerdict.getPercentage().get() + "%"; } else if (testCaseVerdict.getPoints().isPresent()) { okPoints = testCaseVerdict.getPoints().get(); + points = "" + okPoints; } aggregatedPoints = Math.min(aggregatedPoints, okPoints); - points = "" + okPoints; } else if (verdict == Verdict.ACCEPTED) { points = "*"; } else if (verdict == Verdict.SKIPPED) { diff --git a/judgels-backends/judgels-grader-engines/src/test/java/judgels/gabriel/aggregators/MinAggregatorTests.java b/judgels-backends/judgels-grader-engines/src/test/java/judgels/gabriel/aggregators/MinAggregatorTests.java index 3d63533d6..9d65c333a 100644 --- a/judgels-backends/judgels-grader-engines/src/test/java/judgels/gabriel/aggregators/MinAggregatorTests.java +++ b/judgels-backends/judgels-grader-engines/src/test/java/judgels/gabriel/aggregators/MinAggregatorTests.java @@ -87,7 +87,7 @@ void aggregate_min_ok_percentage() { AggregationResult result = aggregator.aggregate(testCaseVerdicts, 70.0); assertThat(result.getSubtaskVerdict()).isEqualTo(SubtaskVerdict.of(Verdict.OK, 17.5)); - assertThat(result.getTestCasePoints()).containsExactly("*", "17.5", "35.0"); + assertThat(result.getTestCasePoints()).containsExactly("*", "25%", "50%"); } @Test