我想向参与者展示一个反馈页面,其中包含例如在他们刚刚完成的试验过程中检测到的点击次数。这是我想要做的:
class PracticeTrialMaker(StaticTrialMaker):
give_end_feedback_passed = True
performance_check_type = "performance"
performance_check_threshold = 0
end_performance_check_waits = True
def get_end_feedback_passed_page(self, score):
how_many_taps = "NA" if score is None else f"{(score):.0f}"
return InfoPage(
Markup(
f"You tapped <strong>{how_many_taps}% times;</strong>."
),
time_estimate=5,
)
def performance_check(self, experiment, participant, participant_trials):
# for now, just count number of taps detected
n_taps_detected = participant_trials.analysis['num_resp_raw_all']
failed = participant_trials.failed
return {"score": n_taps_detected, "passed": not failed}但我不知道如何找到/传递分析结果到performance_check……它们不包含在participant_trials或参与者或实验中,除非我完全遗漏了什么。
如何向参与者显示基于分析的反馈?
发布于 2021-10-28 18:43:38
方法get_end_feedback_passed_page在StaticTrialMaker结束时根据该试验生成器内所有试验的总体性能提供反馈。更准确地说,它仅在参与者成功达到性能阈值时显示反馈。
对于您的示例,我将在StaticTrial中使用show_feedback方法。这允许您在每个单独的试验之后提供反馈。然后,您可以通过调用试验中存储的分析输出(即self.details["analysis"] )来访问分析的输出(在方法analyze_recording中返回的字典)。以下是上下文中的一个示例:
class MyExperimentalTrial(StaticTrial):
__mapper_args__ = {"polymorphic_identity": "custom_trial"}
wait_for_feedback = True
def gives_feedback(self, experiment, participant):
return True
def show_feedback(self, experiment, participant):
output_analysis = self.details["analysis"]
if output_analysis["num_taps"] > 20:
return InfoPage(
Markup(
f"""
<h3>Excellent!</h3>
<hr>
We detected {output_analysis["num_taps"]} taps.
"""
),
time_estimate=5
)
else:
return InfoPage(
Markup(
f"""
<h3>VERY BAD...</h3>
"""
),
time_estimate=5
)请注意,您应该将其与gives_feedback结合使用,并在相应trialmaker check_performance_every_trial=False的定义中指定
https://stackoverflow.com/questions/69757413
复制相似问题