From c1c9d372573a56e48e9dad3c7d322f7aecb727d1 Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Sat, 17 Aug 2024 18:11:47 +0700 Subject: [PATCH] grader: allow floor rounding mode more properly --- .../judgels/gabriel/api/GradingConfig.java | 9 +++++++++ .../judgels/gabriel/api/ScoringConfig.java | 20 +++++++++++++++++++ .../gabriel/api/ScoringRoundingMode.java | 6 ++++++ .../engines/BlackboxGradingEngine.java | 10 +++++++++- .../programming/ProblemSubmissionConfig.java | 2 -- .../judgels/sandalphon/SandalphonClient.java | 9 +++++++++ .../programming/ProgrammingProblemStore.java | 5 +++++ .../scoreboard/ContestScoreboardUpdater.java | 9 ++++++++- .../scoreboard/ScoreboardProcessor.java | 2 ++ .../bundle/BundleScoreboardProcessor.java | 2 ++ .../gcj/GcjScoreboardProcessor.java | 2 ++ .../icpc/IcpcScoreboardProcessor.java | 2 ++ .../ioi/IoiScoreboardProcessor.java | 10 +++++++++- .../troc/TrocScoreboardProcessor.java | 2 ++ .../BundleScoreboardProcessorTests.java | 8 ++++++++ .../gcj/GcjScoreboardProcessorTests.java | 19 ++++++++++++++++++ .../icpc/IcpcScoreboardProcessorTests.java | 19 ++++++++++++++++++ .../ioi/IoiScoreboardProcessorTests.java | 16 +++++++++++++++ .../troc/TrocScoreboardProcessorTests.java | 19 ++++++++++++++++++ 19 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringConfig.java create mode 100644 judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringRoundingMode.java diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/GradingConfig.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/GradingConfig.java index 24cdae52c..69aafdf98 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/GradingConfig.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/GradingConfig.java @@ -1,7 +1,10 @@ package judgels.gabriel.api; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; import java.util.List; import java.util.Map; +import org.immutables.value.Value; public interface GradingConfig { Map getSourceFileFields(); @@ -9,4 +12,10 @@ public interface GradingConfig { int getMemoryLimit(); List getTestData(); List getSubtasks(); + + @Value.Default + @JsonInclude(Include.NON_DEFAULT) + default ScoringConfig getScoringConfig() { + return ScoringConfig.DEFAULT; + } } diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringConfig.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringConfig.java new file mode 100644 index 000000000..b0e6ee75b --- /dev/null +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringConfig.java @@ -0,0 +1,20 @@ +package judgels.gabriel.api; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +@Value.Immutable +@JsonDeserialize(as = ImmutableScoringConfig.class) +public interface ScoringConfig { + ScoringConfig DEFAULT = new Builder().build(); + + @Value.Default + @JsonInclude(Include.NON_DEFAULT) + default ScoringRoundingMode getRoundingMode() { + return ScoringRoundingMode.ROUND; + } + + class Builder extends ImmutableScoringConfig.Builder {} +} diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringRoundingMode.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringRoundingMode.java new file mode 100644 index 000000000..166b49591 --- /dev/null +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/api/ScoringRoundingMode.java @@ -0,0 +1,6 @@ +package judgels.gabriel.api; + +public enum ScoringRoundingMode { + ROUND, + FLOOR, +} diff --git a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java index 2eb896811..45a84dd8b 100644 --- a/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java +++ b/judgels-backends/judgels-grader-engines/src/main/java/judgels/gabriel/engines/BlackboxGradingEngine.java @@ -29,6 +29,7 @@ import judgels.gabriel.api.GradingSource; import judgels.gabriel.api.PreparationException; import judgels.gabriel.api.SandboxFactory; +import judgels.gabriel.api.ScoringRoundingMode; import judgels.gabriel.api.Subtask; import judgels.gabriel.api.SubtaskResult; import judgels.gabriel.api.SubtaskVerdict; @@ -333,9 +334,16 @@ private GradingResult buildResult() throws GradingException { throw new GradingException(e); } + int score; + if (config.getScoringConfig().getRoundingMode() == ScoringRoundingMode.ROUND) { + score = (int) Math.round(gradingVerdict.getPoints()); + } else { + score = (int) Math.floor(gradingVerdict.getPoints()); + } + return new GradingResult.Builder() .verdict(gradingVerdict.getVerdict()) - .score((int) Math.floor(gradingVerdict.getPoints())) + .score(score) .details(detailsString) .build(); } diff --git a/judgels-backends/judgels-server-api/src/main/java/judgels/sandalphon/api/problem/programming/ProblemSubmissionConfig.java b/judgels-backends/judgels-server-api/src/main/java/judgels/sandalphon/api/problem/programming/ProblemSubmissionConfig.java index 61620af7a..e1d53e921 100644 --- a/judgels-backends/judgels-server-api/src/main/java/judgels/sandalphon/api/problem/programming/ProblemSubmissionConfig.java +++ b/judgels-backends/judgels-server-api/src/main/java/judgels/sandalphon/api/problem/programming/ProblemSubmissionConfig.java @@ -1,13 +1,11 @@ package judgels.sandalphon.api.problem.programming; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.time.Instant; import java.util.Map; import judgels.gabriel.api.LanguageRestriction; import org.immutables.value.Value; @Value.Immutable -@JsonDeserialize(as = ImmutableProblemSubmissionConfig.class) public interface ProblemSubmissionConfig { Map getSourceKeys(); String getGradingEngine(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java index fcd12ed7b..7982b8120 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/SandalphonClient.java @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.UriInfo; import judgels.gabriel.api.GradingConfig; +import judgels.gabriel.api.ScoringConfig; import judgels.sandalphon.api.lesson.Lesson; import judgels.sandalphon.api.lesson.LessonInfo; import judgels.sandalphon.api.lesson.LessonStatement; @@ -155,6 +156,14 @@ public Map getProgrammingProblemSubmissionConfi return Set.copyOf(problemJids).stream().collect(toMap(jid -> jid, this::getProgrammingProblemSubmissionConfig)); } + public ScoringConfig getProgrammingProblemScoringConfig(String problemJid) { + return programmingProblemStore.getProgrammingProblemScoringConfig(problemJid); + } + + public Map getProgrammingProblemScoringConfigs(Collection problemJids) { + return Set.copyOf(problemJids).stream().collect(toMap(jid -> jid, this::getProgrammingProblemScoringConfig)); + } + public judgels.sandalphon.api.problem.programming.ProblemWorksheet getProgrammingProblemWorksheet( HttpServletRequest req, UriInfo uriInfo, diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/programming/ProgrammingProblemStore.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/programming/ProgrammingProblemStore.java index d2b42fb99..8edf702eb 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/programming/ProgrammingProblemStore.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/problem/programming/ProgrammingProblemStore.java @@ -11,6 +11,7 @@ import judgels.fs.FileSystem; import judgels.gabriel.api.GradingConfig; import judgels.gabriel.api.LanguageRestriction; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.engines.GradingEngineRegistry; import judgels.sandalphon.api.problem.programming.ProblemSubmissionConfig; import judgels.sandalphon.problem.base.BaseProblemStore; @@ -137,6 +138,10 @@ public ProblemSubmissionConfig getProgrammingProblemSubmissionConfig(String prob .build(); } + public ScoringConfig getProgrammingProblemScoringConfig(String problemJid) { + return getGradingConfig(null, problemJid).getScoringConfig(); + } + private void updateGradingLastUpdateTime(String userJid, String problemJid) { problemFs.writeToFile(getGradingLastUpdateTimeFilePath(userJid, problemJid), "" + System.currentTimeMillis()); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java index e3a7754a5..44e1229b8 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java @@ -17,8 +17,10 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.gabriel.api.ScoringConfig; import judgels.jophiel.JophielClient; import judgels.jophiel.api.profile.Profile; +import judgels.sandalphon.SandalphonClient; import judgels.sandalphon.api.submission.bundle.ItemSubmission; import judgels.sandalphon.api.submission.programming.Submission; import judgels.sandalphon.submission.bundle.ItemSubmissionStore; @@ -53,6 +55,7 @@ public class ContestScoreboardUpdater { private final ScoreboardProcessorRegistry scoreboardProcessorRegistry; private final ContestScoreboardPusher scoreboardPusher; private final JophielClient jophielClient; + private final SandalphonClient sandalphonClient; public ContestScoreboardUpdater( ObjectMapper objectMapper, @@ -67,7 +70,8 @@ public ContestScoreboardUpdater( ScoreboardIncrementalMarker scoreboardIncrementalMarker, ScoreboardProcessorRegistry scoreboardProcessorRegistry, ContestScoreboardPusher scoreboardPusher, - JophielClient jophielClient) { + JophielClient jophielClient, + SandalphonClient sandalphonClient) { this.objectMapper = objectMapper; this.contestTimer = contestTimer; @@ -82,6 +86,7 @@ public ContestScoreboardUpdater( this.scoreboardProcessorRegistry = scoreboardProcessorRegistry; this.scoreboardPusher = scoreboardPusher; this.jophielClient = jophielClient; + this.sandalphonClient = sandalphonClient; } @UnitOfWork @@ -119,6 +124,7 @@ public void update(Contest contest) { Set contestants = ImmutableSet.copyOf(contestantsMap.values()); Set contestantJidsSet = contestants.stream().map(ContestContestant::getUserJid).collect(toSet()); Map profilesMap = jophielClient.getProfiles(contestantJidsSet, contest.getBeginTime()); + Map scoringConfigsMap = sandalphonClient.getProgrammingProblemScoringConfigs(problemJidsSet); ScoreboardState state = new ScoreboardState.Builder() .problemJids(problemJids) @@ -201,6 +207,7 @@ public void update(Contest contest) { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, programmingSubmissions, bundleItemSubmissions, freezeTimesMap); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java index fb87e4b3e..c74fdb3be 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.gabriel.api.ScoringConfig; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.bundle.ItemSubmission; import judgels.sandalphon.api.submission.programming.Submission; @@ -29,6 +30,7 @@ ScoreboardProcessResult process( StyleModuleConfig styleModuleConfig, Set contestants, Map profilesMap, + Map scoringConfigsMap, List programmingSubmissions, List bundleItemSubmissions, Map freezeTimesMap); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java index f1885806c..76d04a656 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java @@ -13,6 +13,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import judgels.gabriel.api.ScoringConfig; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.bundle.ItemSubmission; import judgels.sandalphon.api.submission.programming.Submission; @@ -61,6 +62,7 @@ public ScoreboardProcessResult process( StyleModuleConfig styleModuleConfig, Set contestants, Map profilesMap, + Map scoringConfigsMap, List programmingSubmissions, List bundleItemSubmissions, Map freezeTimesMap) { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java index a79b5dafb..aa77909ba 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.jophiel.api.user.rating.UserRating; @@ -70,6 +71,7 @@ public ScoreboardProcessResult process( StyleModuleConfig styleModuleConfig, Set contestants, Map profilesMap, + Map scoringConfigsMap, List programmingSubmissions, List bundleItemSubmissions, Map freezeTimesMap) { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java index ac4ede8bf..6199b6862 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.jophiel.api.user.rating.UserRating; @@ -70,6 +71,7 @@ public ScoreboardProcessResult process( StyleModuleConfig styleModuleConfig, Set contestants, Map profilesMap, + Map scoringConfigsMap, List programmingSubmissions, List bundleItemSubmissions, Map freezeTimesMap) { diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java index c94624690..158929e8c 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java @@ -18,6 +18,8 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import judgels.gabriel.api.ScoringConfig; +import judgels.gabriel.api.ScoringRoundingMode; import judgels.gabriel.api.SubtaskResult; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; @@ -72,6 +74,7 @@ public ScoreboardProcessResult process( StyleModuleConfig styleModuleConfig, Set contestants, Map profilesMap, + Map scoringConfigsMap, List programmingSubmissions, List bundleItemSubmissions, Map freezeTimesMap) { @@ -153,7 +156,12 @@ public ScoreboardProcessResult process( } maxScorePerSubtaskMap.put(problemJid, newMaxScorePerSubtask); - score = (int) Math.round(newScore); + + if (scoringConfigsMap.get(problemJid).getRoundingMode() == ScoringRoundingMode.ROUND) { + score = (int) Math.round(newScore); + } else { + score = (int) Math.floor(newScore); + } } else { score = grading.getScore(); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java index cbad51454..d36685bb2 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.jophiel.api.user.rating.UserRating; @@ -70,6 +71,7 @@ public ScoreboardProcessResult process( StyleModuleConfig styleModuleConfig, Set contestants, Map profilesMap, + Map scoringConfigsMap, List programmingSubmissions, List bundleItemSubmissions, Map freezeTimesMap) { diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java index cb06bc791..a3f2ea4f0 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.gabriel.api.ScoringConfig; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.bundle.Grading; import judgels.sandalphon.api.submission.bundle.ItemSubmission; @@ -57,6 +58,10 @@ class Process { "c1", new Profile.Builder().username("c1").build(), "c2", new Profile.Builder().username("c2").build()); + private Map scoringConfigsMap = Map.of( + "p1", ScoringConfig.DEFAULT, + "p2", ScoringConfig.DEFAULT); + @Test void latest_answered_time_calculation() { List submissions = ImmutableList.of( @@ -121,6 +126,7 @@ void latest_answered_time_calculation() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), submissions, Map.of()); @@ -196,6 +202,7 @@ void total_answered_items_over_last_answered_time() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), submissions, Map.of()); @@ -255,6 +262,7 @@ void last_answered_time_as_tiebreaker() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), submissions, Map.of()); diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java index 7a5c450a3..92e9aa294 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.programming.Submission; @@ -61,6 +62,10 @@ class Process { "c1", new Profile.Builder().username("c1").build(), "c2", new Profile.Builder().username("c2").build()); + private Map scoringConfigsMap = Map.of( + "p1", ScoringConfig.DEFAULT, + "p2", ScoringConfig.DEFAULT); + @Test void time_calculation() { List submissions = ImmutableList.of( @@ -77,6 +82,7 @@ void time_calculation() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -127,6 +133,7 @@ void base_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -177,6 +184,7 @@ void reversed_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -228,6 +236,7 @@ void points_over_penalty() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -276,6 +285,7 @@ void penalty_as_tiebreaker() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -337,6 +347,7 @@ void same_rank_if_equal() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -410,6 +421,7 @@ void zero_points_ordering() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -478,6 +490,7 @@ void no_pending() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, baseSubmissions, ImmutableList.of(), freezeTimesMap); @@ -527,6 +540,7 @@ void pending_does_not_overwrite_accepted() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -576,6 +590,7 @@ void pending_does_overwrite_not_accepted() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -625,6 +640,7 @@ void pending_counts_on_freeze_time() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -705,6 +721,7 @@ void empty_initial_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -733,6 +750,7 @@ void empty_new_submissions() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), ImmutableList.of(), Map.of()); @@ -752,6 +770,7 @@ void existing_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java index 4949d1566..15e046265 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.programming.Submission; @@ -60,6 +61,10 @@ class Process { "c1", new Profile.Builder().username("c1").build(), "c2", new Profile.Builder().username("c2").build()); + private Map scoringConfigsMap = Map.of( + "p1", ScoringConfig.DEFAULT, + "p2", ScoringConfig.DEFAULT); + @Test void time_calculation() { List submissions = ImmutableList.of( @@ -78,6 +83,7 @@ void time_calculation() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -130,6 +136,7 @@ void base_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -181,6 +188,7 @@ void reversed_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -235,6 +243,7 @@ void solve_over_penalty() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -285,6 +294,7 @@ void penalty_as_tiebreaker() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -349,6 +359,7 @@ void same_rank_if_equal() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -425,6 +436,7 @@ void zero_points_ordering() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -496,6 +508,7 @@ void no_pending() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, baseSubmissions, ImmutableList.of(), freezeTimesMap); @@ -547,6 +560,7 @@ void pending_does_not_overwrite_accepted() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -598,6 +612,7 @@ void pending_does_overwrite_not_accepted() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -649,6 +664,7 @@ void pending_counts_on_freeze_time() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -734,6 +750,7 @@ void empty_initial_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -766,6 +783,7 @@ void empty_new_submissions() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), ImmutableList.of(), Map.of()); @@ -785,6 +803,7 @@ void existing_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java index 493e28530..5ba103ec3 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java @@ -15,6 +15,7 @@ import java.util.Optional; import java.util.Set; import judgels.gabriel.api.LanguageRestriction; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.programming.Submission; @@ -62,6 +63,10 @@ class Process { "c1", new Profile.Builder().username("c1").build(), "c2", new Profile.Builder().username("c2").build()); + private Map scoringConfigsMap = Map.of( + "p1", ScoringConfig.DEFAULT, + "p2", ScoringConfig.DEFAULT); + @Test void time_calculation() { List submissions = ImmutableList.of( @@ -76,6 +81,7 @@ void time_calculation() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -121,6 +127,7 @@ void frozen() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of(contest.getJid(), Instant.ofEpochMilli(23))); @@ -186,6 +193,7 @@ void empty_initial_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -240,6 +248,7 @@ void existing_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -301,6 +310,7 @@ void base_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -346,6 +356,7 @@ void reversed_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -395,6 +406,7 @@ void sorted_without_last_affecting_penalty() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -437,6 +449,7 @@ void sorted_with_last_affecting_penalty() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -507,6 +520,7 @@ void empty_initial_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -535,6 +549,7 @@ void empty_new_submissions() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), ImmutableList.of(), Map.of()); @@ -554,6 +569,7 @@ void existing_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java index eb12ec9a9..65ba58802 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; +import judgels.gabriel.api.ScoringConfig; import judgels.gabriel.api.Verdict; import judgels.jophiel.api.profile.Profile; import judgels.sandalphon.api.submission.programming.Submission; @@ -61,6 +62,10 @@ class Process { "c1", new Profile.Builder().username("c1").build(), "c2", new Profile.Builder().username("c2").build()); + private Map scoringConfigsMap = Map.of( + "p1", ScoringConfig.DEFAULT, + "p2", ScoringConfig.DEFAULT); + @Test void time_calculation() { List submissions = ImmutableList.of( @@ -81,6 +86,7 @@ void time_calculation() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -131,6 +137,7 @@ void base_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -181,6 +188,7 @@ void reversed_case() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -232,6 +240,7 @@ void points_over_penalty() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -280,6 +289,7 @@ void penalty_as_tiebreaker() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -341,6 +351,7 @@ void same_rank_if_equal() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -414,6 +425,7 @@ void zero_points_ordering() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -482,6 +494,7 @@ void no_pending() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, baseSubmissions, ImmutableList.of(), freezeTimesMap); @@ -531,6 +544,7 @@ void pending_does_not_overwrite_accepted() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -580,6 +594,7 @@ void pending_does_overwrite_not_accepted() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -629,6 +644,7 @@ void pending_counts_on_freeze_time() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), freezeTimesMap); @@ -710,6 +726,7 @@ void empty_initial_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of()); @@ -740,6 +757,7 @@ void empty_new_submissions() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, ImmutableList.of(), ImmutableList.of(), Map.of()); @@ -759,6 +777,7 @@ void existing_incremental_content() { styleModuleConfig, contestants, profilesMap, + scoringConfigsMap, submissions, ImmutableList.of(), Map.of());