From bab5f36055ea9544520899e366629f54cdbe3f41 Mon Sep 17 00:00:00 2001
From: Miguel Barão
Date: Wed, 18 Nov 2020 20:08:24 +0000
Subject: [PATCH] - jobe_server on the test.yaml applies as default JOBE server for all questions, but can be overriden. - comments are parsed by markdown when reviewing tests.
---
BUGS.md | 4 +++-
demo/demo.yaml | 4 ++++
demo/questions/questions-tutorial.yaml | 8 ++++++--
perguntations/questions.py | 13 ++++++-------
perguntations/templates/review-question.html | 8 ++++----
perguntations/testfactory.py | 9 ++++++++-
6 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/BUGS.md b/BUGS.md
index e81d677..80e0fbb 100644
--- a/BUGS.md
+++ b/BUGS.md
@@ -1,8 +1,10 @@
# BUGS
+- em caso de timeout na submissão (e.g. JOBE ou script nao responde) a correcção não termina e o teste não é guardado.
+- QuestionCode falta reportar nos comments os vários erros que podem ocorrer (timeout, etc)
- permitir remover alunos que estão online para poderem comecar de novo.
-- grade gives internal server error
+- grade gives internal server error??
- reload do teste recomeça a contagem no inicio do tempo.
- 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.
- em grade.html as barras estao normalizadas para os limites scale_min e max do teste actual e nao dos testes realizados no passado (tabela test devia guardar a escala).
diff --git a/demo/demo.yaml b/demo/demo.yaml
index 0bfe4ef..2233ca4 100644
--- a/demo/demo.yaml
+++ b/demo/demo.yaml
@@ -14,6 +14,9 @@ database: students.db
# Directory where the submitted and corrected test are stored for later review.
answers_dir: ans
+# Server used to compile & execute code
+jobe_server: 192.168.1.85
+
# --- optional settings: -----------------------------------------------------
# Title of this test, e.g. course name, year or test number
@@ -37,6 +40,7 @@ show_points: true
# (default: no scaling, just use question points)
scale: [0, 5]
+
# ----------------------------------------------------------------------------
# Base path applied to the questions files and all the scripts
# including question generators and correctors.
diff --git a/demo/questions/questions-tutorial.yaml b/demo/questions/questions-tutorial.yaml
index fbfe559..06c8499 100644
--- a/demo/questions/questions-tutorial.yaml
+++ b/demo/questions/questions-tutorial.yaml
@@ -26,6 +26,7 @@
show_points: true # mostra cotação das perguntas (default: true)
scale: [0, 20] # limites inferior e superior da escala (default: [0,20])
scale_points: true # normaliza cotações para a escala definida
+ jobe_server: moodle-jobe.uevora.pt # server used to compile & execute code
debug: false # mostra informação de debug no browser
# --------------------------------------------------------------------------
@@ -626,7 +627,6 @@
Escreva um programa em C que recebe uma string no standard input e
mostra a mensagem `hello ` seguida da string.
Por exemplo, se o input for `Maria`, o output deverá ser `hello Maria`.
- server: 127.0.0.1 # replace by appropriate address
language: c
correct:
- stdin: 'Maria'
@@ -641,6 +641,10 @@
Se um caso incluir `stdin`, este será enviado para o programa e o `stdout`
obtido será comparado com o declarado. A pergunta é considerada correcta se
todos os outputs coincidirem.
+
+ Por defeito é o usado o servidor JOBE declarado no teste. Para usar outro
+ diferente nesta pergunta usa-se a opção `server: 127.0.0.1` com o endereço
+ apropriado.
answer: |
#include
int main() {
@@ -648,7 +652,7 @@
scanf("%s", name);
printf("hello %s", name);
}
- server: 192.168.1.141
+ # server: 192.168.1.85
language: c
correct:
- stdin: 'Maria'
diff --git a/perguntations/questions.py b/perguntations/questions.py
index 6338f35..4ec0f79 100644
--- a/perguntations/questions.py
+++ b/perguntations/questions.py
@@ -591,11 +591,8 @@ class QuestionTextArea(Question):
# ============================================================================
class QuestionCode(Question):
- '''An instance of QuestionCode will always have the keys:
- type (str)
- text (str)
- correct (str with script to run)
- answer (None or an actual answer)
+ '''
+ Submits answer to a JOBE server to compile and run against the test cases.
'''
_outcomes = {
@@ -669,13 +666,15 @@ class QuestionCode(Question):
return
logger.debug(self._outcomes[outcome])
+
+
if result['cmpinfo']: # compiler errors and warnings
self['comments'] = f'Erros de compilação:\n{result["cmpinfo"]}'
self['grade'] = 0.0
return
- if result['stdout'] != expected['stdout']:
- self['comments'] = 'O output gerado é diferente do esperado.'
+ if result['stdout'] != expected.get('stdout', ''):
+ self['comments'] = 'O output gerado é diferente do esperado.' # FIXME mostrar porque?
self['grade'] = 0.0
return
diff --git a/perguntations/templates/review-question.html b/perguntations/templates/review-question.html
index 305c068..4ea3137 100644
--- a/perguntations/templates/review-question.html
+++ b/perguntations/templates/review-question.html
@@ -39,14 +39,14 @@
{{ round(q['grade'] * q['points'], 2) }}
pontos
- {{ q['comments'] }}
+ {{ md(q['comments']) }}
{% elif q['grade'] > 0.49 %}
{{ round(q['grade'] * q['points'], 2) }}
pontos
- {{ q['comments'] }}
+ {{ md(q['comments']) }}
{% if q['solution'] %}
{{ md('**Solução:** \n\n' + q['solution']) }}
@@ -57,7 +57,7 @@
{{ round(q['grade'] * q['points'], 2) }}
pontos
- {{ q['comments'] }}
+ {{ md(q['comments']) }}
{% if q['solution'] %}
{{ md('**Solução:** \n\n' + q['solution']) }}
@@ -101,7 +101,7 @@
{{ round(q['grade'] * q['points'], 2) }} pontos
- {{ q['comments'] }}
+ {{ md(q['comments']) }}
{% if q['solution'] %}
{{ md('**Solução:** \n\n' + q['solution']) }}
diff --git a/perguntations/testfactory.py b/perguntations/testfactory.py
index cbebdc0..b1db1d4 100644
--- a/perguntations/testfactory.py
+++ b/perguntations/testfactory.py
@@ -98,16 +98,23 @@ class TestFactory(dict):
# make factory only for the questions used in the test
if question['ref'] in qrefs:
- question.setdefault('type', 'information')
+ # question.setdefault('type', 'information')
question.update({
'filename': filename,
'path': dirname,
'index': i # position in the file, 0 based
})
+ if question['type'] == 'code' and 'server' not in question:
+ try:
+ question['server'] = self['jobe_server']
+ except KeyError as exc:
+ msg = f'Missing JOBE server in "{question["ref"]}"'
+ raise TestFactoryException(msg)
self.question_factory[question['ref']] = QFactory(question)
# check if all the questions can be correctly generated
+ # TODO and corrected
try:
self.question_factory[question['ref']].generate()
except Exception as exc:
--
libgit2 0.21.2