Commit f6b63c71d20e3bd9c226d1ab4a697a1b530574ac
1 parent
c7ca2f4e
Exists in
master
and in
1 other branch
changes to demo scripts
Showing
3 changed files
with
24 additions
and
24 deletions
Show diff stats
demo/questions/correct/correct-question.py
... | ... | @@ -3,24 +3,22 @@ |
3 | 3 | import re |
4 | 4 | import sys |
5 | 5 | |
6 | -s = sys.stdin.read() | |
6 | +msg1 = '''--- | |
7 | +grade: 1.0 | |
8 | +comments: Muito bem! | |
9 | +''' | |
10 | + | |
11 | +msg0 = ''' | |
12 | +grade: 0.0 | |
13 | +comments: A resposta correcta é "red green blue". | |
14 | +''' | |
7 | 15 | |
8 | -# set of words converted to lowercase lowercase | |
9 | -answer = set(re.findall(r'[\w]+', s.lower())) | |
16 | +s = sys.stdin.read() | |
10 | 17 | |
11 | -# correct set of colors | |
12 | -rgb_colors = set(['red', 'green', 'blue']) | |
18 | +answer = set(re.findall(r'[\w]+', s.lower())) # get words in lowercase | |
19 | +rgb_colors = set(['red', 'green', 'blue']) # the correct answer | |
13 | 20 | |
14 | 21 | if answer == rgb_colors: |
15 | - # print(1.0) | |
16 | - print(''' | |
17 | - grade: 1.0 | |
18 | - comments: Muito bem! | |
19 | - ''') | |
22 | + print(msg1) | |
20 | 23 | else: |
21 | - # print(0.0) | |
22 | - print(''' | |
23 | - grade: 0.0 | |
24 | - comments: A resposta correcta é "red green blue". | |
25 | - ''') | |
26 | -exit(0) | |
27 | 24 | \ No newline at end of file |
25 | + print(msg0) | ... | ... |
demo/questions/correct/correct-timeout.py
demo/questions/generators/generate-question.py
... | ... | @@ -5,22 +5,23 @@ import sys |
5 | 5 | |
6 | 6 | arg = sys.stdin.read() # read arguments |
7 | 7 | |
8 | -a,b = (int(n) for n in arg.split(',')) | |
8 | +a, b = (int(n) for n in arg.split(',')) | |
9 | 9 | |
10 | -q = ''' | |
10 | +q = f'''--- | |
11 | 11 | type: checkbox |
12 | -text: | | |
13 | - 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. | |
12 | +text: | | |
13 | + Indique quais das seguintes adições resultam em overflow quando se considera | |
14 | + a adição de números com sinal (complemento para 2) em registos de 8 bits. | |
14 | 15 | |
15 | - Os números foram gerados aleatoriamente no intervalo de {0} a {1}. | |
16 | + Os números foram gerados aleatoriamente no intervalo de {a} a {b}. | |
16 | 17 | options: |
17 | -'''.format(a,b) | |
18 | +''' | |
18 | 19 | |
19 | 20 | correct = [] |
20 | 21 | for i in range(5): |
21 | 22 | x = randint(a, b) |
22 | 23 | y = randint(a, b) |
23 | - q += '- "`{} + {}`"\n'.format(x, y) | |
24 | + q += f' - "`{x} + {y}`"\n' | |
24 | 25 | correct.append(1 if x + y > 127 else -1) |
25 | 26 | |
26 | 27 | q += 'correct: ' + str(correct) | ... | ... |