【问题标题】:Record answer randomization in Qualtrics using javascript使用 javascript 在 Qualtrics 中记录答案随机化
【发布时间】:2015-01-11 12:50:58
【问题描述】:

我正在 Qualtrics 进行一项调查。该调查有一个重复的问题,有六个答案选项。这六个选项是随机的(以标准方式,没有 javascript)。问题正在使用 loop&merge 重复,效果很好,因为它一遍又一遍地使用相同的问题结构(36 次),但我可以使用字段函数来调整每次迭代的问题和答案。

但是,我遇到的一个问题是 Qualtrics 不(作为标准)支持在结果中记录随机化数据 - 即它如何在每次迭代中随机化六个答案选择。当我在下载结果时使用“导出随机查看顺序数据”功能时,它只显示最后一次提问的答案顺序。所以看起来这是一个在每次迭代后都会被覆盖的值。

所以现在我希望通过 javascript 记录每次迭代的答案顺序。但是,我还没有找到给出订单答案的函数(随机化后)。我咨询了Qualtrics javascript API,发现了一些看起来很有希望的函数,比如getChoices(),但是当我尝试这个时,我得到的只是没有随机化的答案顺序(即只有1、2、3、4、5, 6).

有谁知道使用javascript或其他方式记录每次迭代的随机选择顺序的方法吗?

【问题讨论】:

    标签: javascript qualtrics


    【解决方案1】:

    found用另一种方式记录循环和合并随机化顺序。

    1. 在调查流程中创建嵌入式数据字段。这里我们将记录随机化顺序。我将调用该字段 rand_order。
    2. 添加带有唯一编号的循环和合并字段以标识每个循环(例如 1、2、3、4、5、...、n)。

    然后将下一个javascript添加到循环块的任何页面。

    //*Place Your Javascript Below This Line*/
       var questionText = "${lm://Field/1}"; // "${lm://Field/1}" will actually evaluate to  
       //whatever is Field 1 in the current Loop & Merge loop.
       // You can do this with embedded data too, as seen in the next line
       var order = "${e://Field/rand_order}" + "|" + questionText; // gets the value of the embedded data
       // field "rand_order", concatenates the current loop's identifier to it, 
      //and stores that as a variable
       Qualtrics.SurveyEngine.setEmbeddedData('rand_order', order); // updates the  
       //embeddeddata field "rand_order" to be our order variable, which has the current loop's 
       //identifier attached, effectively constructing a string of numbers representing the order
    

    您将得到一个名为“rand_order”的列,其中填充了“1|5|23|2...|n”。您可以更改分隔符以使其与您用于处理数据的任何脚本更加兼容。

    【讨论】:

      【解决方案2】:

      Qualtrics 已经为您记录了这些信息。这只是在下载数据时明确要求的问题。 this page 上的第 5 号有更多信息,但我会重述重要的部分:

      1. 在“数据和分析”选项卡中,单击“导出和导入”,然后单击“导出数据”。
      2. 在“下载数据表”窗口中点击“更多选项”。
      3. 选中“导出随机调查的查看订单数据”复选框。

      【讨论】:

      • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
      • @FedericoGrandi,这是一个很好的观点,谢谢。我已经相应地编辑了答案。
      【解决方案3】:

      我认为这里的问题是查看 DOM 中的选择顺序。 Qualtrics 提供getChoiceContainer() 方法来获取包含选项的div。这是我编写并经过最低限度测试的 sn-p:

      //get the div containing the choices, then get all input child elements of that div
      var choices = this.getChoiceContainer().getElementsByTagName("input");
      //initialize an array for the IDs of the choices
      var choiceIDs = []
      //add the ID of each choice to the array
      for (var i=0; i < choices.length; i++) {
      	choiceIDs.push(choices[i].id);
      		
      }
      //get the current choice order from embedded data and add this loop to it.
      //Add a | to distinguish between loops.
      var choiceOrder = "${e://field/choiceorder}" + choiceIDs.toString() + "|";
      //set the embedded data with the new value
      Qualtrics.SurveyEngine.setEmbeddedData("choiceorder", choiceOrder);

      一些注意事项/注意事项: 我只在带有单选按钮的基本多项选择问题上对此进行了测试。它可能需要针对不同的问题类型进行调整。

      我也刚刚获得了问题选择的 ID。您可能很容易修改它以获取其他信息,例如选择的标签或它对应的数值。

      【讨论】:

      • 感谢一百万,完美!我添加了几行来删除你得到的所有额外字符: var str = choiceIDs.toString(); str = str.replace(/QR~/g, ""); str = str.replace(/QID163~/g, "");(/code&gt;
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多