class Quiz(Page):
form_model = 'player'
form_fields = ['a', 'b', 'c']
@staticmethod
def vars_for_template(player: Player):
return dict(solutions=False)
class QuizSolutions(Page):
form_model = 'player'
form_fields = ['a', 'b', 'c']
@staticmethod
def vars_for_template(player: Player):
return dict(solutions=True)
Then an includable template that's included in both page's templates like this:
{{ formfield 'a' }}
{{ if solutions }}
{{ if player.a != '42' }} <p>Your answer was incorrect. It is 42 because ....</p>
{{ endif }}
{{ formfield 'b' }}
{{ if solutions }}
{{ if player.a != '42' }} <p>Your answer was incorrect. It is 42 because ....</p>
{{ endif }}
so the formfields will be re-displayed in the second page along with solutions.
You can disable the inputs in the second page with some javascript:
<script>
for (let input of document.getElementsByTagName('input')) {
input.disabled = 'disabled';
}
</script>
but note that cheating (changing the answers on the second page) is still possible if the user knows a some javascript.