Allowing respondents to skip constant sum questions despite 'Must Total' validation

joshkahn21
joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭
edited July 14 in Custom Code

Hi,

At my organization, we ask a lot of constant sum questions, but we also want to let our respondents skip them when they don't have the relevant data. As of now, it seems impossible to allow respondents to skip questions when 'Must Total' is selected. I think it would be ideal if the 'Must Total' validation was "activated" AFTER respondents enter ANY data into one of the constant sum boxes. So, in effect, if respondents don't enter any data, they can skip it without triggering the validation rules.

The folks over at Product Ideas suggested I post the question here. Does anyone have the custom code to make this work? Thank you in advance - I'm a newbie with javascript!

Also, I have added this request/idea to the Product Ideas page, and I've asked if they can allow the validation to be changed to 'Request Response' at a minimum or, ideally, if they can "activate" the validation as described above.

If you think this should become a standard feature, please upvote it here: https://community.qualtrics.com/XMcommunity/discussion/16460/request-response-not-force-for-constant-sum-questions/p1?new=1

Thanks,

Dr. Josh Kahn

Best Answer

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭
    edited July 2 Accepted Answer

    It surprising that @ObjectiveFocus also asked this same question. While we wait for it to become a feature, here's a code you can use:

    Qualtrics.SurveyEngine.addOnReady(function () {
        let quest = this,
            qc = quest.questionContainer,
            id = quest.questionId,
            total_box = qc.querySelector("#" + id + "_Total");
        total_box.oninput = function () {
            quest.disableNextButton();
            if (total_box.value == 0 || total_box.value == 100) quest.enableNextButton();
        };
    });
    

    You can change the 0 or 100 values to whatever you want.


    NOTE: this will work with the constant sum question NOT with a matrix set up as a constant sum.

«1

Answers

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    So, you want to display the question, and allow them to skip it if they have not values to put in, right?

    I can't find a work around. Looks like the answer could be to allow multiple values in the validation of the total. like "0, 100" would validate against 0 (no answers) or 100 total.

    I'll give an upvote to your product idea.

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭

    Hi mklubeck, Yes, that's exactly what I am trying to do. I tried to set up validation so that if all fields were empty, then it would validate, but I couldn't get it to work. So you might be on to something with allowing multiple values to validate. Thanks for trying and for the upvote!

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    Thanks @ahmedA

    @joshkahn21 and @ObjectiveFocus please let us know if it works!

    BTW, it's not surprising to me at all. It's a solid need so I would expect a lot of people to run into the issue. Thanks for the solution @ahmedA !

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    @mklubeck Now that you mention it, this does seem like pretty standard requirement. And when I think about it, there have been multiple surveys where I've used a screener question with display logic to accomplish this. Just didn't realize I could do it at once. Thanks.

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭
    edited July 6

    Hi @ahmedA, Thank you for your time and the code! Unfortunately, I must be doing something wrong, but I can't get it to work. When I try to advance to the next page, I get an error that I need to total the options to 100. I've tested it both in preview and after publishing the survey. I copy/pasted the code directly into the javascript code editor as in the pic posted below. Was I supposed to adjust anything? I also tried it in the code area for when the page loads, but I got the same error.

    Again, many thanks for your time and code!

    Josh


  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    Remove your validation.

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭

    Yes, thank you - That was it! I had to remove the regular validation that I set up with the question originally. Thank you so much for your help!!

    Best Wishes,

    josh

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    @ahmedA Very nice code! Thanks. I'm not in need of it at this time, but I added it to my Question Library for my users.

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    @ahmedA quick question - for the quest.enableNextButton() functionality, can you help me with a simple javascript? i want to "disable" the Next Button if Question A is displayed (it has display logic), and I want to "enable" it if Question B is displayed. Only one, A or B would be displayed. So I'm assuming for each question, I can set the value to enable or disable...but I want it to do so "if displayed."

    Is this easy or am I asking for too much?

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    @mklubeck could you please ask a new question, since this isn't related to the topic being discussed. This will help others who are looking for the same solution.

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭

    Hi @ahmedA , I hate to open this back up, but I am about to run a new survey next week and I just tested the code again and it doesn't seem to be working. Which, i know, is weird because i just copied the question to the new survey, and I also wrote a new question and copied the javascript code. Tried both ways, both ways don't work. There is no error message that pops up after trying to go the next page when the totals are anywhere between 1 and 99. It just lets the person advance. I went back to the original spot where it worked and now it doesn't give the error message there either. Any thoughts? I doubt anything changed on qualtrics' end. Thank you again for helping me work through this!

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    @joshkahn21

    I'm far from a "coder" but have noticed issues with javascript in the past. One being that my date widget wouldn't allow two in the same survey. The second wouldn't work. BUT before you check on that, I have to ask if you tried the regular fix...did you clear your cache and cookies?

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭

    I did not clear cookies or cache. will try that next. But i've had two people from separate computers test it and they found the same as me. If my respondents all have to clear cookies/cache for it to work, then that's not going to be a great fix.

  • mklubeck
    mklubeck South Bend, IndianaCommunity Member, Qualtrics Brand Admin Sage ✭✭✭

    @joshkahn21 I was hoping for a simple fix...but if it's not that, and not that the JS is causing a change throughout that won't allow a second, grrr. it may not be simple? hopefully you'll hear back from @ahmedA

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    If it's still working on the earlier question, then it implies that the problem is with the implementation and not with code/Qualtrics.

    Do you have some other JS in the header/other question on the page? They maybe interfering with code.

    I'll be able to comment more on it if you are able to share the preview link/QSF of the survey page.

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭

    It is not still working on the earlier question. It took me a bit before I went back and tested the earlier one because I couldn't believe it.

    I set that earlier one up as a test. with one question in front of it, one after it, and the constant sum question in the middle. Happy to provide whatever you'd need, but here's the preview link for that test: https://nace.iad1.qualtrics.com/jfe/preview/SV_3CKHJUuEnLobhEa?Q_CHL=preview&Q_SurveyVersionID=current

    Thanks,

    josh

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭
    edited July 20

    There is a placement issue. Delete everything in your JS editor and just keep the code that I posted earlier, it should work.

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    I just saw your screenshot properly, do the same thing for the previous survey also.

  • joshkahn21
    joshkahn21 Pennsylvania, USACommunity Member, Qualtrics Brand Admin Qubie ✭

    I tried a fresh new survey. new item. pasted it into the part that should run when page is loaded, tried that as is. then tried deleting everything in the JS editor except your code. still didn't work. Does the code work for you when you test it?