from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) from treatments import * from random import sample, shuffle author = 'Tommaso Batistoni - t.batistoni@ucl.ac.uk' doc = """ Implementation of Quadratic Voting as described in e.g. [CHOOSE REFERENCE] """ class Constants(BaseConstants): name_in_url = 'qvsr' players_per_group = None num_rounds = 1 # QV qv_questions = { 'general_a': ["The fight against global warming is a priority.", "Immigration quotas should be reduced.", "Artificial intelligence and new technologies are an opportunity for our" " societies", "In society, the most important decisions should be made by the" " population rather than by politicians.", "Homosexual couples must have the same rights as heterosexual couples.", "The use of pesticides should be more limited.", "Quotas for women in politics should be made universal.", "Pakistanis should have priority in employment over foreigners.", "The resources of surveillance and intelligence services should be increased.", "Music, dance, and theater should have a greater place in school.", "Those who so wish should be able to benefit from euthanasia."], 'general_b': ["The number of officials in civil service should be reduced.", "Greater social justice requires taxing the rich more and giving more to the most" " destitute.", "The power of GAFA (Google, Amazon, Facebook, and Apple) should be restrained.", "Reducing the national debt is a priority.", "The minimum wage should be reduced.", "Pakistan should encourage business creators.", "Income tax should be reduced.", "The government should do everything in its power to ensure that different" " social groups live in the same conditions.", "The government should increase investment in renewable energy.", "The salaries of business leaders should be more regulated."], 'promarket': ["The number of officials in civil service should be reduced.", "Reducing the national debt is a priority.", "The minimum wage should be reduced.", "Pakistan should encourage business creators.", "Income tax should be reduced."], 'proregulation': [ "Having a more just society requires taxing the rich more and giving more to the poor.", "The power of GAFA (Google, Amazon, Facebook, and Apple) should be curbed.", "The government should do everything in its power to ensure that different social groups" " live in the same conditions.", " The government should increase investment in renewable energy. ", " The salary of business leaders should be more regulated. "], 'proequality': [ "Greater social justice requires taxing the rich more and giving more to the poor.", "The minimum wage should be reduced.", "Income tax should be reduced.", "The government should do whatever it takes its power so that the different social groups " " live in the same conditions. "," The salary of business leaders should be more regulated. "], 'other': ["The number of civil servants should be reduced.", "The power of GAFA (Google, Amazon, Facebook, and Apple) should be limited.", "Reducing the national debt is a priority.", "Pakistan should encourage business creators. ", " The government should increase investment in renewable energy. "] } vote_credits = 100 class Subsession(BaseSubsession): def creating_session(self): for p in self.get_players(): # Treatment assignment. NB: only one treatment is actually implemented. p.quadratic_voting_version = next(treatments['qv']) if p.quadratic_voting_version == 'A': all_b = Constants.qv_questions['general_b'] set_a1 = sample(Constants.qv_questions['general_a'], 5) set_a2 = sample(all_b, 5) set_a = set_a1 + set_a2 shuffle(set_a) p.participant.vars['qv_questions'] = set_a class Group(BaseGroup): pass class Player(BasePlayer): quadratic_voting_version = models.StringField() quadratic_voting = models.StringField()