使用3个按键来回答定性的问卷调查 [英] Using 3 KEYSTROKES to Answer Survey in Qualtrics

查看:121
本文介绍了使用3个按键来回答定性的问卷调查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jscript启用Qualtrics中的击键来回答问题.

I use Jscript to enable Keystrokes in Qualtrics to answer a question.

它与Qualtrics示例中提供的2个选项一起工作:

It works as with 2 options as provided in the example by Qualtrics: https://www.qualtrics.com/university/researchsuite/developer-tools/custom-programming/example-code-snippets/#ExampleJavaScript

我添加了第三个击键选项(按q),该选项不起作用:以某种方式注册了q的击键,但是它既不输入数据,也不像按j或k时那样进入下一个问题.请参阅下面的代码.任何建议表示赞赏-谢谢!

I added a third Keystroke option (press q) which is not working: somehow the keystroke for q is registered but neither does it enter the data nor proceed to the next question as is the case when pressing j or k. See code below. Any advise appreciated - thanks!

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place Your Javascript Below This Line*/


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;
    case 81: // 'q' was pressed
      choiceID = 5;
      break;
  }

  if (choiceID) {
    Event.stopObserving(document, 'keydown', keydownCallback);
    that.setChoiceValue(choiceID, true);
    that.clickNextButton();
  }
});


});
});

推荐答案

我不确定到底是什么问题.可能有一些不同的事情:

I'm not sure exactly what is wrong. A few different things it could be:

1)您上面的代码有一个额外的});在最后.但是,Qualtrics不允许您保存它,因此我认为这只是您上面帖子中的错字.

1) Your code above has an extra }); at the end. However, Qualtrics wouldn't let you save that, so I'm thinking it is just a typo in your post above.

2)如果您的choiceID错误并且打开了强制响应,则它将不会前进,并且您会收到一条错误消息.

2) If your choiceID is wrong and you have force response turned on, then it won't advance and you'll get an error message.

3)如果您处于JFE预览模式,则必须先将注意力集中在表单上,​​然后才能进行任何按键操作.

3) If you are in JFE preview mode, then you have to first get focus on the form before any keypress will work.

顺便说一句,这不适用于移动设备.

BTW, this won't work on mobile devices.

以下是一些清理过的代码,也可以解决问题(3):

Here is some cleaned up code that also fixes issue (3):

Qualtrics.SurveyEngine.addOnload(function()
{
    $('Buttons').hide();
    if(window.location.pathname.match(/^\/jfe[0-9]?\/preview/)) {
        $(this.questionId).select('input').first().focus();
    }   
    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;
            case 81: // 'q' was pressed
                choiceID = 5;
                break;
        }

        if (choiceID) {
            Event.stopObserving(document, 'keydown', keydownCallback);
            that.setChoiceValue(choiceID, true);
            $('NextButton').click();
        }
    });
});

这篇关于使用3个按键来回答定性的问卷调查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆