/
submissions.html
279 lines (260 loc) · 13 KB
/
submissions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
{# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for #}
{# more information about the licensing of this file. #}
{% extends "layout.html" %}
{% block title %}{{ _("Submissions") }}{% endblock %}
{% block column %}
{{ template_helper.call('course_admin_menu',course=course,current='submissions') | safe }}
{% endblock %}
{% block navbar %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ get_homepath() }}/mycourses" title="{{ _('My courses') }}" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-graduation-cap"></i></a></li>
<li class="breadcrumb-item"><a href="{{get_homepath()}}/course/{{course.get_id()}}">{{ course.get_name(user_manager.session_language()) }}</a></li>
<li class="breadcrumb-item"><a href="{{get_homepath()}}/admin/{{course.get_id()}}" title="{{ _('Administration') }}" data-toggle="tooltip" data-placement="bottom">
<i class="fa fa-user-secret"></i></a></li>
<li class="breadcrumb-item active"><a href="#"><i class="fa fa-file-code-o fa-fw"></i> {{ _("Submissions") }} <span class="sr-only">{{ _("(current)") }}</span></a></li>
</ol>
</nav>
{% endblock %}
{% block content %}
{% set is_admin = user_manager.has_admin_rights_on_course(course) %}
<h2>{{_("Submissions")}}</h2>
<!-- Query submissions -->
{% with target="submissions#alerts", is_stats=False %}
{% include "course_admin/submissions_query.html" %}
{% endwith %}
<!-- Alerts -->
<div id="alerts">
{% for msg in msgs %}
<div class="alert alert-warning alert-dismissable" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ msg }}
</div>
{% endfor %}
</div>
<p>{{sub_count}} {{_("submissions selected")}}</p>
<!-- Submission table -->
<div style="overflow-x:auto;">
<table class="table">
<thead class="table-borderless">
<tr>
<th></th>
<th>
{% if "show_stud_name" in old_params %}
{{ _("student name") }}
{% else %}
{{ _("username") }}
{% endif %}
</th>
<th>
{% if "show_task_name" in old_params %}
{{ _("task name")}}
{% else %}
{{ _("taskid") }}
{% endif %}
</th>
{% if "show_id" in old_params %}
<th>{{ _("id") }}</th>
{% endif %}
<th>{{ _("submitted on") }}</th>
<th>{{ _("replayed on") }}</th>
<th>{{ _("result") }}</th>
{% if "show_tags" in old_params %}
<th>{{ _("tags") }}</th>
{% endif %}
<th>
<form method="post" action="submissions#alerts">
<input type="hidden" name="displayed_selection" value="{{displayed_selection}}">
<div class="btn-group btn-group-sm" role="group">
<button class="btn btn-info" type="submit" name="csv" formmethod="post" title="{{ _('Download CSV') }}" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-table"></i></button>
<div class="btn btn-danger" data-toggle="modal" data-target="#download_modal">
<div data-toggle="tooltip" data-placement="top" title="{{ _('Download current selection') }}"><i class="fa fa-download"></i></div>
</div>
{% if is_admin %}
<button class="btn btn-warning" type="submit" name="replay" formmethod="post" title="{{ _('Replay current selection') }}" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-refresh"></i></button>
{% endif %}
</div>
</form>
</th>
</tr>
</thead>
<tbody>
{% for submission in data %}
{% set succeeded = "result" in submission and submission["result"] == "success" %}
<tr class="
{% if succeeded %}
table-success
{% elif submission['status'] == 'waiting' %}
table-warning
{%else %}
table-danger
{%endif %}">
<td>
{% if "best" in submission and submission["best"] %}
<i class="fa fa-star" title="{{ submission['_id'] }}" data-toggle="tooltip" data-placement="bottom"></i>
{% endif %}
</td>
<td>
{% for user in submission["username"] %}
{% if "show_stud_name" in old_params %}
{{ users[user] if user in users else '?' }}<br>
{% else %}
{{ user }}<br>
{% endif %}
{% endfor %}
</td>
{% if "show_task_name" in old_params %}
<td>{{ tasks[submission["taskid"]].get_name(user_manager.session_language()) }}</td>
{% else %}
<td>{{ submission["taskid"] }}</td>
{% endif %}
{% if "show_id" in old_params %}
<td>{{ submission["_id"] }}</td>
{% endif %}
<td>{{ submission["submitted_on"].strftime("%d/%m/%Y %H:%M:%S") }}</td>
<td>
{% if "last_replay" in submission %}
{{submission["last_replay"].strftime("%d/%m/%Y %H:%M:%S") }}
{% else %}
-
{% endif %}
</td>
<td id="status">
{% if succeeded %}
{{_("Succeeded")}}
{%elif submission['status'] == 'waiting' %}
{{_("Waiting")}}
{% else %}
{{_("Failed")}}
{% endif %}
({{ submission.get("grade", 0.0) }}%)
</td>
<!-- TAGS td -->
{% if "show_tags" in old_params %}
<td>
{% set course_tags = course.get_tags() %}
{% for tag_submission in submission['tests'] %}
{% if tag_submission in course_tags %}
{% set tag = course_tags[tag_submission] %}
{% if tag.get_type() == 0 %}
<span style="line-height: 18px;">
<span class="badge alert-success" id="{{ tag.get_id() }}" style="border:1px solid green;">{{ tag.get_name(user_manager.session_language()) }}</span>
</span>
{% elif tag.get_type() == 1 %}
<span style="line-height: 18px;">
<span class="badge alert-danger" id="{{ tag.get_id() }}"> {{ tag.get_name(user_manager.session_language()) }}</span>
</span>
{% endif %}
{% endif %}
{% endfor %}
{# Auto-tags not defined in task #}
{% if "tests" in submission %}
{% for tag in submission["tests"] %}
{% if tag.startswith("*auto-tag-") %}
<span style="line-height: 18px;">
{% if submission["tests"][tag] | length > 30 %}
<span class="badge alert-warning" data-toggle="tooltip" data-placement="left" data-original-title="{{submission['tests'][tag]}}">{{ submission["tests"][tag][:30] }} …</span>
{% else %}
<span class="badge alert-warning">{{ submission["tests"][tag] }}</span>
{% endif %}
</span>
{% endif %}
{% endfor %}
{% endif %}
</td>
{% endif %}
<!-- END TAGS td -->
<td>
<div class="btn-group btn-group-sm" role="group">
<a href="{{get_homepath()}}/submission/{{submission['_id']}}"
class="btn btn-secondary" title="{{ _('View submission') }}" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-file-code-o fa-fw"></i></a>
<a href="{{get_homepath()}}/admin/{{course.get_id()}}/submissions?download_submission={{submission['_id']}}#alerts" class="btn btn-secondary" title="{{ _('Download submission') }}" data-toggle="tooltip"
data-placement="bottom"><i class="fa fa-download"></i></a>
{% if is_admin %}
<a href="#alerts" class="replay btn btn-secondary" title=" {{ _('Replay submission') }}" data-toggle="tooltip" data-submissionid="{{ submission['_id'] }}"
data-placement="bottom"><i class="fa fa-refresh"></i></a>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="d-flex justify-content-center">
<ul id="pagination" class="pagination-sm"></ul>
<form id="page_form" method="post" action="submissions#alerts">
<input type="hidden" name="displayed_selection" value="{{displayed_selection}}">
<input id="page_input" type="hidden" name="page" value="1">
</form>
</div>
<script>
$('#pagination').twbsPagination({
totalPages: {{ number_of_pages }},
startPage: {{ page_number }},
visiblePages: 5,
onPageClick: function (event, page) {
if(page != {{ page_number }}) {
$("#page_input").val(page)
$("#page_form").submit();
}
}
});
</script>
<!-- Modal to download submissions -->
<div id="download_modal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="submissions#alerts">
<input type="hidden" name="displayed_selection" value="{{ displayed_selection }}">
<div class="modal-header">
<h4 class="modal-title">{{ _("Download format") }}</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body row">
<label class="col-sm-2 control-label">{{ _("Folder format") }}</label>
<div class="col-sm-10">
{% set valid_formats = ["taskid/username", "taskid/audience", "username/taskid", "audience/taskid"] %}
{% set valid_formats_t = [_("taskid/username"), _("taskid/audience"), _("username/taskid"), _("audience/taskid") ] %}
{% for entry in valid_formats %}
<div class="radio">
<label><input type="radio" name="download_type" value="{{entry}}"> {{ _(entry) }}</label>
</div>
{% endfor %}
<label class="form-check-label">
<input name="eval_dl" class="form-check-input" type="checkbox"> {{_("Only evaluation submissions")}}
</label>
<br>
<label class="form-check-label">
<input name="simplify" class="form-check-input" type="checkbox"> {{ _("Simplified file tree") }}
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ _("Cancel") }}</button>
<button type="submit" name="download" formmethod="post" class="btn btn-info">{{ _("Download") }}</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal to download submissions END -->
{% if is_admin %}
<script>
$(".replay").click (function (event) {
var row = $(this).rparent(3);
$.ajax({
type: "POST",
url: "/admin/{{course.get_id()}}/submissions",
data: "replay_submission=" + $(this).data("submissionid"),
success: function(data) {
row.find("#status").text("{{ _('Waiting') }} (0.0%)");
row.removeClass();
row.addClass("table-warning");
}
});
});
</script>
{%endif %}
{% endblock %}