Commit 623ce1101b09268cee36d39375307b22798192a8

Authored by Miguel Barão
1 parent 23013d8c
Exists in master and in 1 other branch dev

- added a 'train_mode'. The submission will correct and show the test with the results obtained.

@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 8
9 # TODO 9 # TODO
10 10
  11 +- implementar train_mode:False em que a submissão do teste só faz a correcção e mantem-se na mesma página para o aluno corrigir as respostas.
11 - alterar o script json2md.py em conformidade 12 - alterar o script json2md.py em conformidade
12 - Menu para professor com link para /results e /students 13 - Menu para professor com link para /results e /students
13 - implementar singlepage/multipage. Fazer uma class para single page que trate de andar gerir o avanco e correcao das perguntas 14 - implementar singlepage/multipage. Fazer uma class para single page que trate de andar gerir o avanco e correcao das perguntas
@@ -102,21 +102,26 @@ class Root(object): @@ -102,21 +102,26 @@ class Root(object):
102 # store results in the database 102 # store results in the database
103 t.update_answers(ans) 103 t.update_answers(ans)
104 t.correct() 104 t.correct()
105 - if t['save_answers']:  
106 - t.save_json(self.testconf['answers_dir'])  
107 - self.database.save_test(t)  
108 -  
109 - # ---- Expire session ----  
110 - self.loggedin.discard(t['number'])  
111 - cherrypy.lib.sessions.expire() # session coockie expires client side  
112 - cherrypy.session['userid'] = cherrypy.request.login = None  
113 - cherrypy.log.error('Student %s terminated with grade = %.2f points.' %  
114 - (t['number'], t['grade']), 'APPLICATION')  
115 -  
116 - # ---- Show result to student ----  
117 - grades = self.database.student_grades(t['number'])  
118 - template = self.templates.get_template('grade.html')  
119 - return template.render(t=t, allgrades=grades) 105 +
  106 + if t['train_mode']:
  107 + raise cherrypy.HTTPRedirect('/test')
  108 +
  109 + else:
  110 + if t['save_answers']:
  111 + t.save_json(self.testconf['answers_dir'])
  112 + self.database.save_test(t)
  113 +
  114 + # ---- Expire session ----
  115 + self.loggedin.discard(t['number'])
  116 + cherrypy.lib.sessions.expire() # session coockie expires client side
  117 + cherrypy.session['userid'] = cherrypy.request.login = None
  118 + cherrypy.log.error('Student %s terminated with grade = %.2f points.' %
  119 + (t['number'], t['grade']), 'APPLICATION')
  120 +
  121 + # ---- Show result to student ----
  122 + grades = self.database.student_grades(t['number'])
  123 + template = self.templates.get_template('grade.html')
  124 + return template.render(t=t, allgrades=grades)
120 125
121 # ============================================================================ 126 # ============================================================================
122 def parse_arguments(): 127 def parse_arguments():
templates/test.html
@@ -189,10 +189,28 @@ @@ -189,10 +189,28 @@
189 % endif # modal 189 % endif # modal
190 % endif # show_hints 190 % endif # show_hints
191 191
  192 + % if t['train_mode'] and 'grade' in q:
  193 + % if q['grade'] > 0.9:
  194 + <div class="alert alert-success" role="alert">
  195 + <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
  196 + ${round(q['grade'] * q['points'] / total_points * 20.0, 1)} valores
  197 + </div>
  198 + % elif q['grade'] > 0.5:
  199 + <div class="alert alert-warning" role="alert">
  200 + <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
  201 + ${round(q['grade'] * q['points'] / total_points * 20.0, 1)} valores
  202 + </div>
  203 + % else:
  204 + <div class="alert alert-danger" role="alert">
  205 + <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
  206 + ${round(q['grade'] * q['points'] / total_points * 20.0, 1)} valores
  207 + </div>
  208 + % endif
  209 + % endif
192 210
193 % if t['show_points']: 211 % if t['show_points']:
194 <p class="text-right"> 212 <p class="text-right">
195 - <small>(${q['points'] / total_points * 20.0} pontos)</small> 213 + <small>(${round(q['points'] / total_points * 20.0, 1)} pontos)</small>
196 <p> 214 <p>
197 % endif 215 % endif
198 216
@@ -23,7 +23,7 @@ def read_configuration(filename): @@ -23,7 +23,7 @@ def read_configuration(filename):
23 test['title'] = str(test.get('title', '')) 23 test['title'] = str(test.get('title', ''))
24 test['show_hints'] = bool(test.get('show_hints', False)) 24 test['show_hints'] = bool(test.get('show_hints', False))
25 test['show_points'] = bool(test.get('show_points', False)) 25 test['show_points'] = bool(test.get('show_points', False))
26 - test['singlepage'] = bool(test.get('singlepage', True)) 26 + test['train_mode'] = bool(test.get('train_mode', False))
27 test['save_answers'] = bool(test.get('save_answers', True)) 27 test['save_answers'] = bool(test.get('save_answers', True))
28 if test['save_answers']: 28 if test['save_answers']:
29 if 'answers_dir' not in test: 29 if 'answers_dir' not in test: