我是一个完整的 javascript 初学者,所以真的需要帮助!我提出了一组名为advisorRating 的问题(如下所示),我希望序言以随机顺序在单独的页面上说“评价顾问A”和“评价顾问B”。
即在一个页面上给顾问 A 打分 -> 提交 -> 下一页要求给顾问 B 打分,反之亦然。
我还希望演示顺序平均分配(即 50% 时间 A 然后 B,反之亦然)
为此,我尝试了下面的代码,但它不起作用。有一段时间它只显示了顾问 B 两次,而现在它只显示了顾问 A 两次。
type: jsPsychSurveyLikert,
questions: [
{prompt: "How knowledgeable is this advisor?",
name: 'Knowledgeable',
labels: advisorLikertScale,
},
if (Math.random() < 0.5)
{
advisorRating.preamble = "Please rate Advisor A on the following questions";
timeline.push(advisorRating);
advisorRating.preamble = "Please rate Advisor B on the following questions";
timeline.push(advisorRating);
}
else
{
advisorRating.preamble = "Please rate Advisor B on the following questions";
timeline.push(advisorRating);
advisorRating.preamble = "Please rate Advisor A on the following questions";
timeline.push(advisorRating);
}
我尝试了不同的东西:
以不同方式定义顾问序言:advisorRating["preamble"]
首先定义advisorA 和advisorB 然后推送:
var advisorB = advisorRating
advisorA.preamble = "Please rate Advisor A on the following questions";
advisorB.preamble = "Please rate Advisor B on the following questions";
if (Math.random() < 0.5)
{
timeline.push(advisorRatingA, advisorRatingB);
}
else
{
timeline.push(advisorRatingB, advisorRatingA);
}
我想知道为什么这不起作用。然而,更重要的是,我想知道如何才能实现我最初的目标:在不同的页面上随机呈现指令。
谢谢你的帮助:)x