test.html
16.1 KB
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Teste </title>
<link rel="icon" href="/static/favicon.ico">
<!-- MathJax -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [["$$$","$$$"], ["$","$"], ["\\(","\\)"]]}
});
</script>
<script type="text/javascript" src="/static/js/mathjax/MathJax.js?config=TeX-AMS_CHTML-full">
</script>
<!-- Bootstrap -->
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css"> <!-- optional -->
<link rel="stylesheet" href="/static/css/github.css"> <!-- syntax highlight -->
<link rel="stylesheet" href="/static/css/sticky-footer-navbar.css">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<!-- My javascripts -->
<script src="/static/js/question_disabler.js"></script>
<script src="/static/js/prevent_enter_submit.js"></script>
<script src="/static/js/tabkey_in_textarea.js"></script>
<script src="/static/js/detect_unfocus.js"></script>
<style>
/* Fixes navigation panel overlaying content */
body {
padding-top: 80px;
background: #aaa;
}
/* Hack to avoid name clash between pygments and mathjax */
.MathJax .mo,
.MathJax .mi {
color: inherit;
}
.drop-shadow {
-webkit-box-shadow: 0 0 5px 2px rgba(0, 0, 0, .5);
box-shadow: 0px 2px 10px 3px rgba(0, 0, 0, .2);
border-radius:5px;
}
textarea {
font-family: monospace !important;
}
</style>
</head>
<!-- ===================================================================== -->
<body>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid drop-shadow">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<!-- <span class="glyphicon glyphicon-menu-hamburger"></span> -->
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
${t['title']}
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
${t['student']['name']} (${t['student']['number']}) <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li class="active"><a href="/test">Teste</a></li>
% if t['practice']:
<li><a href="/results">Ver resultados</a></li>
% endif
<li><a data-toggle="modal" data-target="#sair" id="form-button-submit"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Sair</a></li>
<!-- <li><a href="#">Change password</a></li> -->
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<form action="/correct/" method="post" id="test">
<%!
import markdown as md
import yaml
import random
%>
<%def name="pretty(text)">
${md.markdown(str(text), extensions=['markdown.extensions.tables',
'markdown.extensions.fenced_code',
'markdown.extensions.codehilite',
'markdown.extensions.def_list',
'markdown.extensions.sane_lists'])}
</%def>
<%
total_points = sum(q['points'] for q in t['questions'])
%>
% if t['debug']:
<pre>
${yaml.dump({k:v for k,v in t.items() if k!='questions'})}
</pre>
% endif
% if t['practice'] and 'grade' in t:
<div class="jumbotron drop-shadow">
<h1>Resultado</h1>
<p>Teve <strong>${'{:.1f}'.format(t['grade'])}</strong> valores.</p>
<p>Se quiser, pode corrigir e submeter o teste novamente.<br>Para terminar escolha a opção 'Sair' no menu.</p>
</div>
% endif
% for i,q in enumerate(t['questions']):
<div class="ui-corner-all custom-corners">
% if q['type'] == 'information':
<div class="alert alert-info drop-shadow" role="alert">
<h4>
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> ${q['title']}
</h4>
<p>
${pretty(q['text'])}
</p>
</div>
% elif q['type'] == 'warning':
<div class="alert alert-warning drop-shadow" role="alert">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> ${q['title']}
</h4>
<p>
${pretty(q['text'])}
</p>
</div>
% elif q['type'] == 'alert':
<div class="alert alert-danger drop-shadow" role="alert">
<h4>
<span class="glyphicon glyphicon-alert" aria-hidden="true"></span> ${q['title']}
</h4>
<p>
${pretty(q['text'])}
</p>
</div>
% else:
<div class="panel panel-primary drop-shadow">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left">
${q['title']}
</h4>
<div class="pull-right">
Classificar
<input type="checkbox" class="question_disabler" data-size="mini" name="answered-${q['ref']}" id="answered-${q['ref']}" checked="">
</div>
</div>
<div class="panel-body" id="example${i}">
<div class="question">
${pretty(q['text'])}
</div>
<fieldset data-role="controlgroup">
% if q['type'] == 'radio':
% for opt in q['options']:
<div class="radio">
<label class="option">
<input type="radio" name="${q['ref']}" id="${q['ref']}${loop.index}" value="${loop.index}" ${'checked' if q['answer'] is not None and str(loop.index) == q['answer'] else ''}>
${pretty(opt)}
</label>
</div>
% endfor
% elif q['type'] == 'checkbox':
% for opt in q['options']:
<div class="checkbox">
<label>
<input type="checkbox" name="${q['ref']}" id="${q['ref']}${loop.index}" value="${loop.index}" ${'checked' if q['answer'] is not None and str(loop.index) in q['answer'] else ''}>
${pretty(opt)}
</label>
</div>
% endfor
% elif q['type'] in ('text', 'text_regex'):
<input type="text" name="${q['ref']}" class="form-control" value="${q['answer'] if q['answer'] is not None else ''}">
% elif q['type'] == 'textarea':
<textarea class="form-control" rows="${q['lines']}" name="${q['ref']}">${q['answer'] if q['answer'] is not None else ''}</textarea>
% endif
</fieldset>
% if t['show_hints']:
% if 'hint' in q:
<button class="btn btn-sm btn-warning" type="button" data-toggle="collapse" data-target="#hint-${q['ref']}" aria-expanded="false" aria-controls="hint-${q['ref']}">
Ajuda
</button>
<div class="collapse" id="hint-${q['ref']}">
<div class="well">
${pretty(q['hint'])}
</div>
</div>
% endif # hint
% if 'modal' in q:
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modal-${q['ref']}">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
</button>
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal-${q['ref']}" aria-hidden="true" id="modal-${q['ref']}">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Anexo</h4>
</div>
<div class="modal-body">
${pretty(q['modal'])}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
</div>
% endif # modal
% endif # show_hints
% if t['show_points']:
<p class="text-right">
<small>(Cotação: ${round(q['points'] / total_points * 20.0, 1)} pontos)</small>
<p>
% endif
% if t['practice'] and 'grade' in q:
% if q['grade'] > 0.99:
<div class="alert alert-success" role="alert">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
${round(q['grade'] * q['points'] / total_points * 20.0, 1)} pontos<br>
${q['comments']}
</div>
% elif q['grade'] > 0.49:
<div class="alert alert-warning" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
${round(q['grade'] * q['points'] / total_points * 20.0, 1)} pontos<br>
${q['comments']}
</div>
% else:
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
${round(q['grade'] * q['points'] / total_points * 20.0, 1)} pontos<br>
${q['comments']}
</div>
% endif
% endif
</div> <!-- panel-body -->
% if t['debug'] or t['show_ref']:
<div class="panel-footer">
% if t['debug']:
<pre><code>
${yaml.dump(q)}
</code></pre>
% endif
% if t['show_ref']:
<dl class="dl-horizontal">
<dt>filename:</dt>
<dd>${q['filename']}</dd>
<dt>ref:</dt>
<dd>${q['ref']}</dd>
</dl>
% endif
</div>
% endif
</div> <!-- panel -->
% endif
</div> <!-- ui-corner-all custom-corners -->
% endfor
<hr>
<button type="button" class="btn btn-danger drop-shadow" data-toggle="modal" data-target="#confirmar" id="form-button-submit">
Submeter teste
</button>
</form>
</div>
<!-- Modal de confirmacao submissao -->
<div class="modal fade" id="confirmar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Deseja submeter o teste?</h4>
</div>
<div class="modal-body">
Se submeter, o teste será enviado para classificação e já não poderá voltar atrás.
Veja se respondeu a todas as questões e desactive as que não pretende classificar.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success btn-lg" data-dismiss="modal">Não!</button>
<button form="test" type="submit" class="btn btn-danger btn-lg">Sim, submeter</button>
</div>
</div>
</div>
</div>
<!-- Modal de confirmacao sair -->
<div class="modal fade" id="sair" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Deseja sair?</h4>
</div>
<div class="modal-body">
Se sair, será considerada desistência da prova e terá uma classificação de 0 valores.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success btn-lg" data-dismiss="modal">Não!</button>
<a href="/giveup" class="btn btn-danger btn-lg" role="button">Sim, desistir do teste</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>