使用javascript记录Qualtrics中随机选择的答案标签

时间:2017-08-29 17:32:05

标签: javascript qualtrics

我正在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);

1 个答案:

答案 0 :(得分:1)

您不需要JavaScript。您可以将显示的选项传输到调查流程中的嵌入变量中:

choiceorder = ${q://QIDxx/ChoiceGroup/DisplayedChoices}