Commit e3d61b8258f5cbd3504a9170765bc53a69aaba24

Authored by Miguel Barão
1 parent 353ca74c
Exists in master and in 1 other branch dev

Default max_tries in radio and checkbox questions

Showing 2 changed files with 4 additions and 0 deletions   Show diff stats
BUGS.md
1 1  
2 2 # BUGS
3 3  
  4 +- guardar o estado a meio de um nível.
4 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.
5 6 - click numa opcao checkbox fora da checkbox+label não está a funcionar.
6 7 - shift-enter não está a funcionar
... ...
aprendizations/questions.py
... ... @@ -37,6 +37,7 @@ class Question(dict):
37 37 'comments': '',
38 38 'solution': '',
39 39 'files': {},
  40 + 'max_tries': 3,
40 41 })
41 42  
42 43 def correct(self) -> None:
... ... @@ -78,6 +79,7 @@ class QuestionRadio(Question):
78 79 'correct': 0,
79 80 'shuffle': True,
80 81 'discount': True,
  82 + 'max_tries': (n + 3) // 4 # 1 try for each 4 options
81 83 })
82 84  
83 85 # convert int to list, e.g. correct: 2 --> correct: [0,0,1,0,0]
... ... @@ -157,6 +159,7 @@ class QuestionCheckbox(Question):
157 159 'shuffle': True,
158 160 'discount': True,
159 161 'choose': n, # number of options
  162 + 'max_tries': max(1, min(n - 1, 3))
160 163 })
161 164  
162 165 if len(self['correct']) != n:
... ...