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