Skip to content

Commit 2287da4

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 2287da4

File tree

4 files changed

+203
-175
lines changed

4 files changed

+203
-175
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: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ public function getContestStats(Contest $contest): ContestStatus
10091009
}
10101010

10111011
/**
1012+
* @param ScoreCache[]|null $cache
10121013
* @return array{'problems': ContestProblem[], 'samples': string[], 'showLimits': bool,
10131014
* 'defaultMemoryLimit': int, 'timeFactorDiffers': bool,
10141015
* 'stats': array{'numBuckets': int, 'maxBucketSizeCorrect': int,
@@ -1020,7 +1021,8 @@ public function getContestStats(Contest $contest): ContestStatus
10201021
public function getTwigDataForProblemsAction(
10211022
StatisticsService $statistics,
10221023
?int $teamId = null,
1023-
bool $forJury = false
1024+
bool $forJury = false,
1025+
?array $cache = null
10241026
): array {
10251027
$contest = isset($teamId) ? $this->getCurrentContest($teamId) : $this->getCurrentContest(onlyPublic: !$forJury);
10261028
$showLimits = (bool)$this->config->get('show_limits_on_team_page');
@@ -1093,8 +1095,20 @@ public function getTwigDataForProblemsAction(
10931095
}
10941096
}
10951097

1098+
$allProblems = [null => [], 'solved' => []];
1099+
if ($cache) {
1100+
foreach ($cache as $ind => $cachedProblem) {
1101+
if ($cachedProblem->getIsCorrect(true)) {
1102+
$allProblems['solved'][] = $problems[$ind];
1103+
} else {
1104+
$allProblems[null][] = $problems[$ind];
1105+
}
1106+
}
1107+
} else {
1108+
$allProblems = [null => $problems];
1109+
}
10961110
$data = [
1097-
'problems' => $problems,
1111+
'allproblems' => $allProblems,
10981112
'samples' => $samples,
10991113
'showLimits' => $showLimits,
11001114
'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)