在 Qualtrics 中使用 Javascript 嵌入响应选项中的数据
我的目标是随机分配一个块中的 10 个项目,然后针对显示的最后一个项目提出一系列问题。我让 JS 适用于项目主干,但不适用于所选的响应选项。
我首先在调查开始时定义嵌入数据。
接下来,我为第一个块中的每个问题添加 JS。使用相同的嵌入名称标记它们会导致 Qualtrics 每次覆盖嵌入的数据,这意味着它将记住第一个块中显示的最后一个问题:
JS for Q1(注意它调用 QID1):
Qualtrics.SurveyEngine.addOnload(function()
{
var text = "${q://QID1/QuestionText}";
Qualtrics.SurveyEngine.setEmbeddedData( 'TestQuestion', text );
var answer = "${q://QID1/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData( "TestAnswer", answer );
});
JS for Q2(注意它调用 QID2):
Qualtrics.SurveyEngine.addOnload(function()
{
var text = "${q://QID2/QuestionText}";
Qualtrics.SurveyEngine.setEmbeddedData( 'TestQuestion', text );
var answer = "${q://QID2/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData( "TestAnswer", answer );
});
接下来,我调用问题中后续块中的嵌入数据:
但是,当我启动调查时,它仅显示 TestQuestion 元数据:
我做错了什么?如何获取要输入的响应选项(TestAnswer 嵌入数据)?是否应该将其添加到 JS 中的不同位置?
我也尝试过这个,但它不起作用:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{var answer = "${q://QID2/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData( "TestAnswer", answer );}
});
My goal is to randomize 10 items within a block, and then ask a series of questions about the last item displayed. I got JS to work for the item stem, but not for the response option that was selected.
I begin by defining the embedded data at the beginning of the survey.
Next, I add JS for each question in the first block. Labeling them with the same embedded name causes Qualtrics to overwrite the embedded data each time, which means that it will remember the last question displayed from the first block:
JS for Q1 (note that it calls QID1):
Qualtrics.SurveyEngine.addOnload(function()
{
var text = "${q://QID1/QuestionText}";
Qualtrics.SurveyEngine.setEmbeddedData( 'TestQuestion', text );
var answer = "${q://QID1/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData( "TestAnswer", answer );
});
JS for Q2 (note that it calls QID2):
Qualtrics.SurveyEngine.addOnload(function()
{
var text = "${q://QID2/QuestionText}";
Qualtrics.SurveyEngine.setEmbeddedData( 'TestQuestion', text );
var answer = "${q://QID2/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData( "TestAnswer", answer );
});
Next, I call the embedded data in the subsequent block in the questions:
However, when I launch the survey, it only displays the TestQuestion metadata:
What am I doing wrong? How can I get the response option (TestAnswer embedded data) to pipe in? Should it be added at a different spot in the JS?
I also tried this, but it didn't work:
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{var answer = "${q://QID2/ChoiceGroup/SelectedChoices}";
Qualtrics.SurveyEngine.setEmbeddedData( "TestAnswer", answer );}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论