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
913
913
return $ this ->problems ;
914
914
}
915
915
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
+
916
926
public function addClarification (Clarification $ clarification ): Contest
917
927
{
918
928
$ this ->clarifications [] = $ clarification ;
Original file line number Diff line number Diff line change @@ -1093,14 +1093,11 @@ public function problemBadge(ContestProblem $problem): string
1093
1093
);
1094
1094
}
1095
1095
1096
- public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest ): string
1096
+ public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest = null ): string
1097
1097
{
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 );
1104
1101
}
1105
1102
1106
1103
public function printMetadata (?string $ metadata ): string
You can’t perform that action at this time.
0 commit comments