我试图让玩家选择跳过回合。
这是我当前的代码
模型.py
class Player(BasePlayer):
tran = models.BooleanField()
页面.py
class AddNumbers(Page):
def is_displayed(self):
return self.player.tran == 1
timeout_seconds = 30
form_model = "player"
form_fields = ["number_entered"]
def vars_for_template(self):
number_1 = random.randint(1, 10)
number_2 = random.randint(1, 10)
self.player.sum_of_of_numbers = number_1 + number_2
return {
"number_1": number_1,
"number_2": number_2,
}
def before_next_page(self):
if self.player.id_in_group == 1 or self.player.id_in_group == 2 or self.player.id_in_group == 3:
if self.player.sum_of_of_numbers == self.player.number_entered:
self.player.payoff = Constants.payment_per_correct_answer
else:
self.player.sum_of_of_numbers != self.player.number_entered
self.player.payoff = Constants.payment_round_control
else:
if self.player.sum_of_of_numbers == self.player.number_entered:
self.player.payoff = Constants.payment_per_correct_answer + Constants.payment_round_treatment
else:
if self.player.sum_of_of_numbers != self.player.number_entered:
self.player.payoff = Constants.payment_round_treatment
control100.html
{% block content %}
<p>You started the game with the following amount: <b> {{Constants.endowment_1}}. </b></p>
<p>This is your current payoff: <b> {{participant.payoff}} + {{Constants.endowment_1}}</p>
如果您成功解决问题,您将获得 5 英镑的报酬。如果您没有成功解决它或者您选择不解决简单的数学问题,您将不会获得报酬。
<div>
<button class="btn btn-primary btn-large" name = "tran" value= "True" >Solve a simple maths problem.</button>
 
 
 
 
 
<button class="btn btn-primary btn-large" name = "tran" value= "False" >Skip solving the simple maths problem.</button>
</div>
{% 端块 %}
还有一些其他代码,但通常发生的错误是tran = models.Boolean(default=0)
应该到位。但是,当我执行这样的代码时,两个按钮都会跳过下一轮(如果值为 False,我只想跳过这一轮。我想知道是否需要在某处编写脚本?
任何帮助将不胜感激。