Skip to content

Commit 6c2a153

Browse files
committed
Hide already solved problems for teams
This moves the already solved problems under a new header, the teams can still visit those but it hides those by default to make it easier for teams to focus on the next problem. In case we like this we should check if the function should actually be public.
1 parent 0557de6 commit 6c2a153

File tree

4 files changed

+205
-176
lines changed

4 files changed

+205
-176
lines changed

webapp/src/Controller/Team/ProblemController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Service\ConfigurationService;
99
use App\Service\DOMJudgeService;
1010
use App\Service\EventLogService;
11+
use App\Service\ScoreboardService;
1112
use App\Service\StatisticsService;
1213
use Doctrine\ORM\EntityManagerInterface;
1314
use Doctrine\ORM\NonUniqueResultException;
@@ -32,6 +33,7 @@ public function __construct(
3233
DOMJudgeService $dj,
3334
protected readonly ConfigurationService $config,
3435
protected readonly StatisticsService $stats,
36+
protected readonly ScoreboardService $scoreboard,
3537
protected readonly EventLogService $eventLogService,
3638
EntityManagerInterface $em,
3739
KernelInterface $kernel,
@@ -46,8 +48,9 @@ public function __construct(
4648
public function problemsAction(): Response
4749
{
4850
$teamId = $this->dj->getUser()->getTeam()->getTeamid();
51+
$cache = $this->scoreboard->getScorecache($this->dj->getCurrentContest(), $this->dj->getUser()->getTeam());
4952
return $this->render('team/problems.html.twig',
50-
$this->dj->getTwigDataForProblemsAction($this->stats, $teamId));
53+
$this->dj->getTwigDataForProblemsAction($this->stats, $teamId, cache: $cache));
5154
}
5255

5356

webapp/src/Service/DOMJudgeService.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use App\Entity\ProblemAttachment;
2525
use App\Entity\QueueTask;
2626
use App\Entity\Rejudging;
27+
use App\Entity\ScoreCache;
2728
use App\Entity\Submission;
2829
use App\Entity\Team;
2930
use App\Entity\TeamAffiliation;
@@ -1009,7 +1010,8 @@ public function getContestStats(Contest $contest): ContestStatus
10091010
}
10101011

10111012
/**
1012-
* @return array{'problems': ContestProblem[], 'samples': string[], 'showLimits': bool,
1013+
* @param ScoreCache[]|null $cache
1014+
* @return array{'allproblems': array<mixed, ContestProblem[]>, 'samples': string[], 'showLimits': bool,
10131015
* 'defaultMemoryLimit': int, 'timeFactorDiffers': bool,
10141016
* 'stats': array{'numBuckets': int, 'maxBucketSizeCorrect': int,
10151017
* 'maxBucketSizeCorrect': int, 'maxBucketSizeIncorrect': int,
@@ -1020,7 +1022,8 @@ public function getContestStats(Contest $contest): ContestStatus
10201022
public function getTwigDataForProblemsAction(
10211023
StatisticsService $statistics,
10221024
?int $teamId = null,
1023-
bool $forJury = false
1025+
bool $forJury = false,
1026+
?array $cache = null
10241027
): array {
10251028
$contest = isset($teamId) ? $this->getCurrentContest($teamId) : $this->getCurrentContest(onlyPublic: !$forJury);
10261029
$showLimits = (bool)$this->config->get('show_limits_on_team_page');
@@ -1093,8 +1096,20 @@ public function getTwigDataForProblemsAction(
10931096
}
10941097
}
10951098

1099+
$allProblems = [null => [], 'solved' => []];
1100+
if ($cache) {
1101+
foreach ($cache as $ind => $cachedProblem) {
1102+
if ($cachedProblem->getIsCorrect(true)) {
1103+
$allProblems['solved'][] = $problems[$ind];
1104+
} else {
1105+
$allProblems[null][] = $problems[$ind];
1106+
}
1107+
}
1108+
} else {
1109+
$allProblems = [null => $problems];
1110+
}
10961111
$data = [
1097-
'problems' => $problems,
1112+
'allproblems' => $allProblems,
10981113
'samples' => $samples,
10991114
'showLimits' => $showLimits,
11001115
'defaultMemoryLimit' => $defaultMemoryLimit,

webapp/src/Service/ScoreboardService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ protected function getCategories(bool $jury): array
10781078
* Get the scorecache used to calculate the scoreboard.
10791079
* @return ScoreCache[]
10801080
*/
1081-
protected function getScorecache(Contest $contest, ?Team $team = null): array
1081+
public function getScorecache(Contest $contest, ?Team $team = null): array
10821082
{
10831083
$queryBuilder = $this->em->createQueryBuilder()
10841084
->from(ScoreCache::class, 's')

0 commit comments

Comments
 (0)