Commit 203495c326bc78f06b6ebef06954799a2bd20ae8

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

- detect colisions in question refs

- report inexistent refs in test.yaml
- added logs directory (empty) to repository
BUGS.md
... ... @@ -5,16 +5,13 @@
5 5 !!! - questions type script, necessário dar um caminho exacto relativamete ao directorio do server em vez da pergunta. deveria ser possivel mover as perguntas de directorio sem rebentar os caminhos.
6 6  
7 7 - parece que é preciso criar à mão a pasta para as respostas (ans/...) depois apercebo-me que os caminhos no teste dizem respeito à directoria donde o teste é corrido... as respostas deveriam guardadas no directório dado.
8   -- colisoes nas referencias das perguntas. a referencia deveria influir o nome do ficheiro? acho que nao
9 8 - se database for mal configurada, é criada uma base de dados vazia e rebenta na autenticacao.
10 9 - mostrar erro quando nao consegue importar questions files
11 10 - testar regex na definicao das perguntas. como se faz rawstring em yaml? singlequote? problemas de backslash??? sim... necessário fazer \\ em varios casos, mas não é claro! e.g. \n é convertido em espaço mas \w é convertido em \\ e w.
12 11 - testar envio de parametros para stdin para perguntas tipo generator.
13   -- usar pomba da ue moderna.
14 12  
15 13 # TODO
16 14  
17   -- pacotes exactos usados para instalar.
18 15 - SQLAlchemy em vez da classe database.
19 16 - Criar botão para o docente fazer enable/disable do aluno explicitamente (exames presenciais).
20 17 - hash das passwords obtidas da concatenacao do numero de aluno com password (evita que passwords repetidas sejam detectadas).
... ... @@ -30,6 +27,9 @@
30 27  
31 28 # FIXED
32 29  
  30 +- pacotes exactos usados para instalar.
  31 +- detectar colisoes nas referencias das perguntas.
  32 +- usar pomba da ue moderna.
33 33 - /results esta ordenado por numero e nao por data
34 34 - numeros das perguntas não fazem sentido quando há caixas de informação (numerar informacao tb?)
35 35 - Quando apresenta o teste, preencher com os valores definidos em answer (permite que professor dê informação à partida, e no modo practice fiquem com o preenchido anteriormente)
... ...
README.md
... ... @@ -4,15 +4,15 @@ Online "perguntations".
4 4  
5 5 ### Requirements:
6 6  
7   -- python3.4
8   -- cherrypy
9   -- mako
10   -- yaml
  7 +Installed using `pip3`:
11 8  
  9 +- CherryPy (3.7.0)
  10 +- Mako (1.0.1)
  11 +- Markdown (2.6.2)
  12 +- PyYAML (3.11)
12 13  
13 14 ### System setup:
14 15  
15   -
16 16 ```
17 17 #!bash
18 18  
... ... @@ -23,13 +23,13 @@ mv students.db db
23 23  
24 24 # update test configuration
25 25 vi demo/test.yaml # update students_db
26   -mkdir logs # logs are stored here
27 26  
28 27 # run demo test
29 28 ./serve demo/test.yaml
30   -
31 29 ```
32 30  
  31 +(For the time being, also create `ans`, `questions`, `tests`, `scripts`, `sessions` in the same directory, until paths are fixed)
  32 +
33 33 ### Contribute ###
34 34  
35 35 * Writing questions in yaml format
... ...
demo/questions.yaml
... ... @@ -34,7 +34,7 @@
34 34 hint: It's not red.
35 35 # ---------------------------------------------------------------------------
36 36 -
37   - ref: question-v2
  37 + ref: question-v1
38 38 type: text_regex
39 39 text: What's my favorite basic color?
40 40 correct: '[bB]lue'
... ...
demo/test.yaml
... ... @@ -4,12 +4,12 @@ title: Teste de Demonstração
4 4  
5 5 # database contains students+passwords, final results of the tests, and questions done
6 6 # database: path/to/students.db
7   -database: db/asc1-students.db
  7 +database: db/students.db
8 8  
9 9 # this will generate a file for each test done. The file is like a replacement
10 10 # for a test done in paper.
11 11 save_answers: False
12   -# answers_dir: path/to/directory
  12 +answers_dir: ans/demo
13 13  
14 14 show_points: True
15 15 show_hints: True
... ...
logs/.gitignore 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +# ignore everything except .gitignore
  2 +*
  3 +!.gitignore
0 4 \ No newline at end of file
... ...
questions.py
... ... @@ -15,8 +15,8 @@ import os
15 15 # for q in pool.values():
16 16 # test.append(create_question(q))
17 17 #
18   -# test[0]['answer'] = 42
19   -# grade = test[0].correct()
  18 +# test[0]['answer'] = 42 # insert answer
  19 +# grade = test[0].correct() # correct answer
20 20  
21 21  
22 22 # ===========================================================================
... ... @@ -39,6 +39,9 @@ class QuestionsPool(dict):
39 39 print(' * question with index {0} in file {1} is not a dict. Ignoring...'.format(i, filename))
40 40 continue
41 41  
  42 + if q['ref'] in self:
  43 + print(' * question "{0}" in file "{1}" already exists in file "{2}". Ignoring...'.format(q['ref'], filename, self[q['ref']]['filename']))
  44 +
42 45 # filename and index (number in the file, 0 based)
43 46 q['filename'] = filename
44 47 q['index'] = i
... ...
test.py
... ... @@ -75,7 +75,11 @@ def read_configuration(filename, debug=False, show_points=False, show_hints=Fals
75 75 # create list of alternatives, normalized
76 76 l = []
77 77 for r in q['ref']:
78   - qq = pool[r]
  78 + try:
  79 + qq = pool[r]
  80 + except KeyError:
  81 + print(' * question "{0}" in test "{1}" not found in the pool. Ignoring...'.format(r, test['ref']))
  82 + continue
79 83 qq['points'] = p
80 84 l.append(qq)
81 85  
... ...