Skip to content

Commit

Permalink
Allow scorer to output percentage of tc points (without subtasks)
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Sep 7, 2024
1 parent 5cd6dfb commit 55caad9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions include/tcframe/runner/aggregator/SumAggregator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@ class SumAggregator : public TestCaseAggregator {
return {Verdict::ac(), subtaskPoints};
}

double testCaseFullPoints = subtaskPoints / testCaseVerdicts.size();

Verdict aggregatedVerdict = Verdict::ac();
double aggregatedPoints = 0;
for (const TestCaseVerdict& testCaseVerdict : testCaseVerdicts) {
aggregatedVerdict = max(aggregatedVerdict, testCaseVerdict.verdict());

if (testCaseVerdict.verdict() == Verdict::ac()) {
aggregatedPoints += subtaskPoints / testCaseVerdicts.size();
aggregatedPoints += testCaseFullPoints;
} else if (testCaseVerdict.verdict() == Verdict::ok()) {
aggregatedPoints += testCaseVerdict.points().value();
if (testCaseVerdict.points()) {
aggregatedPoints += testCaseVerdict.points().value();
} else if (testCaseVerdict.percentage()) {
aggregatedPoints += testCaseVerdict.percentage().value() * testCaseFullPoints / 100.0;
}
}
}
return {aggregatedVerdict, aggregatedPoints};
Expand Down
5 changes: 3 additions & 2 deletions test/unit/tcframe/runner/aggregator/SumAggregatorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ TEST_F(SumAggregatorTests, Aggregate_PartialPoints) {
vector<TestCaseVerdict> verdicts = {
TestCaseVerdict(Verdict::ac()),
TestCaseVerdict(Verdict::tle()),
TestCaseVerdict(Verdict::ok(), 30),
TestCaseVerdict(Verdict::ok(), 15),
TestCaseVerdict(Verdict::ok(), optional<double>(), optional<double>(50.0)),
TestCaseVerdict(Verdict::wa())};
EXPECT_THAT(aggregator.aggregate(verdicts, 100), Eq(SubtaskVerdict(Verdict::tle(), 55)));
EXPECT_THAT(aggregator.aggregate(verdicts, 100), Eq(SubtaskVerdict(Verdict::tle(), 47.5)));
}

TEST_F(SumAggregatorTests, Aggregate_EmptyVerdicts) {
Expand Down

0 comments on commit 55caad9

Please sign in to comment.