2017-08-29 47 views
0

我正在Qualtrics中設計一項調查。每個問題有多個選擇答案,5個固定的和8個隨機的,這5個多重選擇將是不變的,並且始終呈現。我將只從8個隨機選擇中選出一個選項,並用5個常量選項來呈現,因此總的多個選擇將呈現爲6.最後,我需要在嵌入數據字段中捕獲關於8個隨機選項的關聯有5個固定的選擇。我發現這個代碼,它工作完美但迄今它捕獲的選擇的ID。但是,我需要捕獲項目的標籤名稱而不是ID。在Qualtrics中使用javascript記錄隨機選擇的答案標籤

//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++) { 
 
\t choiceIDs.push(choices[i].id); 
 
\t \t 
 
} 
 
//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

你並不需要JavaScript的這一點。你可以只管顯示的選項進入調查流程嵌入式變量:

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

到目前爲止,並沒有對我的情況下工作,但是,我測試您的解決方案針對不同的情況和它的情況下正常工作所有選擇 - 顯示和隱藏。但我的調查邏輯是我有5個固定的顯示和8個隱藏的選擇。在設置高級隨機化過程中,我只將8個選項映射到(隨機子集字段),然後從這8個隱藏的選項中隨機插入1個選項和其他5個固定顯示的選項。最後,我有{1隨機子集} 5固定顯示選擇。這使得它向用戶顯示總共6個多個選項。 – Adam

+0

我明白你做了什麼。它適用於我,所以我認爲你做錯了一些事情:https://marketinview.qualtrics.com/jfe/preview/SV_9N9aUsktdodXhiZ?Q_CHL=preview –

+0

這是步驟: - 調查流程 - >添加一個新的字段 - > choiceorder->設置一個值現在 - >插入管道文本 - >調查問題 - > QID - >顯示的選擇 – Adam