File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -913,6 +913,16 @@ public function getProblems(): Collection
913913 return $ this ->problems ;
914914 }
915915
916+ public function getContestProblem (Problem $ problem ): ?ContestProblem
917+ {
918+ foreach ($ this ->getProblems () as $ contestProblem ) {
919+ if ($ contestProblem ->getProblem () === $ problem ) {
920+ return $ contestProblem ;
921+ }
922+ }
923+ return null ;
924+ }
925+
916926 public function addClarification (Clarification $ clarification ): Contest
917927 {
918928 $ this ->clarifications [] = $ clarification ;
Original file line number Diff line number Diff line change @@ -1093,14 +1093,11 @@ public function problemBadge(ContestProblem $problem): string
10931093 );
10941094 }
10951095
1096- public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest ): string
1096+ public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest = null ): string
10971097 {
1098- foreach ($ problem ->getContestProblems () as $ contestProblem ) {
1099- if ($ contestProblem ->getContest () === $ contest ) {
1100- return $ this ->problemBadge ($ contestProblem );
1101- }
1102- }
1103- return '' ;
1098+ $ contest ??= $ this ->dj ->getCurrentContest ();
1099+ $ contestProblem = $ contest ?->getContestProblem($ problem );
1100+ return $ contestProblem === null ? '' : $ this ->problemBadge ($ contestProblem );
11041101 }
11051102
11061103 public function printMetadata (?string $ metadata ): string
You can’t perform that action at this time.
0 commit comments