from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction0(Page): form_model = 'player' class Introduction(Page): form_model = 'player' def vars_for_template(self): # prepare an json object for highchart. here is an example # history_output = [player1,player2,player3,....] playeri = {'data':[output in round1, 2, 3,4...],'name':`Firm1'} Euro = [] # print('players: ',self.get_others_in_group()) Euro.append({}) Euro[0]['data'] = [] Euro[0]['name'] = 'Earnings in ' + self.player.Currency_name() for i in range(1,1001): Euro[0]['data'].append(round((i)**0.5/10,2)) return { 'Euro': Euro, } class Video(Page): form_model = 'player' class Quiz(Page): form_model = 'player' form_fields = ['Q1_1','Q1_2','Q2','Q3',] def error_message(self, values): #print('values is', values) Q1_1 = "Question 1(a) " Q1_2 = "Question 1(b) " Q2 = "Question 2 " Q3 = "Question 3 " if values['Q1_1']==345: Q1_1 = "" if values['Q1_2']==1.86: Q1_2 = "" if values['Q2'] == 2: Q2 = "" if self.player.Currency_exchange_on() == 1: if values['Q3'] == 1: Q3 = "" else: Q3 = "" if Q1_1+Q1_2+Q2+Q3 != "": return 'The Answers for the following questions are not correct: {} {} {} {}. Please read the instructions and try again. '.format(Q1_1,Q1_2,Q2,Q3) def vars_for_template(self): # prepare an json object for highchart. here is an example # history_output = [player1,player2,player3,....] playeri = {'data':[output in round1, 2, 3,4...],'name':`Firm1'} Euro = [] # print('players: ',self.get_others_in_group()) Euro.append({}) Euro[0]['data'] = [] Euro[0]['name'] = 'Earnings in ' + self.player.Currency_name() for i in range(1,1001): Euro[0]['data'].append(round((i)**0.5/10,2)) return { 'Euro': Euro, } page_sequence = [Introduction0,Introduction,Quiz]