Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Mandatory questions

  • LarryMartell
  • LarryMartell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 5 months ago #190592 by LarryMartell
Mandatory questions was created by LarryMartell
I have a survey with some mandatory questions. When the answers are provided for them and the survey is submitted I get the message 'One or more mandatory questions have not been answered. You cannot proceed until these have been completed.' but the database is updated with the answers. When I click OK to that dialog the page is positioned at the top, whereas if I leave out an answer to a mandatory question the page is positioned at the question without the answer. If I click submit a second time the survey is accepted.

Any ideas on how I can fix or debug this?

I am running Version 2.73.1+171220

Thanks.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #190606 by tpartner
Replied by tpartner on topic Mandatory questions
Can you attach a sample survey (.lss file) here?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • LarryMartell
  • LarryMartell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 5 months ago #190607 by LarryMartell
Replied by LarryMartell on topic Mandatory questions
Unfortunately, this survey uses custom JS and python code, so I cannot send it. I've done more debugging and found some interesting things. When we make a question mandatory it does not show on the page at all. So someone modified our JS code to explicitly show() those DOM elements. I think whatever reason lime has for not showing those questions is the same reason it does not pick up the answers for them. Showing the element in JS makes it appear, but does not 'fix' lime and make it pick up the answer. But some other piece of lime code does pick up the answer because the data ends up in the DB.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago #190611 by tpartner
Replied by tpartner on topic Mandatory questions

When we make a question mandatory it does not show on the page at all. So someone modified our JS code to explicitly show() those DOM elements.

Although I don't know how this could be connected to "mandatory", this sounds like a relevance problem to me. You cannot simply override relevance by forcing the question to appear - if a question is irrelevant it will not be recorded regardless of visibility.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • LarryMartell
  • LarryMartell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 5 months ago #190619 by LarryMartell
Replied by LarryMartell on topic Mandatory questions
Thanks for that reply. That is indeed the issue. The relevance is set based on the existence of answers to other questions, but those answers are set by JS code after the page is rendered. Looks like the only solution is for me to enforce the mandatory-ness myself in my JS code.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago - 4 years 5 months ago #190623 by tpartner
Replied by tpartner on topic Mandatory questions
I don't understand the problem. If you have JS which sets answers which then render other questions irrelevant, shouldn't those other questions be skipped and therefor not recorded?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 5 months ago by tpartner.
The topic has been locked.
  • LarryMartell
  • LarryMartell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 5 months ago #190625 by LarryMartell
Replied by LarryMartell on topic Mandatory questions
The answers set by the JS code make the other questions relevant.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 5 months ago - 4 years 5 months ago #190627 by tpartner
Replied by tpartner on topic Mandatory questions
Okay, in that case, you need to fire Expression Manager after setting the question.

How to do that depends the question type and LS version.

With text questions triggering a change or keyup event should work. With checkboxes, trigger a change event. With radios, trigger a click event.

Search the forums for "fire Expression Manager". I have contributed many examples.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 5 months ago by tpartner.
The topic has been locked.
  • LarryMartell
  • LarryMartell's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
4 years 5 months ago #190628 by LarryMartell
Replied by LarryMartell on topic Mandatory questions
Thanks. I have already implemented the enforcement of the mandatory questions in my JS code. But this is good to know and I may someday go back and change it.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose