Commit c2f89a7b819f18f38f762bdfb4acc249eb5ea4d9

Authored by Miguel Barão
1 parent 4a961828
Exists in master and in 1 other branch dev

- everything working.

BUGS.md
1 1  
2 2 # BUGS
3 3  
4   -- reset password nao funciona no admin
5 4 - qual a diferenca entre md_to_html e md_to_html_review, parece desnecessario haver dois.
6 5 - servir imagens das perguntas
7 6 - como alterar configuracao para mostrar logs de debug?
... ... @@ -12,6 +11,7 @@
12 11  
13 12 # TODO
14 13  
  14 +- cancelar teste no menu admin. Dado o numero de aluno remove teste e faz logout do aluno.
15 15 - decorador para user 0, evita o "if uid==0" em muitas funcoes.
16 16 - mathjax-node:
17 17 sudo pkg install node npm
... ... @@ -35,6 +35,7 @@
35 35  
36 36 # FIXED
37 37  
  38 +- reset password nao funciona no admin
38 39 - reload a intervalos não funciona.
39 40 - allow/deny nao funciona no /admin.
40 41 - Review de um teste que foi apagado rebenta.
... ...
app.py
... ... @@ -252,9 +252,7 @@ class App(object):
252 252 'start_time': self.online.get(uid, {}).get('test', {}).get('start_time',''),
253 253 'password_defined': pw != '',
254 254 'grades': self.get_student_grades_from_test(uid, self.testfactory['ref']),
255   - 'ip_address': self.online.get(uid, {}).get('student', {}).get('ip_address',''),
256   - 'user_agent': self.online.get(uid, {}).get('student', {}).get('user_agent',''),
257   - 'focus': self.online.get(uid, {}).get('student', {}).get('focus', True),
  255 + 'focus': self.online.get(uid, {}).get('student', {}).get('focus', True), # FIXME
258 256 })
259 257 return l
260 258  
... ... @@ -284,11 +282,11 @@ class App(object):
284 282 s.commit()
285 283 logger.info(f'Student {uid}: password reset to ""')
286 284  
287   - def set_user_agent(self, uid, user_agent=''):
288   - self.online[uid]['student']['user_agent'] = user_agent
  285 + # def set_user_agent(self, uid, user_agent=''):
  286 + # self.online[uid]['student']['user_agent'] = user_agent
289 287  
290   - def set_user_ip(self, uid, ipaddress=''):
291   - self.online[uid]['student']['ip_address'] = ipaddress
  288 + # def set_user_ip(self, uid, ipaddress=''):
  289 + # self.online[uid]['student']['ip_address'] = ipaddress
292 290  
293 291 def insert_new_student(self, uid, name):
294 292 try:
... ...
serve.py
... ... @@ -280,7 +280,6 @@ class AdminHandler(BaseHandler):
280 280 self.testapp.deny_student(value)
281 281  
282 282 elif cmd == 'reset_password':
283   - print('reset ',value)
284 283 self.testapp.reset_password(value)
285 284  
286 285 elif cmd == 'insert_student':
... ...
static/css/test.css
1 1 /* Fixes navigation panel overlaying content */
2 2 html {
3   - font-size: 14px;
  3 + font-size: 13px;
4 4 }
5 5  
6 6 body {
... ... @@ -14,20 +14,15 @@ body {
14 14 color: inherit;
15 15 }
16 16  
17   -/*.card {
  17 +.card {
18 18 margin-top: 70px;
19 19 }
20   -*/
21 20  
22   -/*.drop-shadow {
23   - -webkit-box-shadow: 0 0 5px 2px rgba(0, 0, 0, .5);
24   - box-shadow: 0px 2px 10px 3px rgba(0, 0, 0, .2);
25   - border-radius:5px;
26   -}
27   -*/
  21 +
28 22 textarea {
29 23 font-family: monospace !important;
30 24 }
  25 +
31 26 /* make markdown tables beautiful */
32 27 table {
33 28 border-collapse: collapse;
... ...
static/js/admin.js
1 1 $(document).ready(function() {
2   - // button handlers (runs once)
3 2 function button_handlers() {
4   -
  3 + // button handlers (runs once)
5 4 $("#allow_all").click(
6 5 function() {
7 6 $(":checkbox").prop("checked", true).trigger('change');
... ... @@ -39,7 +38,6 @@ $(document).ready(function() {
39 38 });
40 39 }
41 40 );
42   -
43 41 // authorization checkboxes in the students_table:
44 42 $("tbody", "#students_table").on("change", "input", autorizeStudent);
45 43 }
... ... @@ -86,7 +84,7 @@ $(document).ready(function() {
86 84 $.ajax({
87 85 url: "/admin",
88 86 data: {"cmd": "test", "value": ""},
89   - // dataType: "json",
  87 + dataType: "json",
90 88 success: function(data) {
91 89 // fill jumbotron data
92 90 $("#title").html(data['data']['title']);
... ... @@ -114,8 +112,9 @@ $(document).ready(function() {
114 112 emptyTable: "Não há alunos inscritos",
115 113 },
116 114 ajax: {
117   - data: {"cmd": "students_table", "value": ""},
118 115 url: "admin", // students_table
  116 + data: {"cmd": "students_table", "value": ""},
  117 + dataType: "json",
119 118 dataSrc: function ( json ) {
120 119 var t = [];
121 120 for ( var i=0; i<json.data.length ; i++ ) {
... ... @@ -145,7 +144,7 @@ $(document).ready(function() {
145 144 }, 3000 );
146 145 }
147 146  
148   - // populateHeader(); // run once when the page is loaded
  147 + populateHeader(); // run once when the page is loaded
149 148 populateStudentsTable();
150 149 button_handlers(); // assign handlers to buttons
151 150 });
... ...
templates/admin.html
... ... @@ -43,7 +43,7 @@
43 43 </a>
44 44 <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownAluno">
45 45 <a class="dropdown-item" href="#" id="novo_aluno" data-toggle="modal" data-target="#novo_aluno_modal">Inserir novo...</a>
46   - <a class="dropdown-item" href="#" id="reset_password" data-toggle="modal" data-target="#reset_password_modal">Reset password...</a>
  46 + <a class="dropdown-item" href="#" id="reset_password_menu" data-toggle="modal" data-target="#reset_password_modal">Reset password...</a>
47 47 <a class="dropdown-item" href="#" id="allow_all">Autorizar todos</a>
48 48 <a class="dropdown-item" href="#" id="deny_all">Desautorizar todos</a>
49 49 </div>
... ... @@ -105,7 +105,6 @@
105 105 </div>
106 106  
107 107 <div class="modal-footer">
108   - <!-- <button type="button" class="btn btn-danger" data-dismiss="modal">Cancelar</button> -->
109 108 <button id="inserir_novo_aluno" class="btn btn-primary" role="button" data-dismiss="modal">Inserir</button>
110 109 </div>
111 110  
... ... @@ -124,15 +123,20 @@
124 123 </div>
125 124  
126 125 <div class="modal-body">
127   - <div class="input-group input-group-sm">
128   - <input id="reset_number" type="text" class="form-control" placeholder="Número">
129   - <span class="input-group-btn">
130   - <button id="reset_password" class="btn btn-primary" type="button">Reset password!</button>
131   - </span>
  126 + <div class="form-group row">
  127 + <label for="reset_number" class="col-sm-2 col-form-label">Número</label>
  128 + <div class="col-sm-10">
  129 + <input id="reset_number" type="text" class="form-control">
  130 + <!-- <input type="text" class="form-control" id="novo_numero" value=""> -->
  131 + </div>
132 132 </div>
133 133 </div>
  134 +
  135 + <div class="modal-footer">
  136 + <button id="reset_password" class="btn btn-primary" role="button" data-dismiss="modal">Reset password</button>
  137 + </div>
134 138 </div>
135   - </div>
  139 + </div> <!-- modal -->
136 140 </div>
137 141  
138 142  
... ...
templates/test.html
... ... @@ -42,22 +42,10 @@
42 42 </ul>
43 43  
44 44 <span class="navbar-text">
45   -
46   -
47   -<!-- <span class="navbar-text dropdown">
48   - <a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
49   - -->
50   -
51 45 <i class="fa fa-user" aria-hidden="true"></i>
52 46 <span id="name">{{ escape(t['student']['name']) }}</span>
53 47 (<span id="number">{{ escape(t['student']['number']) }}</span>)
54 48 <span class="caret"></span>
55   -
56   -<!-- </a>
57   - <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
58   - <a class="dropdown-item" href="#">Password</a>
59   - </div>
60   - -->
61 49 </span>
62 50 </div>
63 51 </nav>
... ... @@ -65,17 +53,16 @@
65 53  
66 54 <div class="jumbotron">
67 55 <h1 class="display-5">{{ t['title'] }}</h1>
68   - {{ t.get('duration', '') }}
69 56 <hr>
70 57  
71 58 <h5>
72 59 <div class="row">
73   - <label for="inicio" class="col-sm-2">Início:</label>
74   - <div class="col-sm-10" id="inicio">{{ str(t['start_time'].time())[:8]}}</div>
  60 + <label for="inicio" class="col-sm-3">Início:</label>
  61 + <div class="col-sm-9" id="inicio">{{ str(t['start_time'].time())[:8]}}</div>
75 62 </div>
76 63 <div class="row">
77   - <label for="duracao" class="col-sm-2">Duração:</label>
78   - <div class="col-sm-10" id="duracao">{{ t.get('duration', chr(8734)) }}</div>
  64 + <label for="duracao" class="col-sm-3">Duração:</label>
  65 + <div class="col-sm-9" id="duracao">{{ t.get('duration', chr(8734)) }}</div>
79 66 </div>
80 67 </h5>
81 68 </div>
... ... @@ -86,10 +73,10 @@
86 73 {% end %}
87 74  
88 75 <div class="form-row">
89   - <div class="col-9">
  76 + <div class="col-12">
90 77 <button type="button" class="btn btn-success btn-lg btn-block" data-toggle="modal" data-target="#confirmar" id="form-button-submit">Submeter teste</button>
91 78 </div>
92   -<!-- <div class="col-3">
  79 +<!-- <div class="col-2">
93 80 <button type="button" class="btn btn-danger btn-lg btn-block" data-toggle="modal" data-target="#sair" id="form-button-sair">Desisto</button>
94 81 </div> -->
95 82 </div>
... ...