Skip to content

Commit aa8ed35

Browse files
committed
update submit model display
1 parent 56f076e commit aa8ed35

File tree

3 files changed

+83
-51
lines changed

3 files changed

+83
-51
lines changed

etc/db-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@
202202
description: Options related to the DOMjudge user interface.
203203
items:
204204
- name: default_submission_code_mode
205-
type: int
206-
default_value: 0
205+
type: array_val
206+
default_value: [upload]
207207
public: true
208208
description: Select the default submission method for the team
209209
options:
210-
0: Paste
211-
1: Upload
210+
- paste
211+
- upload
212212
- name: output_display_limit
213213
type: int
214214
default_value: 2000

webapp/src/Controller/Team/SubmissionController.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,28 @@ public function createAction(Request $request, ?Problem $problem = null): Respon
155155
}
156156
}
157157

158-
$active_tab = (bool) $this->config->get('default_submission_code_mode') == 0 ? 'paste' : 'upload';
159-
if ($this->dj->getCookie('active_tab') != null) {
160-
$active_tab = $this->dj->getCookie('active_tab');
158+
$active_tab_array = $this->config->get('default_submission_code_mode');
159+
$active_tab = "";
160+
if (count($active_tab_array) == 1) {
161+
$active_tab = reset($active_tab_array);
162+
$this->dj->setCookie('active_tab', $active_tab);
163+
}
164+
else if ($this->dj->getCookie('active_tab') != null) {
165+
$cookie_active_tab = $this->dj->getCookie('active_tab');
166+
if(in_array($cookie_active_tab, $active_tab_array)) {
167+
$active_tab = $cookie_active_tab;
168+
}
169+
else {
170+
$active_tab = reset($active_tab);
171+
$this->dj->setCookie('active_tab', $active_tab);
172+
}
161173
}
162174

163175
$data = [
164176
'formupload' => $formUpload->createView(),
165177
'formpaste' => $formPaste->createView(),
166178
'active_tab' => $active_tab,
179+
'active_tab_array' => $active_tab_array,
167180
'problem' => $problem,
168181
];
169182
$data['validFilenameRegex'] = SubmissionService::FILENAME_REGEX;

webapp/templates/team/submit_modal.html.twig

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,62 +20,81 @@
2020
</div>
2121
{% else %}
2222
<div class="modal-body">
23-
<ul class="nav nav-tabs container text-center" id="submissionTabs" role="tablist" style="width: 100%">
24-
<li class="nav-item" role="presentation" >
25-
<a class="nav-link {% if active_tab == 'upload' %}active{% endif %}" id="upload-tab" data-bs-toggle="tab" href="#upload" role="tab" aria-controls="upload" aria-selected="{% if active_tab == 'upload' %}true{% else %}false{% endif %}" onclick="setCookie('active_tab', 'upload')" >Upload File</a>
26-
</li>
27-
<li class="nav-item text-center" role="presentation">
28-
<a class="nav-link {% if active_tab == 'paste' %}active{% endif %}" id="paste-tab" data-bs-toggle="tab" href="#paste" role="tab" aria-controls="paste" aria-selected="{% if active_tab == 'paste' %}true{% else %}false{% endif %}" onclick="setCookie('active_tab', 'paste')">Paste Code</a>
29-
</li>
30-
</ul>
31-
<div class="tab-content" id="submissionTabsContent" style="margin-top: 20px;">
32-
<div class="tab-pane fade {% if active_tab == 'upload' %}show active{% endif %}" id="upload" role="tabpanel" aria-labelledby="upload-tab">
33-
{{ form_start(formupload) }}
34-
{{ form_row(formupload.code) }}
35-
<div class="alert d-none" id="files_selected"></div>
36-
{{ form_row(formupload.problem) }}
37-
{{ form_row(formupload.language) }}
38-
{{ form_row(formupload.entry_point) }}
39-
<div class="modal-footer">
40-
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
41-
<button type="submit" class="btn btn-success">
42-
<i class="fas fa-cloud-upload-alt"></i> Submit
43-
</button>
44-
</div>
45-
{{ form_end(formupload) }}
46-
</div>
23+
{% if active_tab_array | length > 1 %}
24+
<ul class="nav nav-tabs container text-center" id="submissionTabs" role="tablist" style="width: 100%">
25+
{% if 'upload' in active_tab_array %}
26+
<li class="nav-item" role="presentation">
27+
<a class="nav-link {% if active_tab == 'upload' %}active{% endif %}" id="upload-tab" data-bs-toggle="tab" href="#upload" role="tab" aria-controls="upload" aria-selected="{% if active_tab == 'upload' %}true{% else %}false{% endif %}" onclick="setCookie('active_tab', 'upload')">Upload File</a>
28+
</li>
29+
{% endif %}
30+
{% if 'paste' in active_tab_array %}
31+
<li class="nav-item text-center" role="presentation">
32+
<a class="nav-link {% if active_tab == 'paste' %}active{% endif %}" id="paste-tab" data-bs-toggle="tab" href="#paste" role="tab" aria-controls="paste" aria-selected="{% if active_tab == 'paste' %}true{% else %}false{% endif %}" onclick="setCookie('active_tab', 'paste')">Paste Code</a>
33+
</li>
34+
{% endif %}
35+
</ul>
36+
{% endif %}
4737

48-
<div class="tab-pane fade {% if active_tab == 'paste' %}show active{% endif %}" id="paste" role="tabpanel" aria-labelledby="paste-tab">
49-
{{ form_start(formpaste) }}
50-
{{ form_widget(formpaste.code_content) }}
51-
<label for="codeInput">Paste your code here:</label>
52-
<div class="editor-container">
53-
{{ "" | codeEditor(
54-
"_team_submission_code",
55-
"c_cpp",
56-
true,
57-
formpaste.code_content.vars.id,
58-
null,
59-
formpaste.language.vars.value
60-
) }}
38+
39+
<div class="tab-content" id="submissionTabsContent" style="margin-top: 20px;">
40+
{% if 'upload' in active_tab_array %}
41+
<div class="tab-pane fade {% if active_tab == 'upload' %}show active{% endif %}" id="upload" role="tabpanel" aria-labelledby="upload-tab">
42+
{{ form_start(formupload) }}
43+
{{ form_row(formupload.code) }}
44+
<div class="alert d-none" id="files_selected"></div>
45+
{{ form_row(formupload.problem) }}
46+
{{ form_row(formupload.language) }}
47+
{{ form_row(formupload.entry_point) }}
48+
<div class="modal-footer">
49+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
50+
<button type="submit" class="btn btn-success">
51+
<i class="fas fa-cloud-upload-alt"></i> Submit
52+
</button>
53+
</div>
54+
{{ form_end(formupload) }}
6155
</div>
56+
{% endif %}
57+
58+
{% if 'paste' in active_tab_array %}
59+
<div class="tab-pane fade {% if active_tab == 'paste' %}show active{% endif %}" id="paste" role="tabpanel" aria-labelledby="paste-tab">
60+
{{ form_start(formpaste) }}
61+
{{ form_widget(formpaste.code_content) }}
62+
<label for="codeInput">Paste your code here:</label>
63+
<div class="editor-container">
64+
{{ "" | codeEditor(
65+
"_team_submission_code",
66+
"c_cpp",
67+
true,
68+
formpaste.code_content.vars.id,
69+
null,
70+
formpaste.language.vars.value
71+
) }}
72+
</div>
6273
{{ form_row(formpaste.problem) }}
6374
{{ form_row(formpaste.language) }}
6475
{{ form_row(formpaste.entry_point) }}
65-
<div class="modal-footer">
66-
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
67-
<button type="submit" class="btn btn-primary">
68-
<i class="fas fa-paste"></i> Submit
69-
</button>
76+
<div class="modal-footer">
77+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
78+
<button type="submit" class="btn btn-primary">
79+
<i class="fas fa-paste"></i> Submit
80+
</button>
81+
</div>
82+
{{ form_end(formpaste) }}
7083
</div>
71-
{{ form_end(formpaste) }}
72-
</div>
84+
{% endif %}
7385
</div>
7486
</div>
7587
{% endif %}
7688
</div>
7789
</div>
7890

91+
<style>
92+
.single-tab {
93+
width: 100%;
94+
display: inline-block;
95+
}
96+
</style>
97+
7998
<script>
8099
const fileInput = document.getElementById('submit_problem_code');
81100
fileInput.addEventListener('change', (event) => {

0 commit comments

Comments
 (0)