from otree.api import Currency as c, currency_range
from ._builtin import Page, WaitPage
from .models import Constants

import random
import time


class Bienvenue0(Page):
    form_model = 'player'
    form_fields = ['versionexp']

    def before_next_page(self):
        self.participant.vars['versionexp'] = self.player.versionexp



class Bienvenue(Page):
    form_model = 'player'
    form_fields = []

    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1


    def before_next_page(self):
        self.player.language = "FR"
        self.player.participant.vars['language'] = self.player.language



        if self.player.id_in_group % 2 == 1:
            self.player.treatment = 1 # gneezy - BinsWanger
        else:
            self.player.treatment = 2 # BinsWanger -gneezy

        self.player.participant.vars['treatment'] = self.player.treatment


class Questionnaire0(Page):
    form_model = 'player'
    form_fields = ['q_1', 'q_2_a', 'q_2_b', 'q_2_c',
                   'q_22', 'q_2_e_a', 'q_2_e_b', 'q_2_e_c', 'q_2_h',
                    'q_3', 'q_4', 'q_5', 'q_6',
                   'q_7', 'q_8', 'q_9', 'q_10', 'q_11',
                       ]
    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1


class Questionnaire1(Page):
    form_model = 'player'
    form_fields = [
        'q_12', 'q_13', 'q_14',
        'q_15', 'q_16', 'q_17', 'q_18',
         'q_19',
        'q_19_a','q_19_b', 'q_20',
        'q_21',
        'q_22_p2', 'q_23',
                   ]
    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1



class Questionnaire2(Page):
    form_model = 'player'
    form_fields = [ 'q_24', 'q_25', 'q_26', 'q_27',
                    'q_27_a', 'q_28',  'q_29_a',
                    'q_29_b',
                       'q_29_c', 'q_29_d',
                       'q_30_a', 'q_30_b', 'q_30_c',
                    'q_30_d', 'q_30_e', 'q_30_f',
                    'q_31', 'q_32', 'q_33'

                       ]
    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1


class Questionnaire3(Page):
    form_model = 'player'
    form_fields = [  'q_34_a', 'q_34_b', 'q_34_c']

    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1


class QuestionnaireEnd(Page):
    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1



page_sequence = [
    Bienvenue0,
    Bienvenue,
    Questionnaire0,
    Questionnaire1,
    Questionnaire2,
    Questionnaire3,
    QuestionnaireEnd,


]
