Skip to content

Commit bb8b8c4

Browse files
committed
Alternative solution by collapsing cards
When you press the button it displays the card of the solved problem.
1 parent a1a7ca9 commit bb8b8c4

File tree

4 files changed

+218
-196
lines changed

4 files changed

+218
-196
lines changed

webapp/public/index.php

100644100755
File mode changed.

webapp/src/Service/DOMJudgeService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ public function getContestStats(Contest $contest): ContestStatus
10121012
/**
10131013
* @param ScoreCache[]|null $cache
10141014
* @return array{'allproblems': array<mixed, ContestProblem[]>, 'samples': string[], 'showLimits': bool,
1015-
* 'defaultMemoryLimit': int, 'timeFactorDiffers': bool,
1015+
* 'defaultMemoryLimit': int, 'timeFactorDiffers': bool, 'solved': bool[], 'fullallproblems': ContestProblem[],
10161016
* 'stats': array{'numBuckets': int, 'maxBucketSizeCorrect': int,
10171017
* 'maxBucketSizeCorrect': int, 'maxBucketSizeIncorrect': int,
10181018
* 'problems': array<array{'correct': array<array{'start': DateTime, 'end': DateTime, 'count': int}>,
@@ -1097,19 +1097,24 @@ public function getTwigDataForProblemsAction(
10971097
}
10981098

10991099
$allProblems = [null => [], 'solved' => []];
1100+
$solvedProblem = [];
11001101
if ($cache) {
11011102
foreach ($cache as $ind => $cachedProblem) {
11021103
if ($cachedProblem->getIsCorrect(true)) {
11031104
$allProblems['solved'][] = $problems[$ind];
1105+
$solvedProblem[] = true;
11041106
} else {
11051107
$allProblems[null][] = $problems[$ind];
1108+
$solvedProblem[] = false;
11061109
}
11071110
}
11081111
} else {
11091112
$allProblems = [null => $problems];
11101113
}
11111114
$data = [
11121115
'allproblems' => $allProblems,
1116+
'fullallproblems' => [null => $problems],
1117+
'solved' => $solvedProblem,
11131118
'samples' => $samples,
11141119
'showLimits' => $showLimits,
11151120
'defaultMemoryLimit' => $defaultMemoryLimit,

webapp/templates/partials/problem_list.html.twig

Lines changed: 44 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -16,206 +16,55 @@
1616
problemset
1717
</a>
1818
{% endif %}
19-
</h1>
20-
21-
{% for identifier, problems in allproblems %}
22-
{% if problems is empty %}
23-
{% if not identifier %}
24-
<div class="alert alert-secondary">No problem texts available at this point.</div>
25-
{% endif %}
26-
{% else %}
27-
<div class="container">
28-
{% if show_jury_warning is defined and show_jury_warning %}
29-
<div class="alert alert-warning">
30-
This is a preview of how the page will look like for teams and the public after the contest has started.
31-
</div>
32-
{% endif %}
33-
34-
{% if identifier %}
35-
<h1 class="mt-4 text-center" data-bs-toggle="collapse" href="#alreadySolved">
36-
Already solved problems
37-
<i class="fas fa-chevron-down"></i>
38-
</h1>
39-
{% endif%}
40-
41-
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-3 problem-list{% if identifier %} collapse{% endif %}" {% if identifier %}id="alreadySolved"{% endif %}>
42-
{% for problem in problems %}
43-
<div class="col">
44-
{% set numsamples = samples[problem.probid] %}
45-
{% if problem.problem.interactiveProblem %}
46-
{% set numsamples = 0 %}
47-
{% endif %}
48-
<div class="card">
49-
<div class="card-body">
50-
<h2 class="card-title">
51-
{{ problem | problemBadge }}
52-
</h2>
53-
<h3 class="card-subtitle mb-2 text-muted">
54-
{{ problem.problem.name }}
55-
</h3>
56-
{% if showLimits %}
57-
<h4 class="card-subtitle mb-2 text-muted">
58-
Limits: {{ problem.problem.timelimit }}
59-
second
60-
{%- if problem.problem.timelimit > 1 %}s{% endif %}
61-
{%- if timeFactorDiffers -%}
62-
<sup>*</sup>
63-
{% endif %}
64-
/
65-
{{ ((problem.problem.memlimit | default(defaultMemoryLimit)) * 1024) | printSize }}
66-
</h4>
67-
{% endif %}
68-
{% if problem.problem.languages | length != 0 %}
69-
<h4 class="card-subtitle mb-2 text-muted">
70-
Language{% if problem.problem.languages | length > 1 %}s{% endif %}:
71-
{% for lang in problem.problem.languages %}
72-
<code>{{ lang.name }}</code>{% if not loop.last %}, {% endif %}
73-
{% endfor %}
74-
</h4>
75-
{% endif %}
76-
<h4 class="card-subtitle mb-2 text-muted">
77-
Type: {{ problem.problem.typesAsString }}
78-
</h4>
7919

80-
{% if stats is defined %}
81-
<div class="mt-3">
82-
{% for correct in [true, false] %}
83-
<div class="problem-stats d-flex justify-content-center">
84-
{% for bucket in 0..stats.numBuckets - 1 %}
85-
{% if correct %}
86-
{% set index = 'correct' %}
87-
{% set maxBucketSize = stats.maxBucketSizeCorrect %}
88-
{% else %}
89-
{% set index = 'incorrect' %}
90-
{% set maxBucketSize = stats.maxBucketSizeIncorrect %}
91-
{% endif %}
92-
{% set stat = stats.problems[problem.problem.probid][index][bucket] %}
93-
{% set count = stat.count %}
94-
{% if maxBucketSize == 0 %}
95-
{% set bucket = 0 %}
96-
{% else %}
97-
{% set bucket = (count / maxBucketSize * 9) | round(0, 'ceil') %}
98-
{% endif %}
99-
{% if count == 1 %}
100-
{% set submissionText = 'submission' %}
101-
{% else %}
102-
{% set submissionText = 'submissions' %}
103-
{% endif %}
104-
{% if not contest.freezeData.showFinal and contest.freezetime and stat.end.timestamp >= contest.freezetime %}
105-
{% set maxBucketSize = max(1, stats.maxBucketSizeCorrect, stats.maxBucketSizeIncorrect) %}
106-
{% set bucket = (count / maxBucketSize * 9) | round(0, 'ceil') %}
107-
{% set itemClass = 'frozen' ~ '-' ~ bucket %}
108-
{% set label = count ~ ' ' ~ submissionText ~ ' in freeze' %}
109-
{% else %}
110-
{% set itemClass = index ~ '-' ~ bucket %}
111-
{% set label = count ~ ' ' ~ index ~ ' ' ~ submissionText %}
112-
{% endif %}
113-
<div
114-
class="problem-stats-item {{ itemClass }}"
115-
data-bs-toggle="tooltip"
116-
data-bs-placement="top"
117-
data-bs-html="true"
118-
title="Between {{ stat.start.timestamp | printtime(null, contest) }} and {{ stat.end.timestamp | printtime(null, contest) }}:<br/>{{ label }}">
119-
</div>
120-
{% endfor %}
121-
</div>
122-
{% endfor %}
123-
</div>
124-
<div>
125-
<br/>
126-
</div>
127-
{% endif %}
128-
129-
<div class="text-center">
130-
{% if show_submit_button | default(false) %}
131-
{% if is_granted('ROLE_JURY') or (current_team_contest is not null and current_team_contest.freezeData.started) %}
132-
<a class="justify-content-center" data-ajax-modal data-ajax-modal-after="initSubmitModal" href="{{ path('team_submit', {problem: problem.probid}) }}">
133-
<span class="btn btn-success">
134-
<i class="fas fa-cloud-upload-alt"></i> Submit
135-
</span>
136-
</a>
137-
{% else %}
138-
<a class="justify-content-center">
139-
<span class="btn btn-success disabled" disabled>
140-
<i class="fas fa-cloud-upload-alt"></i> Submit
141-
</span>
142-
</a>
143-
{% endif %}
144-
{% endif %}
145-
146-
{% set clarificationsCount = 0 %}
147-
{% set unseenClarificationCount = 0 %}
148-
{% if clarifications[problem.probid] is defined %}
149-
{% set clarificationsCount = clarifications[problem.probid] | length %}
150-
{% for clar in clarifications[problem.probid] %}
151-
{% if team and team.unreadClarifications.contains(clar) %}
152-
{% set unseenClarificationCount = unseenClarificationCount + 1 %}
153-
{% endif %}
154-
{% endfor %}
155-
{% endif %}
156-
{% if clarificationsCount > 0 %}
157-
<a data-ajax-modal class="btn btn-secondary" role="button"
158-
href="{{ path('team_clarification_by_prob', {'probId': problem.probid}) }}">
159-
<i class="fas fa-question-circle"></i>
160-
{% if clarificationsCount > 0 %}
161-
{% set badgeClass = 'text-bg-info' %}
162-
{% if unseenClarificationCount > 0 %}
163-
{% set badgeClass = 'text-bg-danger' %}
164-
{% endif %}
165-
<span class="badge {{ badgeClass }}">{{ clarificationsCount }}</span>
166-
{% endif %}
167-
clarifications
168-
</a>
169-
{% endif %}
170-
171-
<div style="margin-top: 10px;">
172-
</div>
20+
{% if allproblems['solved'] is defined and allproblems['solved'] is not empty %}
21+
<a class="btn btn-secondary" role="button"
22+
data-bs-toggle="collapse" data-bs-target=".collapse-solved-problems">
23+
<i class="fas fa-check-double"></i>
24+
show solved problems
25+
</a>
26+
{% endif %}
27+
</h1>
17328

174-
{% if problem.problem.problemstatementType is not empty %}
175-
<a class="btn btn-secondary" role="button"
176-
href="{{ path(problem_statement_path, {'probId': problem.probid}) }}">
177-
<i class="fas fa-file-{{ problem.problem.problemstatementType }}"></i>
178-
statement
179-
</a>
180-
{% endif %}
29+
{% set found_problem_texts = false %}
30+
{% for problems in allproblems %}
31+
{% if problems is not empty %}
32+
{% set found_problem_texts = true %}
33+
{% endif %}
34+
{% endfor %}
18135

182-
{% if numsamples > 0 %}
183-
<a class="btn btn-secondary" role="button"
184-
href="{{ path(problem_sample_zip_path, {'probId': problem.probid}) }}">
185-
<i class="fas fa-file-archive"></i> samples
186-
</a>
187-
{% endif %}
188-
</div>
36+
{% if not found_problem_texts %}
37+
<div class="alert alert-secondary">No problem texts available at this point.</div>
38+
{% else %}
39+
<div class="container">
40+
{% if show_jury_warning is defined and show_jury_warning %}
41+
<div class="alert alert-warning">
42+
This is a preview of how the page will look like for teams and the public after the contest has started.
43+
</div>
44+
{% endif %}
18945

190-
{% if problem.problem.attachments | length > 0 %}
191-
<hr/>
192-
<ol class="text-center list-group list-group-flush">
193-
{% for attachment in problem.problem.attachments %}
194-
<li class="list-group-item">
195-
<a class="btn btn-outline-secondary" role="button"
196-
href="{{ path(problem_attachment_path, {'probId': problem.probid, 'attachmentId': attachment.attachmentid}) }}">
197-
<i class="{{ attachment.type | fileTypeIcon }}"></i> {{ attachment.name }}
198-
</a>
199-
</li>
200-
{% endfor %}
201-
</ol>
202-
{% endif %}
46+
<h3>Alternative 1: Enable/Disable with button</h3>
47+
{% include 'partials/problem_list_cards.html.twig' with {'problems': fullallproblems[null], 'collapse': 2} %}
48+
<hr>
49+
<h3>Alternative 2: Those would be there by default</h3>
50+
{% include 'partials/problem_list_cards.html.twig' with {'problems': allproblems[null], 'collapse': 0} %}
20351

204-
</div>
205-
</div>
206-
</div>
207-
{% endfor %}
208-
</div>
52+
{% if allproblems['solved'] is defined %}
53+
<h1 class="mt-4 text-center" data-bs-toggle="collapse" href="#alreadySolved">
54+
Alternative 2: Already solved problems
55+
<i class="fas fa-chevron-down"></i>
56+
</h1>
57+
{% include 'partials/problem_list_cards.html.twig' with {'problems': allproblems['solved'], 'collapse': 1} %}
58+
{% endif %}
20959

210-
{% if showLimits and timeFactorDiffers %}
211-
<div class="row">
212-
<div class="col-md-12 my-sm-3">
213-
<div class=" alert alert-secondary" role="alert">
214-
* language time factors apply
215-
</div>
60+
{% if showLimits and timeFactorDiffers %}
61+
<div class="row">
62+
<div class="col-md-12 my-sm-3">
63+
<div class=" alert alert-secondary" role="alert">
64+
* language time factors apply
21665
</div>
21766
</div>
218-
{% endif %}
219-
</div>
220-
{% endif %}
221-
{% endfor %}
67+
</div>
68+
{% endif %}
69+
</div>
70+
{% endif %}

0 commit comments

Comments
 (0)