diff --git a/demo/correct-question.py b/demo/correct-question.py
deleted file mode 100755
index d1eef4c..0000000
--- a/demo/correct-question.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env python3
-
-import re
-import sys
-
-s = sys.stdin.read()
-
-# set of words converted to lowercase lowercase
-answer = set(re.findall(r'[\w]+', s.lower()))
-
-# correct set of colors
-rgb_colors = set(['red', 'green', 'blue'])
-
-if answer == rgb_colors:
- print(1.0)
-else:
- print(0.0)
-exit(0)
\ No newline at end of file
diff --git a/demo/generate-question.py b/demo/generate-question.py
deleted file mode 100755
index 2d999bc..0000000
--- a/demo/generate-question.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env python3
-
-from random import randint
-import sys
-
-arg = sys.stdin.read() # read arguments
-
-a,b = (int(n) for n in arg.split(','))
-
-q = '''
-type: checkbox
-text: |
- Indique quais das seguintes adições resultam em overflow quando se considera a adição de números com sinal (complemento para 2) em registos de 8 bits.
-
- Os números foram gerados aleatoriamente no intervalo de {0} a {1}.
-options:
-'''.format(a,b)
-
-correct = []
-for i in range(5):
- x = randint(a, b)
- y = randint(a, b)
- q += '- "`{} + {}`"\n'.format(x, y)
- correct.append(1 if x + y > 127 else -1)
-
-q += 'correct: ' + str(correct)
-
-print(q)
diff --git a/demo/questions.yaml b/demo/questions.yaml
deleted file mode 100644
index 6a65ed5..0000000
--- a/demo/questions.yaml
+++ /dev/null
@@ -1,75 +0,0 @@
--
- ref: solar-system-jupiter
- type: radio
- text: Qual dos seguintes é o maior planeta?
- options:
- - Jupiter
- - Mercury
- - Mars
- # optional, default is 0, True, True
- correct: 0
- shuffle: True
- discount: True
- hint: Também é o mais pesado.
-# ---------------------------------------------------------------------------
--
- ref: math-expressions
- type: checkbox
- text: Quais das seguintes expressões são verdadeiras?
- options:
- - $1 > 0$
- - $\sqrt{3} > \sqrt{2}$
- - $e^{i\pi} + 1 = 0$
- - $\frac{\partial f(x,y)}{\partial z} = 1$
- - $-1 > 1$
- correct: [1, 1, 1, -1, -1]
- # optional
- discount: True
- hint: Duas delas são falsas.
-# ---------------------------------------------------------------------------
--
- ref: question-v1
- type: text
- text: Indique uma das minhas cores básicas favoritas?
- correct: ['Azul', 'Verde']
- hint: Só há 3 cores básicas e não gosto de vermelho. A primeira letra é maiúscula.
-# ---------------------------------------------------------------------------
--
- ref: question-v2
- type: text_regex
- text: Qual é a minha cor básica favorita?
- correct: '[aA]zul'
- hint: O céu é...
-# ---------------------------------------------------------------------------
--
- ref: question-colors
- type: textarea
- text: Escreva o nome das três cores básicas em inglês.
- correct: correct-question.py
- hint: Qualquer ordem serve.
-# ---------------------------------------------------------------------------
--
- ref: question-whatever
- type: generator
- script: generate-question.py
- arg: "11,120"
- # the script should print a question in yaml format like the ones above.
- # Print only the dictionary, not the list (hiffen).
-# ---------------------------------------------------------------------------
--
- ref: one-question
- type: warning
- text: Não vale fazer batota!
-# ---------------------------------------------------------------------------
--
- ref: another-question
- # type: information (default)
- text: |
- O texto das perguntas é escrito em __markdown__ e pode incluir formulas em
- LaTeX $\sqrt{2\pi}$ e código lindinho
-
- ```.C
- int main() {
- return 0;
- }
- ```
diff --git a/demo/questions/correct/correct-question.py b/demo/questions/correct/correct-question.py
new file mode 100755
index 0000000..701ebb6
--- /dev/null
+++ b/demo/questions/correct/correct-question.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+
+s = sys.stdin.read()
+
+# set of words converted to lowercase lowercase
+answer = set(re.findall(r'[\w]+', s.lower()))
+
+# correct set of colors
+rgb_colors = set(['red', 'green', 'blue'])
+
+if answer == rgb_colors:
+ # print(1.0)
+ print('''
+ grade: 1.0
+ comments: Muito bem!
+ ''')
+else:
+ # print(0.0)
+ print('''
+ grade: 0.0
+ comments: A resposta correcta é "red green blue".
+ ''')
+exit(0)
\ No newline at end of file
diff --git a/demo/questions/correct/correct-timeout.py b/demo/questions/correct/correct-timeout.py
new file mode 100755
index 0000000..1098990
--- /dev/null
+++ b/demo/questions/correct/correct-timeout.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python3
+
+import sys
+import time
+
+s = sys.stdin.read()
+
+# generate timeout
+time.sleep(100)
+
+print(0.5)
diff --git a/demo/questions/generators/generate-question.py b/demo/questions/generators/generate-question.py
new file mode 100755
index 0000000..2d999bc
--- /dev/null
+++ b/demo/questions/generators/generate-question.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+from random import randint
+import sys
+
+arg = sys.stdin.read() # read arguments
+
+a,b = (int(n) for n in arg.split(','))
+
+q = '''
+type: checkbox
+text: |
+ Indique quais das seguintes adições resultam em overflow quando se considera a adição de números com sinal (complemento para 2) em registos de 8 bits.
+
+ Os números foram gerados aleatoriamente no intervalo de {0} a {1}.
+options:
+'''.format(a,b)
+
+correct = []
+for i in range(5):
+ x = randint(a, b)
+ y = randint(a, b)
+ q += '- "`{} + {}`"\n'.format(x, y)
+ correct.append(1 if x + y > 127 else -1)
+
+q += 'correct: ' + str(correct)
+
+print(q)
diff --git a/demo/questions/images/flag-es.svg b/demo/questions/images/flag-es.svg
new file mode 100644
index 0000000..fba167d
--- /dev/null
+++ b/demo/questions/images/flag-es.svg
@@ -0,0 +1,406 @@
+
+
\ No newline at end of file
diff --git a/demo/questions/images/flag-fr.svg b/demo/questions/images/flag-fr.svg
new file mode 100644
index 0000000..0baf7f3
--- /dev/null
+++ b/demo/questions/images/flag-fr.svg
@@ -0,0 +1 @@
+
diff --git a/demo/questions/images/flag-pt.svg b/demo/questions/images/flag-pt.svg
new file mode 100644
index 0000000..5c19329
--- /dev/null
+++ b/demo/questions/images/flag-pt.svg
@@ -0,0 +1,67 @@
+
+
\ No newline at end of file
diff --git a/demo/questions/images/planets.png b/demo/questions/images/planets.png
new file mode 100644
index 0000000..69845f4
Binary files /dev/null and b/demo/questions/images/planets.png differ
diff --git a/demo/questions/questions.yaml b/demo/questions/questions.yaml
new file mode 100644
index 0000000..d3896da
--- /dev/null
+++ b/demo/questions/questions.yaml
@@ -0,0 +1,174 @@
+-
+ ref: flags
+ type: radio
+ files:
+ flag1: images/flag-pt.svg
+ flag2: images/flag-es.svg
+ flag3: images/flag-fr.svg
+ text: Qual é a bandeira de Portugal?
+ options:
+ - ''
+ - ''
+ - ''
+ # opcional
+ title: Bandeiras nacionais
+# ---------------------------------------------------------------------------
+-
+ ref: solar-system
+ type: radio
+ files:
+ solar_system_planets: images/planets.png
+ text: Qual é o maior planeta do Sistema Solar?
+ options:
+ - Júpiter
+ - Mercúrio
+ - Marte
+ # opcional
+ correct: 0
+ title: Sistema solar
+ shuffle: True
+ discount: True
+ hint: Se usar o markdown `!(text)[imagem]` a imagem fica com tamanho fixo. É preferível usar a tag html `` para ter sempre a largura correcta.
+# ---------------------------------------------------------------------------
+-
+ ref: math-expressions
+ type: checkbox
+ text: Quais das seguintes expressões são verdadeiras?
+ options:
+ - $1 > 0$
+ - $\sqrt{3} > \sqrt{2}$
+ - $e^{i\pi} + 1 = 0$
+ - $\frac{\partial f(x,y)}{\partial z} = 1$
+ - $-1 > 1$
+ correct: [1, 1, 1, -1, -1]
+ # optional
+ title: Expressões matemáticas
+ shuffle: True
+ discount: True
+ hint: Duas delas são falsas.
+# ---------------------------------------------------------------------------
+-
+ ref: our_planet1
+ type: text
+ text: O nosso planeta chama-se planeta...
+ correct: ['Terra', 'terra']
+# ---------------------------------------------------------------------------
+-
+ ref: our_planet2
+ type: text_regex
+ text: O nosso planeta chama-se planeta...
+ correct: !regex '[Tt]erra'
+# ---------------------------------------------------------------------------
+-
+ ref: basic-colors
+ type: textarea
+ text: Escreva o nome das três cores básicas em inglês.
+ correct: correct/correct-question.py
+ # opcional
+ lines: 3
+ timeout: 5
+ hint: Qualquer ordem serve.
+# ---------------------------------------------------------------------------
+-
+ ref: question-whatever
+ type: generator
+ script: generators/generate-question.py
+ # opcional
+ arg: "11,120"
+ # the script should print a question in yaml format.
+ # Print only the dictionary, not the list of dictionaries like here.
+# ---------------------------------------------------------------------------
+-
+ ref: instructions
+ type: alert
+ title: Atenção
+ text: |
+ Deverá indicar em cada pergunta se pretende ou não classificá-la. Se não quiser responder a uma questão, desactive-a para evitar penalizações na nota final.
+
+# ---------------------------------------------------------------------------
+-
+ ref: markdown_instructions
+ type: information
+ title: Fórmulas auxiliares
+
+ # allow these files will be served:
+ files:
+ imagem_privada: images/flag-pt.svg
+
+ text: |
+ O texto das perguntas é escrito em __markdown__.
+
+ ### LaTeX
+
+ As soluções da equação $$$ax^2+bx+c=0$$$ são obtidas com a fórmula resolvente:
+ $$
+ x = \frac{-b\pm\sqrt{b^2-4ac}}{2a}
+ $$
+
+ ### Código
+
+ Suporta *syntax highlight* em múltiplas linguagens.
+
+ C:
+ ```C
+ int main() {
+ printf("Hello world!");
+ return 0; // comentario
+ }
+ ```
+
+ Python:
+ ```python
+ def myfunc(x, y):
+ 'returna soma dos argumentos'
+ return x + y + 1.0 # mais uma unidade
+ ```
+
+ Java:
+ ```java
+ public class HelloWorld {
+ public static void main(String[] args) {
+ // tanta coisa para dizer ola...
+ System.out.println("Hello, World");
+ }
+ }
+ ```
+
+ ### imagens
+
+ Pode incluir:
+
+ - imagens da internet (se acessível):
+
+ 
+
+ - imagens em ficheiros públicos locais:
+
+ 
+
+ - imagens privadas desta pergunta:
+
+ 
+
+ ### Videos Youtube (se acessível)
+
+ Em full screen: [Arte da Fuga - Glenn Gould](https://www.youtube.com/embed/iDSAXtsDB5k)
+
+ Ou embutido na página:
+
+
+
+ ### Tabelas
+
+ ~~Não são perfeitas~~, é uma limitação do markdown.
+
+ Left | Center | Right
+ ------------|:-------------:|-----:
+ A | *hello* | $1600.00
+ B | **world** | $12.50
+ C | `code` | $1.99
+
+
+ ---
+
+ (c) By the author
\ No newline at end of file
diff --git a/demo/test.yaml b/demo/test.yaml
index 680a684..0679e29 100644
--- a/demo/test.yaml
+++ b/demo/test.yaml
@@ -1,15 +1,16 @@
#=============================================================================
ref: demo
-title: Teste de Demonstração
+title: Exame de Demonstração
# Database with student credentials and grades of all questions and tests done
# The database is an sqlite3 file generate with the script initdb_from_csv.py
-database: demo/students.db
+database: ~/Work/Projects/perguntations/test/students.db
# (optional) Generate a file for each test done by a student.
# It includes the questions, answers and grades.
# If undefined, then no tests are saved (useful for debug and training)
-# answers_dir: WHERE_TO_SAVE_THE_TESTS
+save_answers: yes
+answers_dir: test/ans
# Show points for each question, scale 0-20 (default: False)
show_points: True
@@ -18,7 +19,7 @@ show_points: True
show_hints: True
# In practice mode a test can be repeat any number of times (default: False)
-practice: True
+practice: False
# Show lots of information for debugging (default: False)
# debug: True
@@ -27,7 +28,7 @@ practice: True
# Base path applied to the questions files and all the scripts
# including question generators and correctors.
# Either absolute path or relative to current directory.
-questions_dir: demo
+questions_dir: test/questions
# (optional) List of files containing questions in yaml format.
# Selected questions will be obtained from these files.
@@ -39,26 +40,17 @@ files:
# one question is selected from the list.
# The following example will generate a test with 3 questions.
questions:
- # first question
- - ref: math-expressions
- points: 1
-
- # second question
- - ref: solar-system-jupiter
+ - instructions
+ - ref: flags
points: 0.5
-
- # third question
- - ref:
- # choose 1 from the following 2 questions
- - question-v1
- - question-v2
- # points: 1.0 is the default, if omitted
-
- # fourth question
- - ref: question-colors
- points: 1.5
-
- # questions 5,6,7 using default points (=1.0)
+ - ref: math-expressions
+ points: 2.0
+ - ref: solar-system
+ # points: 1.0 is the default, if omitted
+ - ref: # choose one of the following list of questions
+ - our_planet1
+ - our_planet2
+ points: 0.75
+ - basic-colors # same as `ref: basic-colors`
- question-whatever
- - one-question
- - another-question
+ - markdown_instructions
--
libgit2 0.21.2