File tree 2 files changed +14
-7
lines changed
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
862
862
return $ this ->problems ;
863
863
}
864
864
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
+
865
875
public function addClarification (Clarification $ clarification ): Contest
866
876
{
867
877
$ this ->clarifications [] = $ clarification ;
Original file line number Diff line number Diff line change @@ -1108,14 +1108,11 @@ public function problemBadge(ContestProblem $problem): string
1108
1108
);
1109
1109
}
1110
1110
1111
- public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest ): string
1111
+ public function problemBadgeForProblemAndContest (Problem $ problem , ?Contest $ contest = null ): string
1112
1112
{
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 );
1119
1116
}
1120
1117
1121
1118
public function printMetadata (?string $ metadata ): string
You can’t perform that action at this time.
0 commit comments