from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Your name here' doc = """ Your app description """ def generate_question(n, k): tmp = [] for j in range(k): tmp.append([]) for i in range(n): expression = "" max1 = 0 max2 = -1 for m in range(1, 21): tmpint = random.randint(0, 99) expression += str(tmpint) if m % 5 != 0: expression += "\t" else: expression += "\n" if tmpint > max1: max2 = max1 max1 = tmpint elif tmpint > max2: max2 = tmpint tmp[j].append([expression, max1 + max2, 5]) return tmp class Constants(BaseConstants): name_in_url = 'exam' players_per_group = None num_questions = 60 test_repeat = 1 num_rounds = num_questions * (test_repeat + 2) section_time = 300 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): answer = models.IntegerField(blank=True) answer_correct = models.IntegerField() section_result = models.IntegerField() choice_1 = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "A"], [1, "B"], [2, "C"]]) choice_2 = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "A"], [1, "B"], [2, "C"]]) choice_3 = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "A"], [1, "B"], [2, "C"]]) choice_familiarity = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "熟悉"], [1, "不熟悉"]]) choice_difficulty = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "简单"], [1, "正常"], [2, "困难"]]) gender = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "男"], [1, "女"]]) knowledge = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "都了解"], [1, "了解平行志愿"], [2, "了解顺序志愿"], [3, "都不了解"]]) experience = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "平行志愿"], [1, "顺序志愿"], [2, "不清楚"]]) preference = models.IntegerField(widget=widgets.RadioSelectHorizontal, choices=[[0, "平行志愿"], [1, "顺序志愿"], [2, "其他制度"], [3, "不清楚"]])