Commit 2f37bba0126c947c154deb053f422b51f08f37df
1 parent
1456371e
Exists in
master
and in
1 other branch
- remember previous radio e checkbox answers in practice mode.
Showing
2 changed files
with
6 additions
and
5 deletions
Show diff stats
questions.py
... | ... | @@ -381,7 +381,8 @@ class QuestionTextArea(Question): |
381 | 381 | except subprocess.TimeoutExpired: |
382 | 382 | p.kill() |
383 | 383 | # p.communicate() # FIXME parece que este communicate obriga a ficar ate ao final do processo, mas nao consigo repetir o comportamento num script simples... |
384 | - self['grade'] = 0.0 # student gets a zero if timout occurs | |
384 | + value = 0.0 # student gets a zero if timout occurs | |
385 | + printf(' * Timeout in correction script') | |
385 | 386 | |
386 | 387 | # In case the correction program returns a non float value, we assume an error |
387 | 388 | # has occurred (for instance, invalid input). We just assume its the student's | ... | ... |
templates/test.html
... | ... | @@ -162,7 +162,7 @@ |
162 | 162 | % for opt in q['options']: |
163 | 163 | <div class="radio"> |
164 | 164 | <label class="option"> |
165 | - <input type="radio" name="${q['ref']}" id="${q['ref']}${loop.index}" value="${loop.index}"> | |
165 | + <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 ''}> | |
166 | 166 | ${pretty(opt)} |
167 | 167 | </label> |
168 | 168 | </div> |
... | ... | @@ -172,7 +172,7 @@ |
172 | 172 | % for opt in q['options']: |
173 | 173 | <div class="checkbox"> |
174 | 174 | <label> |
175 | - <input type="checkbox" name="${q['ref']}" id="${q['ref']}${loop.index}" value="${loop.index}"> | |
175 | + <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 ''}> | |
176 | 176 | ${pretty(opt)} |
177 | 177 | </label> |
178 | 178 | </div> |
... | ... | @@ -231,11 +231,11 @@ |
231 | 231 | </div> |
232 | 232 | % else: |
233 | 233 | <div class="alert alert-danger" role="alert"> |
234 | - <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | |
235 | - ${round(q['grade'] * q['points'] / total_points * 20.0, 1)} pontos | |
236 | 234 | <p> |
237 | 235 | ${random.choice(t['offensive']) if 'offensive' in t else ''} |
238 | 236 | </p> |
237 | + <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> | |
238 | + ${round(q['grade'] * q['points'] / total_points * 20.0, 1)} pontos | |
239 | 239 | </div> |
240 | 240 | % endif |
241 | 241 | % endif | ... | ... |