From 203495c326bc78f06b6ebef06954799a2bd20ae8 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Mon, 22 Jun 2015 20:47:15 +0100 Subject: [PATCH] - detect colisions in question refs - report inexistent refs in test.yaml - added logs directory (empty) to repository --- BUGS.md | 6 +++--- README.md | 14 +++++++------- demo/questions.yaml | 2 +- demo/test.yaml | 4 ++-- logs/.gitignore | 3 +++ questions.py | 7 +++++-- test.py | 6 +++++- 7 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 logs/.gitignore diff --git a/BUGS.md b/BUGS.md index 1a38e45..b55aba7 100644 --- a/BUGS.md +++ b/BUGS.md @@ -5,16 +5,13 @@ !!! - 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. - 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. -- colisoes nas referencias das perguntas. a referencia deveria influir o nome do ficheiro? acho que nao - se database for mal configurada, é criada uma base de dados vazia e rebenta na autenticacao. - mostrar erro quando nao consegue importar questions files - 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. - testar envio de parametros para stdin para perguntas tipo generator. -- usar pomba da ue moderna. # TODO -- pacotes exactos usados para instalar. - SQLAlchemy em vez da classe database. - Criar botão para o docente fazer enable/disable do aluno explicitamente (exames presenciais). - hash das passwords obtidas da concatenacao do numero de aluno com password (evita que passwords repetidas sejam detectadas). @@ -30,6 +27,9 @@ # FIXED +- pacotes exactos usados para instalar. +- detectar colisoes nas referencias das perguntas. +- usar pomba da ue moderna. - /results esta ordenado por numero e nao por data - numeros das perguntas não fazem sentido quando há caixas de informação (numerar informacao tb?) - 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) diff --git a/README.md b/README.md index 1577a67..739454a 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,15 @@ Online "perguntations". ### Requirements: -- python3.4 -- cherrypy -- mako -- yaml +Installed using `pip3`: +- CherryPy (3.7.0) +- Mako (1.0.1) +- Markdown (2.6.2) +- PyYAML (3.11) ### System setup: - ``` #!bash @@ -23,13 +23,13 @@ mv students.db db # update test configuration vi demo/test.yaml # update students_db -mkdir logs # logs are stored here # run demo test ./serve demo/test.yaml - ``` +(For the time being, also create `ans`, `questions`, `tests`, `scripts`, `sessions` in the same directory, until paths are fixed) + ### Contribute ### * Writing questions in yaml format diff --git a/demo/questions.yaml b/demo/questions.yaml index 83e835d..72a30b4 100644 --- a/demo/questions.yaml +++ b/demo/questions.yaml @@ -34,7 +34,7 @@ hint: It's not red. # --------------------------------------------------------------------------- - - ref: question-v2 + ref: question-v1 type: text_regex text: What's my favorite basic color? correct: '[bB]lue' diff --git a/demo/test.yaml b/demo/test.yaml index fe75d6d..a5a1e70 100644 --- a/demo/test.yaml +++ b/demo/test.yaml @@ -4,12 +4,12 @@ title: Teste de Demonstração # database contains students+passwords, final results of the tests, and questions done # database: path/to/students.db -database: db/asc1-students.db +database: db/students.db # this will generate a file for each test done. The file is like a replacement # for a test done in paper. save_answers: False -# answers_dir: path/to/directory +answers_dir: ans/demo show_points: True show_hints: True diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 0000000..afb5feb --- /dev/null +++ b/logs/.gitignore @@ -0,0 +1,3 @@ +# ignore everything except .gitignore +* +!.gitignore \ No newline at end of file diff --git a/questions.py b/questions.py index 06d60a6..8346d38 100644 --- a/questions.py +++ b/questions.py @@ -15,8 +15,8 @@ import os # for q in pool.values(): # test.append(create_question(q)) # -# test[0]['answer'] = 42 -# grade = test[0].correct() +# test[0]['answer'] = 42 # insert answer +# grade = test[0].correct() # correct answer # =========================================================================== @@ -39,6 +39,9 @@ class QuestionsPool(dict): print(' * question with index {0} in file {1} is not a dict. Ignoring...'.format(i, filename)) continue + if q['ref'] in self: + print(' * question "{0}" in file "{1}" already exists in file "{2}". Ignoring...'.format(q['ref'], filename, self[q['ref']]['filename'])) + # filename and index (number in the file, 0 based) q['filename'] = filename q['index'] = i diff --git a/test.py b/test.py index eab81f8..6c4ffc3 100644 --- a/test.py +++ b/test.py @@ -75,7 +75,11 @@ def read_configuration(filename, debug=False, show_points=False, show_hints=Fals # create list of alternatives, normalized l = [] for r in q['ref']: - qq = pool[r] + try: + qq = pool[r] + except KeyError: + print(' * question "{0}" in test "{1}" not found in the pool. Ignoring...'.format(r, test['ref'])) + continue qq['points'] = p l.append(qq) -- libgit2 0.21.2