"""Define additional oTree widgets created for this project.""" from otree import widgets import numpy as np class LikertWidget(widgets.RadioSelectHorizontal): template_name = 'global/LikertWidget.html' def simulate_values(templates, views, models): """For all fields in these forms, simulate values from a specified distribution within a range given by the particular field. """ for i, template in zip(range(1, len(templates)), templates): sim_values = {} fields = getattr(views, template).form_fields print(fields) first = models.Constants.SCALE[0] last = models.Constants.SCALE[-1] print(first, last) for field in fields: sim_values[field] = np.random.randint(first, last + 1) yield (getattr(views, template), sim_values)