Commit 9c62c0f5e1d359656c405ad9f57a23730ea98ad2

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

- fixed textarea to monospace font and tab to 4 spaces (javascript braindead).

- changed looks in some initial logs.
- minor modification in learnapp database code to submit a new studenttopic.
- updated demo questions.
- updated BUGS.md.
BUGS.md
1 1  
2 2 BUGS:
3 3  
  4 +- forçar reload das perguntas.
4 5 - tabelas nas perguntas radio/checkbox não ocupam todo o espaço como em question.
5 6 - topicos virtuais nao deveriam aparecer. na construção da árvore os sucessores seriam ligados directamente aos predecessores.
6 7 - Criar outra estrutura organizada em capítulos (conjuntos de tópicos). Permitir capítulos de capítulos, etc.
7 8  
8   -
9 9 - reportar comentarios após submeter.
10   -- cada topico tem uma pagina begin e uma end?
11 10 - pertuntas tipo tristate: (sim, não, não sei)
12   -- animação no final de cada topico para se perceber a transição
13   -- aumentar espaço a seguir às tabelas no texto
14   -- guardar state cada vez que topico termina
15   -- tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4)
16   -- textarea deve mostrar no html os valores iniciais de ans, se existir
17 11 - detect questions in questions.yaml without ref -> error ou generate default.
18 12 - error if demo.yaml has no topics
19 13 - session management. close after inactive time.
... ... @@ -32,9 +26,15 @@ TODO:
32 26 - pymips: activar/desactivar instruções
33 27 - implementar servidor http com redirect para https.
34 28 - usar codemirror no textarea
  29 +- ao fim de 3 tentativas com password errada, envia email com nova password.
35 30  
36 31 FIXED:
37 32  
  33 +- tabs em textarea nao funcionam correctamente (insere 1 espaco em vez de 4)
  34 +- guardar state cada vez que topico termina
  35 +- textarea deve mostrar no html os valores iniciais de ans, se existirem
  36 +- aumentar espaço a seguir às tabelas no texto
  37 +- animação no final de cada topico para se perceber a transição
38 38 - "<" is not escaped in markdown.
39 39 - Está a mostrar a solução em 'comments'!!!
40 40 - database: answers não tem referencia para o topico, so para question_ref
... ...
demo/solar_system/questions.yaml
  1 +---
1 2  
2 3 # ---------------------------------------------------------------------------
3 4 -
... ... @@ -30,7 +31,7 @@
30 31 ref: saturn
31 32 type: text-regex
32 33 title: Sistema solar
33   - text: O planeta do nosso sistema solar conhecido por ter aneis chama-se planeta...
  34 + text: O planeta do sistema solar conhecido por ter aneis é o planeta...
34 35 correct: !regex '[Ss]aturno'
35 36  
36 37 # ---------------------------------------------------------------------------
... ... @@ -41,5 +42,6 @@
41 42 text: Escreva o nome dos três planetas mais próximos do Sol. (Exemplo `A, B e C`)
42 43 correct: correct-first_3_planets.py
43 44 # opcional
  45 + answer: Vulcano, Krypton, Plutão
44 46 lines: 3
45 47 timeout: 5
... ...
learnapp.py
... ... @@ -118,10 +118,9 @@ class LearnApp(object):
118 118 a = s.query(StudentTopic).filter_by(student_id=uid, topic_id=finished_topic).one_or_none()
119 119 if a is None:
120 120 # insert new studenttopic into database
121   - u = s.query(Student).get(uid)
122   - a = StudentTopic(level=level, date=date)
123 121 t = s.query(Topic).get(finished_topic)
124   - a.topic = t
  122 + a = StudentTopic(level=level, date=date, topic=t)
  123 + u = s.query(Student).get(uid)
125 124 u.topics.append(a)
126 125 else:
127 126 # update studenttopic in database
... ... @@ -177,9 +176,9 @@ class LearnApp(object):
177 176 logger.critical(f'Database "{db}" not usable.')
178 177 sys.exit(1)
179 178 else:
180   - logger.info(f'{n:4} students.')
181   - logger.info(f'{m:4} topics.')
182   - logger.info(f'{q:4} questions answered.')
  179 + logger.info(f'{n:6} students.')
  180 + logger.info(f'{m:6} topics.')
  181 + logger.info(f'{q:6} answers.')
183 182  
184 183 # ------------------------------------------------------------------------
185 184 # helper to manage db sessions using the `with` statement, for example
... ... @@ -297,6 +296,6 @@ def build_dependency_graph(config={}):
297 296 q['path'] = fullpath
298 297 tnode['factory'][q['ref']] = QFactory(q)
299 298  
300   - logger.info(f'{len(tnode["questions"]):4} questions from {tref}')
  299 + logger.info(f'{len(tnode["questions"]):6} from {tref}')
301 300  
302 301 return g
... ...
templates/topic.html
... ... @@ -47,8 +47,11 @@
47 47 background-color: #f5f5f5;
48 48 }
49 49 html {
50   - position: relative;
51   - min-height: 100%;
  50 + position: relative;
  51 + min-height: 100%;
  52 + }
  53 + textarea {
  54 + font-family: monospace;
52 55 }
53 56 </style>
54 57  
... ... @@ -131,7 +134,7 @@
131 134 }
132 135 });
133 136  
134   - // Process the response given by the server
  137 + // Process response given by the server
135 138 function updateQuestion(response){
136 139 switch (response["method"]) {
137 140 case "new_question":
... ... @@ -152,7 +155,7 @@
152 155 e.preventDefault();
153 156 postQuestion();
154 157 }
155   - else if (e.keyCode === 9) { // tab
  158 + else if (e.keyCode == 9) { // tab
156 159 e.preventDefault(); // prevent loosing focus
157 160 // get caret position/selection
158 161 var start = this.selectionStart;
... ... @@ -160,8 +163,7 @@
160 163 var value = $(this).val();
161 164  
162 165 // set textarea value to: text before caret + tab + text after caret
163   - $(this).val(value.substring(0, start) + " " + value.substring(end));
164   -
  166 + $(this).val(value.substring(0, start) + " " + " " + " " + " " + value.substring(end));
165 167 // put caret at right position again (add one for the tab)
166 168 this.selectionStart = this.selectionEnd = start + 4;
167 169 }});
... ...