在 Qualtrics 中使用 Javascript 嵌入响应选项中的数据

发布于 2025-01-10 03:47:32 字数 1800 浏览 0 评论 0原文

我的目标是随机分配一个块中的 10 个项目,然后针对显示的最后一个项目提出一系列问题。我让 JS 适用于项目主干,但不适用于所选的响应选项。

我首先在调查开始时定义嵌入数据。

输入图片description here

接下来,我为第一个块中的每个问题添加 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 元数据:

在此处输入图像描述< /a>

我做错了什么?如何获取要输入的响应选项(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.

enter image description here

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:

enter image description here

However, when I launch the survey, it only displays the TestQuestion metadata:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文