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 @@ -915,6 +915,16 @@ public function getProblems(): Collection
915
915
return $ this ->problems ;
916
916
}
917
917
918
+ public function getContestProblem (Problem $ problem ): ?ContestProblem
919
+ {
920
+ foreach ($ this ->getProblems () as $ contestProblem ) {
921
+ if ($ contestProblem ->getProblem () === $ problem ) {
922
+ return $ contestProblem ;
923
+ }
924
+ }
925
+ return null ;
926
+ }
927
+
918
928
public function addClarification (Clarification $ clarification ): Contest
919
929
{
920
930
$ this ->clarifications [] = $ clarification ;
Original file line number Diff line number Diff line change @@ -1084,14 +1084,11 @@ public function problemBadge(ContestProblem $problem): string
1084
1084
);
1085
1085
}
1086
1086
1087
- public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest ): string
1087
+ public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest = null ): string
1088
1088
{
1089
- foreach ($ problem ->getContestProblems () as $ contestProblem ) {
1090
- if ($ contestProblem ->getContest () === $ contest ) {
1091
- return $ this ->problemBadge ($ contestProblem );
1092
- }
1093
- }
1094
- return '' ;
1089
+ $ contest ??= $ this ->dj ->getCurrentContest ();
1090
+ $ contestProblem = $ contest ?->getContestProblem($ problem );
1091
+ return $ contestProblem === null ? '' : $ this ->problemBadge ($ contestProblem );
1095
1092
}
1096
1093
1097
1094
public function printMetadata (?string $ metadata ): string
You can’t perform that action at this time.
0 commit comments