Skip to content

Commit 3bfe011

Browse files
Also show problem badges
1 parent 7b4a669 commit 3bfe011

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

webapp/src/Service/StatisticsService.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ public function getGroupedProblemsStats(
520520
/**
521521
* @return array{
522522
* contest: Contest,
523+
* problems: ContestProblem[],
523524
* filters: array<string, string>,
524525
* view: string,
525526
* languages: array<string, array{
@@ -529,6 +530,10 @@ public function getGroupedProblemsStats(
529530
* solved: int,
530531
* not_solved: int,
531532
* total: int,
533+
* problems_solved: array<int, ContestProblem>,
534+
* problems_solved_count: int,
535+
* problems_attempted: array<int, ContestProblem>,
536+
* problems_attempted_count: int,
532537
* }>
533538
* }
534539
*/
@@ -552,6 +557,10 @@ public function getLanguagesStats(Contest $contest, string $view): array
552557
'solved' => 0,
553558
'not_solved' => 0,
554559
'total' => 0,
560+
'problems_solved' => [],
561+
'problems_solved_count' => 0,
562+
'problems_attempted' => [],
563+
'problems_attempted_count' => 0,
555564
];
556565
}
557566

@@ -577,20 +586,28 @@ public function getLanguagesStats(Contest $contest, string $view): array
577586
$languageStats[$language->getLangid()]['total']++;
578587
if ($s->getResult() === 'correct') {
579588
$languageStats[$language->getLangid()]['solved']++;
589+
$languageStats[$language->getLangid()]['problems_solved'][$s->getProblem()->getProbId()] = $s->getContestProblem();
580590
} else {
581591
$languageStats[$language->getLangid()]['not_solved']++;
582592
}
593+
$languageStats[$language->getLangid()]['problems_attempted'][$s->getProblem()->getProbId()] = $s->getContestProblem();
583594
}
584595
}
585596

586597
foreach ($languageStats as &$languageStat) {
587-
usort($languageStat['teams'], static fn(Team $a, Team $b) => ($a->getLabel() ?: $a->getExternalid()) <=> ($b->getLabel() ?: $b->getExternalid()));
598+
usort($languageStat['teams'], static fn(
599+
Team $a,
600+
Team $b
601+
) => ($a->getLabel() ?: $a->getExternalid()) <=> ($b->getLabel() ?: $b->getExternalid()));
588602
$languageStat['team_count'] = count($languageStat['teams']);
603+
$languageStat['problems_solved_count'] = count($languageStat['problems_solved']);
604+
$languageStat['problems_attempted_count'] = count($languageStat['problems_attempted']);
589605
}
590606
unset($languageStat);
591607

592608
return [
593609
'contest' => $contest,
610+
'problems' => $this->getContestProblems($contest),
594611
'filters' => StatisticsService::FILTERS,
595612
'view' => $view,
596613
'languages' => $languageStats,

webapp/src/Twig/TwigExtension.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,9 +1061,12 @@ public function fileTypeIcon(string $type): string
10611061
return 'fas fa-file-' . $iconName;
10621062
}
10631063

1064-
public function problemBadge(ContestProblem $problem): string
1064+
public function problemBadge(ContestProblem $problem, bool $grayedOut = false): string
10651065
{
10661066
$rgb = Utils::convertToHex($problem->getColor() ?? '#ffffff');
1067+
if ($grayedOut) {
1068+
$rgb = 'whitesmoke';
1069+
}
10671070
$background = Utils::parseHexColor($rgb);
10681071

10691072
// Pick a border that's a bit darker.
@@ -1075,6 +1078,10 @@ public function problemBadge(ContestProblem $problem): string
10751078

10761079
// Pick the foreground text color based on the background color.
10771080
$foreground = ($background[0] + $background[1] + $background[2] > 450) ? '#000000' : '#ffffff';
1081+
if ($grayedOut) {
1082+
$foreground = 'silver';
1083+
$border = 'linen';
1084+
}
10781085
return sprintf(
10791086
'<span class="badge problem-badge" style="background-color: %s; border: 1px solid %s"><span style="color: %s;">%s</span></span>',
10801087
$rgb,

webapp/templates/jury/analysis/languages.html.twig

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,22 @@
4141
</div>
4242
{% endif %}
4343
<br/>
44-
<i class="fas fa-file-code fa-fw"></i> {{ language.total }} total submission{% if language.total != 1 %}s{% endif %}<br />
45-
<i class="fas fa-check fa-fw"></i> {{ language.solved }} submission{% if language.solved != 1 %}s{% endif %} solved problems<br />
44+
<i class="fas fa-file-code fa-fw"></i> {{ language.total }} total submission{% if language.total != 1 %}s{% endif %}
45+
for {{ language.problems_attempted_count }} problem{% if language.problems_attempted_count != 1 %}s{% endif %}:<br/>
46+
{% for problem in problems %}
47+
<a href="{{ path('jury_problem', {'probId': problem.probid}) }}">
48+
{{ problem | problemBadge(language.problems_attempted[problem.probid] is not defined) }}
49+
</a>
50+
{% endfor %}
51+
<br />
52+
<i class="fas fa-check fa-fw"></i> {{ language.solved }} submission{% if language.solved != 1 %}s{% endif %} solved problems
53+
for {{ language.problems_solved_count }} problem{% if language.problems_solved_count != 1 %}s{% endif %}:<br/>
54+
{% for problem in problems %}
55+
<a href="{{ path('jury_problem', {'probId': problem.probid}) }}">
56+
{{ problem | problemBadge(language.problems_solved[problem.probid] is not defined) }}
57+
</a>
58+
{% endfor %}
59+
<br />
4660
<i class="fas fa-xmark fa-fw"></i> {{ language.not_solved }} submission{% if language.not_solved != 1 %}s{% endif %} did not solve a problem<br />
4761
</div>
4862
</div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy