Commit e65f90d3fb0781ece1b7761a30576589b283f8cb

Authored by Miguel Barão
1 parent 623ce110
Exists in master and in 1 other branch dev

- added logout option in the menu.

- added final grade in a jumbotron when in train_mode.
BUGS.md
... ... @@ -8,7 +8,7 @@
8 8  
9 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 +- permitir enviar varios testes, aluno escolhe qual o teste que quer fazer.
12 12 - alterar o script json2md.py em conformidade
13 13 - Menu para professor com link para /results e /students
14 14 - implementar singlepage/multipage. Fazer uma class para single page que trate de andar gerir o avanco e correcao das perguntas
... ... @@ -19,6 +19,7 @@
19 19  
20 20 # FIXED
21 21  
  22 +- in the train_mode, there is no way to logout. Add logout option in the menu.
22 23 - simplificar a gravacao do teste em json.
23 24 - mostrar numero ordem em /results
24 25 - modal a pedir confirmação de submissão.
... ...
serve.py
... ... @@ -32,10 +32,20 @@ class Root(object):
32 32 def default(self, *args):
33 33 raise cherrypy.HTTPRedirect('/test')
34 34  
  35 + # --- LOGOUT ------------------------------------------------------------
  36 + @cherrypy.expose
  37 + @require()
  38 + def logout(self):
  39 + uid = cherrypy.session.get('userid')
  40 + self.loggedin.discard(uid)
  41 + cherrypy.lib.sessions.expire() # session coockie expires client side
  42 + cherrypy.session['userid'] = cherrypy.request.login = None
  43 + cherrypy.log.error('Student {0} logged out.'.format(uid), 'APPLICATION')
  44 + raise cherrypy.HTTPRedirect('/')
  45 +
35 46 # --- STUDENTS -----------------------------------------------------------
36 47 @cherrypy.expose
37 48 @require()
38   - # def students(self, reset_pw=None):
39 49 def students(self, **reset_pw):
40 50 uid = cherrypy.session.get('userid')
41 51 if uid != '0':
... ...
static/.DS_Store
No preview for this file type
templates/test.html
... ... @@ -63,8 +63,14 @@
63 63 <span class="icon-bar"></span>
64 64 <span class="icon-bar"></span>
65 65 </button>
66   - <a class="navbar-brand" href="#">UÉvora</a>
  66 + <a class="navbar-brand" href="#">
  67 + <!-- <img class="brand" alt="UEvora" src="/pomba-ue.svg"/> -->
  68 + UEvora
  69 + </a>
67 70 </div>
  71 +
  72 + <p class="navbar-text"> ${t['title']} </p>
  73 +
68 74 <div class="collapse navbar-collapse" id="myNavbar">
69 75 <!-- <ul class="nav navbar-nav">
70 76 <li><a href="#">Teoria</a></li>
... ... @@ -74,12 +80,15 @@
74 80 -->
75 81 <ul class="nav navbar-nav navbar-right">
76 82 <li class="dropdown">
77   - <a class="dropdown-toggle" data-toggle="dropdown" href="#">${t['number']} - ${t['name']} <span class="caret"></span></a>
78   -<!-- <ul class="dropdown-menu">
79   - <li><a href="#">Toggle colors (day/night)</a></li>
80   - <li><a href="#">Change password</a></li>
  83 + <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  84 + <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
  85 + ${t['name']} (${t['number']}) <span class="caret"></span>
  86 + </a>
  87 + <ul class="dropdown-menu">
  88 + <li><a href="/logout"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Logout</a></li>
  89 + <!-- <li><a href="#">Change password</a></li> -->
81 90 </ul>
82   - --> </li>
  91 + </li>
83 92 </ul>
84 93 </div>
85 94 </div>
... ... @@ -103,6 +112,16 @@
103 112 <%
104 113 total_points = sum(q['points'] for q in questions)
105 114 %>
  115 +
  116 + % if t['train_mode'] and 'grade' in t:
  117 + <div class="jumbotron drop-shadow">
  118 + <h1>Resultado</h1>
  119 + <p>Teve <strong>${'{:.1f}'.format(t['grade'])}</strong> valores no teste.</p>
  120 + <p>Se quiser, pode submeter o teste novamente. Para terminar faça logout no menu.</p>
  121 +
  122 + </div>
  123 + % endif
  124 +
106 125 % for i,q in enumerate(questions):
107 126 <div class="ui-corner-all custom-corners">
108 127 % if q['type'] == 'information':
... ...