问题
I have the code listed below. This was a code recommended by the Qualtrics support team before they updated their system. In this code, you remove the next button, and let the participants answer with key strokes,e.g. J or 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();
}
});
});
I also created a Embedded Data called 'choiceID' from the Survey Flow section. I can see this new column in my final results.
I want to send the response key information (J as choiceID=1 or K as choiceID=2) to the results as an embedded data?
I am working on integrating the code below, which does not seem to be working.
Qualtrics.SurveyEngine.setEmbeddedData("choiceID",choiceID);
回答1:
Here is the working version.
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();
}
});
});
回答2:
I don't think you need to implement embedded data to see, in the data file, the results of the key press (See It used to be possible to setChoiceValue in Qualtrics. Is there a workaround that does not involve embedded data? ). The following works for me.
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();
}
});
});
来源:https://stackoverflow.com/questions/42225935/in-qualtrics-how-to-save-a-key-response-into-an-embedded-data