Commit 43c0279e40e3f8cb17dcaf1e5150e0472791fd6a

Authored by Miguel Barão
1 parent 5635b91a
Exists in master and in 1 other branch dev

Fix text-regex questions due to upgrade to pyyaml 5.1.

Type declaration !regex is no longer required in questions.yaml files.
1 1
2 # BUGS 2 # BUGS
3 3
4 -- testar se perguntas regex funcionam com yaml.safe_load.  
5 - safari as vezes envia dois gets no inicio do topico. nesses casos, a segunda pergunta não é actualizada no browser... o topico tem de ser gerado qd se escolhe o topico em main_topics. O get nao deve alterar o estado. 4 - safari as vezes envia dois gets no inicio do topico. nesses casos, a segunda pergunta não é actualizada no browser... o topico tem de ser gerado qd se escolhe o topico em main_topics. O get nao deve alterar o estado.
6 - click numa opcao checkbox fora da checkbox+label não está a funcionar. 5 - click numa opcao checkbox fora da checkbox+label não está a funcionar.
7 - shift-enter não está a funcionar 6 - shift-enter não está a funcionar
aprendizations/knowledge.py
@@ -71,13 +71,14 @@ class StudentKnowledge(object): @@ -71,13 +71,14 @@ class StudentKnowledge(object):
71 # ------------------------------------------------------------------------ 71 # ------------------------------------------------------------------------
72 # FIXME async mas nao tem awaits... do not allow restart same topic 72 # FIXME async mas nao tem awaits... do not allow restart same topic
73 async def start_topic(self, topic): 73 async def start_topic(self, topic):
74 - logger.debug(f'StudentKnowledge.start_topic({topic})') 74 + logger.debug('StudentKnowledge.start_topic()')
75 if self.current_topic == topic: 75 if self.current_topic == topic:
  76 + logger.debug(' Restarting current topic is not allowed.')
76 return False 77 return False
77 78
78 # do not allow locked topics 79 # do not allow locked topics
79 if self.is_locked(topic): 80 if self.is_locked(topic):
80 - logger.debug(f'Topic {topic} is locked') 81 + logger.debug(f' Topic {topic} is locked')
81 return False 82 return False
82 83
83 # starting new topic 84 # starting new topic
aprendizations/questions.py
@@ -6,17 +6,9 @@ from os import path @@ -6,17 +6,9 @@ from os import path
6 import logging 6 import logging
7 import asyncio 7 import asyncio
8 8
9 -# user installed libraries  
10 -import yaml  
11 -  
12 # this project 9 # this project
13 from aprendizations.tools import run_script 10 from aprendizations.tools import run_script
14 11
15 -  
16 -# regular expressions in yaml files, e.g. correct: !regex '[aA]zul'  
17 -yaml.add_constructor('!regex', lambda l, n: re.compile(l.construct_scalar(n)))  
18 -  
19 -  
20 # setup logger for this module 12 # setup logger for this module
21 logger = logging.getLogger(__name__) 13 logger = logging.getLogger(__name__)
22 14
demo/solar_system/questions.yaml
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 ref: saturn 44 ref: saturn
45 title: Sistema solar 45 title: Sistema solar
46 text: O planeta do sistema solar conhecido por ter aneis é o planeta... 46 text: O planeta do sistema solar conhecido por ter aneis é o planeta...
47 - correct: !regex '[Ss]aturno' 47 + correct: '[Ss]aturno'
48 solution: | 48 solution: |
49 O planeta Saturno é famoso pelos seus anéis. 49 O planeta Saturno é famoso pelos seus anéis.
50 É o segundo maior planeta do Sistema Solar, a seguir a Júpiter. 50 É o segundo maior planeta do Sistema Solar, a seguir a Júpiter.