oTree Forum >

Randomized Task data unsaved

#1 by Noella

I am sure this is easy for a lot, but I cannot figure it out. I have a set of questions with multiple choices. I randomized the questions using creating subsession; this is working well. However, at the end of the game, I realized that only the last question data was saved. 
I understand this is caused by randomizing, but I don’t know how to solve this. 
This is the code for randomizing:
def creating_session(subsession: Subsession):
    if subsession.round_number == 1:
        for p in subsession.get_players():
            round_numbers = list(range(1, C.NUM_ROUNDS + 1))
            task_rounds = dict(zip(C.questions, round_numbers))
            p.participant.task_rounds = task_rounds

I did this for each question:
class Q1(Page):
    form_model = 'player'
    form_fields = ['q1']

    def is_displayed(player: Player):
        participant = player.participant

        return player.round_number == participant.task_rounds['q1']

    def vars_for_template(player: Player):
        return dict(player_in_rounds = player.in_rounds(1, C.NUM_ROUNDS))

The data only shows the last question answered by the player. Since the choices made by player in each round is not saved, I cannot set payoff for the rounds. Attached is screenshot of the data page from localhost. 
I will be grateful for your help. 
I look forward to your suggestions.
Thank you.

Best wishes,

#2 by Chris_oTree

That data table just shows 1 round at a time. In the bottom left corner you can click through the rounds.

Write a reply

Set forum username