diff --git a/demo/questions/correct/correct-question.py b/demo/questions/correct/correct-question.py index 701ebb6..8319a2f 100755 --- a/demo/questions/correct/correct-question.py +++ b/demo/questions/correct/correct-question.py @@ -3,24 +3,22 @@ import re import sys -s = sys.stdin.read() +msg1 = '''--- +grade: 1.0 +comments: Muito bem! +''' + +msg0 = ''' +grade: 0.0 +comments: A resposta correcta é "red green blue". +''' -# set of words converted to lowercase lowercase -answer = set(re.findall(r'[\w]+', s.lower())) +s = sys.stdin.read() -# correct set of colors -rgb_colors = set(['red', 'green', 'blue']) +answer = set(re.findall(r'[\w]+', s.lower())) # get words in lowercase +rgb_colors = set(['red', 'green', 'blue']) # the correct answer if answer == rgb_colors: - # print(1.0) - print(''' - grade: 1.0 - comments: Muito bem! - ''') + print(msg1) else: - # print(0.0) - print(''' - grade: 0.0 - comments: A resposta correcta é "red green blue". - ''') -exit(0) \ No newline at end of file + print(msg0) diff --git a/demo/questions/correct/correct-timeout.py b/demo/questions/correct/correct-timeout.py index 1098990..c9eb0bf 100755 --- a/demo/questions/correct/correct-timeout.py +++ b/demo/questions/correct/correct-timeout.py @@ -5,7 +5,8 @@ import time s = sys.stdin.read() -# generate timeout +# sleep a lot of time to generate timeout during correction time.sleep(100) +# probably this result will not be seen because the script will be interrupted print(0.5) diff --git a/demo/questions/generators/generate-question.py b/demo/questions/generators/generate-question.py index 2d999bc..a494ad3 100755 --- a/demo/questions/generators/generate-question.py +++ b/demo/questions/generators/generate-question.py @@ -5,22 +5,23 @@ import sys arg = sys.stdin.read() # read arguments -a,b = (int(n) for n in arg.split(',')) +a, b = (int(n) for n in arg.split(',')) -q = ''' +q = f'''--- 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. +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}. + Os números foram gerados aleatoriamente no intervalo de {a} a {b}. options: -'''.format(a,b) +''' correct = [] for i in range(5): x = randint(a, b) y = randint(a, b) - q += '- "`{} + {}`"\n'.format(x, y) + q += f' - "`{x} + {y}`"\n' correct.append(1 if x + y > 127 else -1) q += 'correct: ' + str(correct) -- libgit2 0.21.2