我有下面列出的代码。这是Qualtrics支持团队在更新系统之前推荐的代码。在此代码中,您删除下一个按钮,让参与者用键击回答,例如。 J或K.
Qualtrics.SurveyEngine.addOnload(function()
{
this.hideNextButton();
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 74: // 'j' was pressed
choiceID = 1;
break;
case 75: // 'k' was pressed
choiceID = 2;
break;
}
if (choiceID) {
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
that.clickNextButton();
}
});
});
我还从Survey Flow部分创建了一个名为'choiceID'的嵌入数据。我可以在最终结果中看到这个新专栏。
我想将响应密钥信息(J as choiceID = 1或K as choiceID = 2)作为嵌入数据发送给结果?
我正在努力整合下面的代码,这似乎不起作用。
Qualtrics.SurveyEngine.setEmbeddedData("choiceID",choiceID);
答案 0 :(得分:1)
这是工作版本。
Qualtrics.SurveyEngine.addOnload(function()
{
this.hideNextButton();
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 74: // 'j' was pressed
choiceID = 1;
break;
case 75: // 'k' was pressed
choiceID = 2;
break;
}
if (choiceID) {
Qualtrics.SurveyEngine.setEmbeddedData("choiceID",choiceID);
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
that.clickNextButton();
}
});
});
答案 1 :(得分:0)
我认为您不需要实施嵌入数据,以便在数据文件中查看按键结果(请参阅It used to be possible to setChoiceValue in Qualtrics. Is there a workaround that does not involve embedded data?)。以下适用于我。
Qualtrics.SurveyEngine.addOnload(function()
{
this.hideNextButton();
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 74: // 'j' was pressed
choiceID = 1;
break;
case 75: // 'k' was pressed
choiceID = 2;
break;
}
if (choiceID) {
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
that.clickNextButton();
}
});
});