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 @@ -862,6 +862,16 @@ public function getProblems(): Collection
862862 return $ this ->problems ;
863863 }
864864
865+ public function getContestProblem (Problem $ problem ): ?ContestProblem
866+ {
867+ foreach ($ this ->getProblems () as $ contestProblem ) {
868+ if ($ contestProblem ->getProblem () === $ problem ) {
869+ return $ contestProblem ;
870+ }
871+ }
872+ return null ;
873+ }
874+
865875 public function addClarification (Clarification $ clarification ): Contest
866876 {
867877 $ this ->clarifications [] = $ clarification ;
Original file line number Diff line number Diff line change @@ -1108,14 +1108,11 @@ public function problemBadge(ContestProblem $problem): string
11081108 );
11091109 }
11101110
1111- public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest ): string
1111+ public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest = null ): string
11121112 {
1113- foreach ($ problem ->getContestProblems () as $ contestProblem ) {
1114- if ($ contestProblem ->getContest () === $ contest ) {
1115- return $ this ->problemBadge ($ contestProblem );
1116- }
1117- }
1118- return '' ;
1113+ $ contest ??= $ this ->dj ->getCurrentContest ();
1114+ $ contestProblem = $ contest ?->getContestProblem($ problem );
1115+ return $ contestProblem === null ? '' : $ this ->problemBadge ($ contestProblem );
11191116 }
11201117
11211118 public function printMetadata (?string $ metadata ): string
You can’t perform that action at this time.
0 commit comments