from otree.api import *
doc = """
Simple version of comprehension test
"""
class C(BaseConstants):
NAME_IN_URL = 'comprehension_test_simple'
PLAYERS_PER_GROUP = None
NUM_ROUNDS = 1
timers = dict(pre_count=60*2, mypage=60 * 3, start_last_part=60 * 2)
class Subsession(BaseSubsession):
pass
class Group(BaseGroup):
pass
class Player(BasePlayer):
quiz1 = models.IntegerField(label='Quante lettere ci sono nella parola "CANE"?')
quiz2 = models.IntegerField(label='Quante lettere ci sono nella parola "RISTORANTE"?')
quiz3 = models.IntegerField(label='Quante lettere ci sono nella parola "FINESTRA"?')
quiz4 = models.IntegerField(label='Quante lettere ci sono nella parola "SEDIA"?')
quiz5 = models.IntegerField(label='Quante lettere ci sono nella parola "TAVOLO"?')
quiz6 = models.IntegerField(label='Quante lettere ci sono nella parola "COLAZIONE"?')
timeout = models.BooleanField(initial=False)
class PreCount(Page):
timeout_seconds = C.timers['pre_count']
@staticmethod
def before_next_page(player: Player, timeout_happened):
if timeout_happened:
player.timeout = True
player.participant.dropout = True
@staticmethod
def app_after_this_page(player: Player, upcoming_apps):
participant = player.participant
if participant.dropout:
return upcoming_apps[-1]
class MyPage(Page):
form_model = 'player'
form_fields = ['quiz1', 'quiz2', 'quiz3', 'quiz4', 'quiz5', 'quiz6']
timeout_seconds = C.timers['mypage']
# @staticmethod
# def get_form_fields(player: Player):
# import random
#
# form_fields = ['quiz1', 'quiz2', 'quiz3', 'quiz4', 'quiz5', 'quiz6']
#
# random.shuffle(form_fields)
# return form_fields
@staticmethod
def error_message(player: Player, values):
solutions = dict(quiz1=4, quiz2=10, quiz3=8, quiz4=5, quiz5=6, quiz6=9)
if values != solutions:
return "Una o più risposte sono sbagliate. Per favore corregga."
@staticmethod
def before_next_page(player: Player, timeout_happened):
if timeout_happened:
player.timeout = True
player.participant.dropout = True
@staticmethod
def app_after_this_page(player: Player, upcoming_apps):
participant = player.participant
if participant.dropout:
return upcoming_apps[-1]
class StartLastPart(Page):
timeout_seconds = C.timers['start_last_part']
@staticmethod
def before_next_page(player: Player, timeout_happened):
if timeout_happened:
player.timeout = True
player.participant.dropout = True
@staticmethod
def app_after_this_page(player: Player, upcoming_apps):
participant = player.participant
if participant.dropout:
return upcoming_apps[-1]
class Results(Page):
pass
page_sequence = [PreCount,
MyPage,
StartLastPart
#Results
]