1111use App \Entity \Problem ;
1212use App \Entity \Submission ;
1313use App \Entity \SubmissionFile ;
14+ use App \Entity \SubmissionSource ;
1415use App \Entity \Team ;
1516use App \Entity \User ;
1617use App \Utils \FreezeData ;
@@ -438,7 +439,7 @@ public function submitSolution(
438439 Contest |int $ contest ,
439440 Language |string $ language ,
440441 array $ files ,
441- ? string $ source = null ,
442+ SubmissionSource $ source = SubmissionSource:: UNKNOWN ,
442443 ?string $ juryMember = null ,
443444 Submission |int |null $ originalSubmission = null ,
444445 ?string $ entryPoint = null ,
@@ -569,7 +570,7 @@ public function submitSolution(
569570
570571 if (!empty ($ entryPoint ) && !preg_match (self ::FILENAME_REGEX , $ entryPoint )) {
571572 $ message = sprintf ("Entry point '%s' contains illegal characters. " , $ entryPoint );
572- if ($ forceImportInvalid || $ source === ' shadowing ' ) {
573+ if ($ forceImportInvalid || $ source === SubmissionSource:: SHADOWING ) {
573574 $ importError = $ message ;
574575 } else {
575576 return null ;
@@ -610,15 +611,15 @@ public function submitSolution(
610611 }
611612 if (!preg_match (self ::FILENAME_REGEX , $ file ->getClientOriginalName ())) {
612613 $ message = sprintf ("Illegal filename '%s'. " , $ file ->getClientOriginalName ());
613- if ($ forceImportInvalid || $ source === ' shadowing ' ) {
614+ if ($ forceImportInvalid || $ source === SubmissionSource:: SHADOWING ) {
614615 $ importError = $ message ;
615616 } else {
616617 return null ;
617618 }
618619 }
619620 $ totalSize += $ file ->getSize ();
620621
621- if ($ source !== ' shadowing ' && $ language ->getFilterCompilerFiles ()) {
622+ if ($ source !== SubmissionSource:: SHADOWING && $ language ->getFilterCompilerFiles ()) {
622623 $ matchesExtension = false ;
623624 foreach ($ language ->getExtensions () as $ extension ) {
624625 if (str_ends_with ($ file ->getClientOriginalName (), '. ' . $ extension )) {
@@ -632,7 +633,7 @@ public function submitSolution(
632633 }
633634 }
634635
635- if ($ source !== ' shadowing ' && $ language ->getFilterCompilerFiles () && $ extensionMatchCount === 0 ) {
636+ if ($ source !== SubmissionSource:: SHADOWING && $ language ->getFilterCompilerFiles () && $ extensionMatchCount === 0 ) {
636637 $ message = sprintf (
637638 "None of the submitted files match any of the allowed " .
638639 "extensions for %s (allowed: %s) " ,
@@ -647,7 +648,7 @@ public function submitSolution(
647648
648649 if ($ totalSize > $ sourceSize * 1024 ) {
649650 $ message = sprintf ("Submission file(s) are larger than %d kB. " , $ sourceSize );
650- if ($ forceImportInvalid || $ source === ' shadowing ' ) {
651+ if ($ forceImportInvalid || $ source === SubmissionSource:: SHADOWING ) {
651652 $ importError = $ message ;
652653 } else {
653654 return null ;
@@ -660,7 +661,7 @@ public function submitSolution(
660661 // SQL transaction time below.
661662 // Only do this for problem import submissions, as we do not want this for re-submitted submissions nor
662663 // submissions that come through the API, e.g. when doing a replay of an old contest.
663- if ($ this ->dj ->checkrole ('jury ' ) && $ source == ' problem import ' ) {
664+ if ($ this ->dj ->checkrole ('jury ' ) && $ source === SubmissionSource:: PROBLEM_IMPORT ) {
664665 $ results = null ;
665666 foreach ($ files as $ file ) {
666667 $ fileResult = self ::getExpectedResults (file_get_contents ($ file ->getRealPath ()),
@@ -726,7 +727,7 @@ public function submitSolution(
726727 $ this ->em ->flush ();
727728
728729 $ this ->dj ->maybeCreateJudgeTasks ($ judging ,
729- $ source === ' problem import ' ? JudgeTask::PRIORITY_LOW : JudgeTask::PRIORITY_DEFAULT );
730+ $ source === SubmissionSource:: PROBLEM_IMPORT ? JudgeTask::PRIORITY_LOW : JudgeTask::PRIORITY_DEFAULT );
730731 }
731732
732733 $ this ->em ->wrapInTransaction (function () use ($ contest , $ submission ) {
@@ -755,7 +756,7 @@ public function submitSolution(
755756 $ language ->getLangid (), $ problem ->getProblem ()->getProbid ()));
756757
757758 $ this ->dj ->auditlog ('submission ' , $ submission ->getSubmitid (), 'added ' ,
758- 'via ' . ( $ source ?? ' unknown ' ) , null , $ contest ->getCid ());
759+ 'via ' . $ source-> value , null , $ contest ->getCid ());
759760
760761 if (Utils::difftime ((float )$ contest ->getEndtime (), $ submitTime ) <= 0 ) {
761762 $ this ->logger ->info (
0 commit comments