It used to be possible to setChoiceValue in Qualtrics. Is there a workaround that does not involve embedded data?

为君一笑 提交于 2019-12-20 05:38:27

问题


It used to be possible to use the setChoiceValue method in Qualtrics to have key-presses trigger the selection of a particular option withing a multiple choice question. In fact one could even see the radio-button being "clicked" as a result of pressing a given key on the keyboard. This is no longer the case, apparently due to recent changes in Qualtrics. (An inspection of the resulting Qualtrics data file reveals that no choice value was set.) One suggested workaround has been to write embedded data that indicates the selected choice, instead of the choice actually being selected by setChoiceValue. However, that workaround does not work in the circumstance where the question is inside a loop-and-merge block with randomly ordered loop elements (since the choice selections need to be matchable, later on, to corresponding elements within the loop). So my question is, is there a way to have javascript simulate the clicking of a radio button, in the Qualtrics question, without relying on the apparently-broken setChoiceValue method?

EDIT 1/30/2018 -- ANSWER TO MY OWN QUESTION (it's here now since someone deleted it after I added it, below). ". . . here's what I've found. The script works fine whether it uses addOnload or addOnReady. But what does happen, sometimes, is that Qualtrics 'question' becomes altered so that the choice identifiers are no longer as expected. Even changing the question to a descriptive text type question, and then changing it back to multiple choice (so as to re-create Qualtrics's default choices), doesn't necessarily fix the problem with the identifiers. Creating a new block and a new question, from scratch, does fix the problem."

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();
  }
});
});

回答1:


setChoiceValue works just fine. In fact, your script will work just fine if you change addOnload to addOnReady.

The change to Qualtrics has to do with timing and when the buttons are available. With addOnload your script is trying to hide the buttons before they are available which halts the script due a JS error.




回答2:


Thanks! However, here's what I've found:

The script works fine whether it uses addOnload or addOnReady. But what does happen, sometimes, is that Qualtrics 'question' becomes altered so that the choice identifiers are no longer as expected. Even changing the question to a descriptive text type question, and then changing it back to multiple choice (so as to re-create Qualtrics's default choices), doesn't necessarily fix the problem with the identifiers. Creating a new block and a new question, from scratch, does fix the problem.



来源:https://stackoverflow.com/questions/48352749/it-used-to-be-possible-to-setchoicevalue-in-qualtrics-is-there-a-workaround-tha

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!