from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants from utils import composer_fc #Throws error in IDE but works ;) class Algorithm_No_Explain(Page): def is_displayed(self): return self.participant.vars['treatment'] == 't_none' def vars_for_template(self): #Questions for questionnaire questions = self.participant.vars['questions_aft_explain'] question_order = self.participant.vars['questions_aft_explain_order'] (num_questions, questionnaire_table) = composer_fc.buildLikertScale(questions, question_order) self.player.questions_aft_explain_order = str(question_order) return{ 'total_number_products' : self.participant.vars['number_products'], 'questionnaire_1' : questionnaire_table, 'num_questions' : num_questions } form_model = 'player' form_fields = ['questions_aft_explain_answers'] class Algorithm_AV_Explain(Page): def is_displayed(self): return self.participant.vars['treatment'] == 't_av' def vars_for_template(self): #Questions for questionnaire questions = self.participant.vars['questions_aft_explain'] question_order = self.participant.vars['questions_aft_explain_order'] (num_questions, questionnaire_table) = composer_fc.buildLikertScale(questions, question_order) example_demand_data = [300, 400, 700, 500, 300, 400, 700, 800, 500, 400] nn_table = composer_fc.build_nn_table(example_demand_data) self.player.questions_aft_explain_order = str(question_order) return{ 'total_number_products' : self.participant.vars['number_products'], 'nn_table' : nn_table, 'questionnaire_1' : questionnaire_table, 'num_questions' : num_questions } form_model = 'player' form_fields = ['questions_aft_explain_answers'] class Algorithm_NN_Explain(Page): def is_displayed(self): return self.participant.vars['treatment'] == 't_nn' def vars_for_template(self): #Questions for questionnaire questions = self.participant.vars['questions_aft_explain'] question_order = self.participant.vars['questions_aft_explain_order'] (num_questions, questionnaire_table) = composer_fc.buildLikertScale(questions, question_order) example_demand_data = [300, 400, 700, 500, 300, 400, 700, 800, 500, 400] nn_table = composer_fc.build_nn_table(example_demand_data) self.player.questions_aft_explain_order = str(question_order) return{ 'total_number_products' : self.participant.vars['number_products'], 'nn_table' : nn_table, 'questionnaire_1' : questionnaire_table, 'num_questions' : num_questions } form_model = 'player' form_fields = ['questions_aft_explain_answers'] class Algorithm_LR_Explain(Page): def is_displayed(self): return self.participant.vars['treatment'] == 't_lr' def vars_for_template(self): #Questions for questionnaire questions = self.participant.vars['questions_aft_explain'] question_order = self.participant.vars['questions_aft_explain_order'] (num_questions, questionnaire_table) = composer_fc.buildLikertScale(questions, question_order) example_demand_data = [300, 400, 700, 500, 300, 400, 700, 800, 500, 400] self.player.questions_aft_explain_order = str(question_order) return{ 'total_number_products' : self.participant.vars['number_products'], 'questionnaire_1' : questionnaire_table, 'num_questions' : num_questions } form_model = 'player' form_fields = ['questions_aft_explain_answers'] page_sequence = [Algorithm_No_Explain, Algorithm_AV_Explain, Algorithm_NN_Explain, Algorithm_LR_Explain]