diff --git a/BUGS.md b/BUGS.md index 78d3dc4..c2ca992 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,21 +1,20 @@ # BUGS -- review does not show question refs when commandline --show-ref is used but not the test.yaml option. -- em admin, quando scale_max não é 20, as cores das barras continuam a reflectir a escala 0,20. a tabela teste na DB não tem a escala desse teste. - CRITICAL se answer for `i que não preserva whitespace. Necessario adicionar
.
-- teste nao esta a mostrar imagens de vez em quando.
 - 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?
 - a revisao do teste não mostra as imagens.
 - Test.reset_answers() unused.
-- incluir test_id na tabela questions (futuro semestre, pode quebrar compatibilidade).
-- na pagina admin, mostrar com cor vermelha as horas de entrada dos alunos que ja tenham excedido o tempo
+- teste nao esta a mostrar imagens de vez em quando.???
 
 # TODO
 
+- na pagina admin, mostrar com cor vermelha as horas de entrada dos alunos que ja tenham excedido o tempo
 - retornar None quando nao ha alteracoes relativamente à última vez.
 ou usar push (websockets?)
 - mudar ref do test para test_id (ref já é usado nas perguntas)
diff --git a/demo/demo.yaml b/demo/demo.yaml
index 541c48e..7f74340 100644
--- a/demo/demo.yaml
+++ b/demo/demo.yaml
@@ -1,8 +1,10 @@
 ---
 # ============================================================================
 # Unique identifier of the test.
+# Valid names can only include letters, digits, dash and underscore,
+# e.g.  asc1-test3
 # Database queries can be done in the terminal with
-#     sqlite3 students.db "select * from tests where ref='tutorial'"
+#     sqlite3 students.db "select * from tests where ref='asc1-test3'"
 ref: tutorial
 
 # Database file that includes student credentials, tests and questions grades.
@@ -20,9 +22,9 @@ title: Teste de demonstração (tutorial)
 
 # Duration in minutes.
 # (0 or undefined means infinite time)
-duration: 2
+duration: 0
 
-# Automatic test submission after the timeout 'duration'?
+# Automatic test submission after the given 'duration' timeout
 # (default: false)
 autosubmit: true
 
@@ -40,9 +42,6 @@ scale: [0, 5]
 # scale_min: 0
 # scale_points: true
 
-show_ref: true
-debug: false
-
 # ----------------------------------------------------------------------------
 # Base path applied to the questions files and all the scripts
 # including question generators and correctors.
@@ -75,7 +74,7 @@ questions:
   - tut-warning
   - [tut-alert1, tut-alert2]
   - tut-generator
-
+  - tut-yamllint
 
 # test:
 #   - ref1
diff --git a/demo/questions/generators/generate-question.py b/demo/questions/generators/generate-question.py
index 3161ce4..604889c 100755
--- a/demo/questions/generators/generate-question.py
+++ b/demo/questions/generators/generate-question.py
@@ -18,11 +18,10 @@ print(f"""---
 type: text
 title: Geradores de perguntas
 text: |
-  Existe a possibilidade da pergunta ser gerada por um programa externo. Este
-  programa deve escrever no `stdout` uma pergunta em formato `yaml` como nos
+  Existe a possibilidade da pergunta ser gerada por um programa externo. O
+  programa deve escrever no `stdout` uma pergunta em formato `yaml` tal como os
   exemplos anteriores. Pode também receber argumentos para parametrizar a
-  geração da pergunta. Aqui está um exemplo de uma pergunta gerada por um
-  script python:
+  pergunta. Aqui está um exemplo de uma pergunta gerada por um script python:
 
   ```python
       #!/usr/bin/env python3
@@ -46,9 +45,7 @@ text: |
         A solução é {{r}}.''')
   ```
 
-  Este script deve ter permissões para poder ser executado no terminal. Dá
-  jeito usar o comando `gen-somar.py 1 100 | yamllint -` para validar o `yaml`
-  gerado.
+  Este script deve ter permissões para poder ser executado no terminal.
 
   Para indicar que uma pergunta é gerada externamente, esta é declarada com
 
@@ -56,12 +53,12 @@ text: |
       - type: generator
         ref: gen-somar
         script: gen-somar.py
-        # opcional
+        # argumentos opcionais
         args: [1, 100]
   ```
 
-  Os argumentos `args` são opcionais e são passados para o programa como
-  argumentos da linha de comando.
+  Opcionalmente, o programa pode receber uma lista de argumentos declarados em
+  `args`.
 
   ---
 
diff --git a/demo/questions/questions-tutorial.yaml b/demo/questions/questions-tutorial.yaml
index b033145..993d8b8 100644
--- a/demo/questions/questions-tutorial.yaml
+++ b/demo/questions/questions-tutorial.yaml
@@ -581,3 +581,25 @@
   ref: tut-generator
   script: generators/generate-question.py
   args: [1, 100]
+
+# ----------------------------------------------------------------------------
+- type: information
+  ref: tut-yamllint
+  title: Sugestões para validar yaml
+  text: |
+    Como os testes e perguntas são ficheiros `yaml`, é conveniente validar se
+    estão correctamente definitos. Um *linter* recomendado é o `yamllint`. Pode
+    ser instalado com `pip install yamllint` e usado do seguinte modo:
+
+    ```sh
+        yamllint test.yaml
+        yamllint questions.yaml
+    ```
+
+    No caso de programas geradores de perguntas e programas de correcção de
+    respostas pode usar-se um *pipe*:
+
+    ```sh
+        generate-question | yamllint -
+        correct-answer | yamllint -
+    ```
diff --git a/perguntations/__init__.py b/perguntations/__init__.py
index a928eb1..ce1af60 100644
--- a/perguntations/__init__.py
+++ b/perguntations/__init__.py
@@ -32,7 +32,7 @@ proof of submission and for review.
 '''
 
 APP_NAME = 'perguntations'
-APP_VERSION = '2020.05.dev2'
+APP_VERSION = '2020.05.dev3'
 APP_DESCRIPTION = __doc__
 
 __author__ = 'Miguel Barão'
diff --git a/perguntations/app.py b/perguntations/app.py
index 7623dd4..3ece150 100644
--- a/perguntations/app.py
+++ b/perguntations/app.py
@@ -276,8 +276,9 @@ class App():
                         uid, area, win_x, win_y, scr_x, scr_y)
 
     # ------------------------------------------------------------------------
+    # --- GETTERS
+    # ------------------------------------------------------------------------
 
-    # --- helpers (getters)
     # def get_student_name(self, uid):
     #     return self.online[uid]['student']['name']
 
@@ -388,7 +389,10 @@ class App():
     #         if q['ref'] == ref and key in q['files']:
     #             return path.abspath(path.join(q['path'], q['files'][key]))
 
-    # --- helpers (change state)
+    # ------------------------------------------------------------------------
+    # --- SETTERS
+    # ------------------------------------------------------------------------
+
     def allow_student(self, uid):
         '''allow a single student to login'''
         self.allowed.add(uid)
diff --git a/perguntations/models.py b/perguntations/models.py
index d0191ff..7fc416a 100644
--- a/perguntations/models.py
+++ b/perguntations/models.py
@@ -90,5 +90,5 @@ class Question(Base):
                 f'  grade:      "{self.grade}"\n'
                 f'  starttime:  "{self.starttime}"\n'
                 f'  finishtime: "{self.finishtime}"\n'
-                f'  student_id: "{self.student_id}"\n'
+                f'  student_id: "{self.student_id}"\n'  # FIXME normal form
                 f'  test_id:    "{self.test_id}"\n')
diff --git a/perguntations/serve.py b/perguntations/serve.py
index c9a03a8..c0dc987 100644
--- a/perguntations/serve.py
+++ b/perguntations/serve.py
@@ -246,7 +246,7 @@ class AdminHandler(BaseHandler):
             self.testapp.deny_student(value)
 
         elif cmd == 'reset_password':
-            await self.testapp.update_student_password(uid=value, pw='')
+            await self.testapp.update_student_password(uid=value, password='')
 
         elif cmd == 'insert_student':
             student = json.loads(value)
diff --git a/perguntations/templates/review-question-information.html b/perguntations/templates/review-question-information.html
index 8a62b83..a17a93c 100644
--- a/perguntations/templates/review-question-information.html
+++ b/perguntations/templates/review-question-information.html
@@ -18,7 +18,7 @@
 	
     {% if t['show_ref'] %}
         
- File: {{ q['path'] }}/{{ q['filename'] }}, - Ref: {{ q['ref'] }} + file: {{ q['path'] }}/{{ q['filename'] }}
+ ref: {{ q['ref'] }} {% end %} \ No newline at end of file diff --git a/perguntations/templates/review-question.html b/perguntations/templates/review-question.html index d822061..db2d4ce 100644 --- a/perguntations/templates/review-question.html +++ b/perguntations/templates/review-question.html @@ -66,8 +66,8 @@ {% if t['show_ref'] %}
- File: {{ q['path'] }}/{{ q['filename'] }}, - Ref: {{ q['ref'] }} + file: {{ q['path'] }}/{{ q['filename'] }}
+ ref: {{ q['ref'] }} {% end %} @@ -110,8 +110,8 @@ {% if t['show_ref'] %}
- File: {{ q['path'] }}/{{ q['filename'] }}, - Ref: {{ q['ref'] }} + file: {{ q['path'] }}/{{ q['filename'] }}
+ ref: {{ q['ref'] }} {% end %} -- libgit2 0.21.2