Skip to content

Commit a6b1008

Browse files
committed
Fix clarifications for unlinked problems
Closes: #3032
1 parent c1c71c3 commit a6b1008

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

webapp/src/Controller/Jury/ClarificationController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,12 @@ public function viewAction(Request $request, int $id): Response
200200
$clarcontest = $contest->getShortname();
201201
$data['subjectlink'] = null;
202202
if ($clar->getProblem()) {
203-
$concernssubject = $contest->getCid() . "-" . $clar->getProblem()->getProbid();
203+
if ($clar->getContestProblem()) {
204+
$concernssubject = $contest->getCid() . "-" . $clar->getProblem()->getProbid();
205+
} else {
206+
// Very special case, this problem is unlinked.
207+
$concernssubject = "";
208+
}
204209
$data['subjectlink'] = $this->generateUrl('jury_problem', ['probId' => $clar->getProblem()->getProbid()]);
205210
} elseif ($clar->getCategory()) {
206211
$concernssubject = $contest->getCid() . "-" . $clar->getCategory();

webapp/src/Twig/TwigExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,9 +1229,9 @@ private function hexToForegroundAndBorder(string $rgb): array
12291229
return [$foreground, $border];
12301230
}
12311231

1232-
public function problemBadge(ContestProblem $problem, bool $grayedOut = false): string
1232+
public function problemBadge(?ContestProblem $problem, bool $grayedOut = false): string
12331233
{
1234-
$rgb = Utils::convertToHex($problem->getColor() ?? '#ffffff');
1234+
$rgb = Utils::convertToHex($problem?->getColor() ?? '#ffffff');
12351235
if ($grayedOut || empty($rgb)) {
12361236
$rgb = Utils::convertToHex('whitesmoke');
12371237
}
@@ -1247,7 +1247,7 @@ public function problemBadge(ContestProblem $problem, bool $grayedOut = false):
12471247
$rgb,
12481248
$border,
12491249
$foreground,
1250-
$problem->getShortname()
1250+
$problem?->getShortname() ?? '?'
12511251
);
12521252
}
12531253

0 commit comments

Comments
 (0)