From 53e9b6550810c44d21325e36f2e714318055de12 Mon Sep 17 00:00:00 2001 From: Miguel Barão Date: Wed, 26 Jun 2019 11:36:48 +0100 Subject: [PATCH] - incorporate fixes from test.py (already in master) - update BUGS.md --- .gitignore | 5 ++++- BUGS.md | 8 +++++++- perguntations/__init__.py | 2 +- perguntations/test.py | 19 +++++++++---------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 2c886ad..255da5b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ static/lib /*.eggnode_modules # ignore javascript libraries installed with npm -node_modules/ \ No newline at end of file +node_modules/ + +# ignore documentation until it is actually written +doc/ \ No newline at end of file diff --git a/BUGS.md b/BUGS.md index 8122644..c1089a6 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,7 +1,10 @@ # BUGS -- quando se clica no texto de uma opcao, salta para outro lado na pagina. +- codigo `hello world` nao esta a preservar o whitespace. O renderer de markdown gera a tag que não preserva whitespace. Necessario adicionar
.
+- teste nao esta a mostrar imagens.
+- se houver erros a abrir ficheiros .yaml de perguntas, depois dos testes diz "No errors found".
+- dizer quanto desconta em cada pergunta de escolha multipla
 - ordenacao das notas em /admin nao é numerica, é ascii...
 - mensagems de erro do assembler aparecem na mesma linha na correcao e nao fazerm rendering do `$t`, ver se servidor faz parse do markdown dessas mensagens.
 - impedir os eventos copy/paste. alunos usam isso para trazer codigo ja feito nos computadores. Obrigar a fazer reset? fazer um copy automaticamente?
@@ -12,9 +15,11 @@ ou usar push (websockets?)
 - lidar com eventos unfocus.
 - servidor nao esta a lidar com eventos scroll/resize. ignorar?
 - Test.reset_answers() unused.
+- mudar ref do test para test_id (ref já é usado nas perguntas)
 
 # TODO
 
+- nao esta a usar points das perguntas
 - test: mostrar duração do teste com progressbar no navbar.
 - submissao fazer um post ajax?
 - adicionar opcao para eliminar um teste em curso.
@@ -54,6 +59,7 @@ ou usar push (websockets?)
 
 # FIXED
 
+- quando se clica no texto de uma opcao, salta para outro lado na pagina.
 - suportar cotacao to teste diferente de 20 (e.g. para juntar perguntas em papel). opcao "points: 18" que normaliza total para 18 em vez de 20.
 - fazer package para instalar perguntations com pip.
 - pymips: nao pode executar syscalls do spim.
diff --git a/perguntations/__init__.py b/perguntations/__init__.py
index b80190a..f38c675 100644
--- a/perguntations/__init__.py
+++ b/perguntations/__init__.py
@@ -32,7 +32,7 @@ proof of submission and for review.
 '''
 
 APP_NAME = 'perguntations'
-APP_VERSION = '2019.02.dev1'
+APP_VERSION = '2019.06.dev1'
 APP_DESCRIPTION = __doc__
 
 __author__ = 'Miguel Barão'
diff --git a/perguntations/test.py b/perguntations/test.py
index b08cde5..12b9380 100644
--- a/perguntations/test.py
+++ b/perguntations/test.py
@@ -133,13 +133,11 @@ class TestFactory(dict):
 
         testfile = path.join(path.expanduser(self['answers_dir']), 'REMOVE-ME')
         try:  # check if answers_dir is a writable directory
-            f = open(testfile, 'w')
+            with open(testfile, 'w') as f:
+                f.write('You can safely remove this file.')
         except OSError:
             logger.critical(f'Can\'t write answers to "{self["answers_dir"]}"')
             raise TestFactoryException()
-        else:
-            with f:
-                f.write('You can safely remove this file.')
 
         # --- ref
         if 'ref' not in self:
@@ -176,8 +174,8 @@ class TestFactory(dict):
 
         for i, q in enumerate(self['questions']):
             # normalize question to a dict and ref to a list of references
-            if isinstance(q, str):
-                q = {'ref': [q]}
+            if isinstance(q, str):  # e.g.,    - some_ref
+                q = {'ref': [q]}    # becomes  - ref: [some_ref]
             elif isinstance(q, dict) and isinstance(q['ref'], str):
                 q['ref'] = [q['ref']]
 
@@ -191,8 +189,9 @@ class TestFactory(dict):
         test = []
         # total_points = 0.0
 
-        n = 1
-        nerr = 0
+        n = 1     # track question number
+        nerr = 0  # count errors generating questions
+
         for qq in self['questions']:
             # choose one question variant
             qref = random.choice(qq['ref'])
@@ -207,9 +206,9 @@ class TestFactory(dict):
 
             # some defaults
             if q['type'] in ('information', 'success', 'warning', 'alert'):
-                q.setdefault('points', 0.0)
+                q['points'] = qq.get('points', 0.0)
             else:
-                q.setdefault('points', 1.0)
+                q['points'] = qq.get('points', 1.0)
                 q['number'] = n  # counter for non informative panels
                 n += 1
 
--
libgit2 0.21.2