Skip to content

Commit fc3e341

Browse files
elderingvmcj
authored andcommitted
Disallow submitting to a problem when it does not have testcases at import.
Closes #1777 (cherry picked from commit ecb2204)
1 parent 934a591 commit fc3e341

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

webapp/src/Service/ImportProblemService.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,20 @@ public function importZippedProblem(
818818

819819
$messages['info'][] = sprintf('Saved problem %d', $problem->getProbid());
820820

821+
// Only here disable problem submit to make sure the jury submissions
822+
// do get added above.
823+
if ($contestProblem) {
824+
$this->em->flush();
825+
$testcases = $problem->getTestcases()->toArray();
826+
if (count(array_filter($testcases, function($t) { return !$t->getDeleted(); }))==0) {
827+
$messages['danger'][] = 'No testcases present, disabling submitting for this problem';
828+
$contestProblem->setAllowSubmit(false);
829+
}
830+
}
831+
832+
// Make sure we persisted all changes to DB
833+
$this->em->flush();
834+
821835
return $problem;
822836
}
823837

0 commit comments

Comments
 (0)