使用 javascript 在 Qualtrics 中记录随机选择的答案标签
Record answer label of the choice for randomization in Qualtrics using javascript
我正在 Qualtrics 中设计一项调查。每个问题都有多项选择答案,5个固定和8个随机,5个多项选择将是不变的,并一直呈现。我将在 8 个随机选择中仅抛出一个选择,以提供 5 个常量选择,因此将呈现的总多个选择为 6。最后,我需要在嵌入式数据字段中捕获与 8 个随机选择相关联的选项有 5 个固定选项。我找到了这段代码并且它工作完美但到目前为止它捕获了选择的 ID。但是,我需要捕获项目的标签名称而不是 ID。
//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);
您不需要 JavaScript。您可以将显示的选项通过管道传输到调查流程中的嵌入式变量中:
choiceorder = ${q://QIDxx/ChoiceGroup/DisplayedChoices}
我正在 Qualtrics 中设计一项调查。每个问题都有多项选择答案,5个固定和8个随机,5个多项选择将是不变的,并一直呈现。我将在 8 个随机选择中仅抛出一个选择,以提供 5 个常量选择,因此将呈现的总多个选择为 6。最后,我需要在嵌入式数据字段中捕获与 8 个随机选择相关联的选项有 5 个固定选项。我找到了这段代码并且它工作完美但到目前为止它捕获了选择的 ID。但是,我需要捕获项目的标签名称而不是 ID。
//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);
您不需要 JavaScript。您可以将显示的选项通过管道传输到调查流程中的嵌入式变量中:
choiceorder = ${q://QIDxx/ChoiceGroup/DisplayedChoices}