Qualtrics: javascript - text entry

ε祈祈猫儿з 提交于 2019-12-13 08:29:29

问题


I designed a Qualtrics survey which includes a text entry question. I used a form here and it contained 10 text entry boxes. I want participants to fill in at least 5 boxes (any 5 boxes out the 10 is okay). I don't think validation is a good idea because there are so many possible cases when you complete at least 5 text boxes out of 10. For every text box, both filling in it and not filling it are okay, as long as the total competed text boxes are no less than 5.

So I tried to do this through javascript. And here is my code but it cannot work. Please tell me how to change it. Thanks!!

Qualtrics.SurveyEngine.addOnload(function()
{

    //disables the next button on the page
    this.disableNextButton();

    var choicesID=this.getQuestionInfo().Choices.Key


    while (1)
    {
        var t=0
        for (var i=0;i<choicesID.length;i++)
        {
            choicetext=this.getTextValue(choicesID[i])
            if (choicetext.length != 0)
            {
                t=t+1
            }
        }

        if (t<=4) continue;
    }

    this.enableNextButton();
});

回答1:


Sorry to be the bearer of bad news, but you are way off. Your script has a number of errors, but the biggest problem is that it attempts to check how many have been answered when the question loads, which doesn't do you any good. You would need to keep an on-going count using an event listener.

I suggest an alternative approach that doesn't require any JavaScript or custom validation. Use a multiple choice, multiple select question with allow text entry / force response turned on for each answer option. Then just set the minimum number of answers to 5.



来源:https://stackoverflow.com/questions/43088231/qualtrics-javascript-text-entry

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