From c163db71f8b71b07735b0cb7eb0077cc55701ab6 Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Mon, 27 May 2024 22:02:42 +0700 Subject: [PATCH] grading: update submission grading engine when regraded --- .../submission/programming/BaseSubmissionStore.java | 10 ++++++++++ .../submission/programming/SubmissionClient.java | 4 +++- .../submission/programming/SubmissionStore.java | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/BaseSubmissionStore.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/BaseSubmissionStore.java index faa8e05b1..d8b2a7766 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/BaseSubmissionStore.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/BaseSubmissionStore.java @@ -225,6 +225,16 @@ public Submission createSubmission(SubmissionData data, ProblemSubmissionConfig return submissionFromModels(submissionDao.insert(model), null); } + @Override + public void updateSubmissionGradingEngine(String submissionJid, String gradingEngine) { + Optional maybeModel = submissionDao.selectByJid(submissionJid); + if (maybeModel.isPresent()) { + SM model = maybeModel.get(); + model.gradingEngine = gradingEngine; + submissionDao.update(model); + } + } + @Override public String createGrading(Submission submission) { GM model = gradingDao.createGradingModel(); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionClient.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionClient.java index ce1721af6..1c4d0e974 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionClient.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionClient.java @@ -66,7 +66,9 @@ public void regrade(String gradingJid, Submission submission, SubmissionSource s public void regrade(String gradingJid, Submission submission, SubmissionSource source, ProblemSubmissionConfig config, GradingOptions options) { if (config.getGradingLastUpdateTime().isAfter(submission.getTime())) { - // TODO(fushar): update submission's grading engine + if (!submission.getGradingEngine().equals(config.getGradingEngine())) { + submissionStore.updateSubmissionGradingEngine(submission.getJid(), config.getGradingEngine()); + } } requestGrading(gradingJid, submission, source, config, options); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionStore.java b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionStore.java index 005dccba0..43be262d8 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionStore.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/sandalphon/submission/programming/SubmissionStore.java @@ -42,6 +42,7 @@ Optional getLatestSubmission( Map getTotalSubmissionsMap(String containerJid, String userJid, Collection problemJids); Submission createSubmission(SubmissionData data, ProblemSubmissionConfig config); + void updateSubmissionGradingEngine(String submissionJid, String gradingEngine); String createGrading(Submission submission); Optional updateGrading(String gradingJid, GradingResult result); }