Check out the LimeSurvey source code on GitHub!

Hide questions?

4 years 5 months ago #83890 by kamelia
I've got a question with javascript in the source. I want to hide it, but the javascript option $('#questionXX').hide(); doesn't work. I use Limesurvey 1.92+.
When using "always hide this question" option the answer to the hidden question doesn't appear -- and I've already read about it. The problem is that I have to hide my "hidden question" so that the users don't manipulate with it.
Are there any solutions to my problem? I've read about adding some lines to template.css but I don't know which file to edit (the one I've tried didn't work)... Please help me.

Please Log in to join the conversation.

4 years 5 months ago #83894 by kamelia
Allright, now it's not "life-or-death" problem, I managed to hide the answer of my crucial question. It's better than nothing, because the code works, it can be sent into another question and the user can't destroy it (;.

I've put into the template.css that is used in my survey those lines:

display: none;

I've tried to replace "answer" with "question" but the question still appeared.

Anyway, I'm still curious whether hiding a question can be obtained in lime 1.92+.

Please Log in to join the conversation.

4 years 5 months ago #83895 by TMSWhite
What are you really trying to do?

(1) Hide a calculation so it can't be manipulated? If so, put it in the group following the questions upon which it is based, and use a hidden Equation question. If the group only contains hidden questions, they are never displayed client-side, so the user has not ability to know or manipulate them.
(2) something else - if so, please clarify.

Please Log in to join the conversation.

4 years 5 months ago #83896 by kamelia
In fact I don't think it could be fixed with hidden equation (I've tried with no satisfying results).
I've got a multiple choice question and supposing someone chose one of the nonexcluding options in the hidden question I run a script randomly picking up one of the options. The answer from hidden question is later used in another question.
Javascript works perfectly, it chooses one option but it can be sent further only if the question is visible.
In fact, when I think about the people I will give my survey to they are likely to manipulate the output if they see that something interesting has become visible (; (and the warning "please don't change it" seems to be an invitation to do so (; ). The option in javascript I mentioned didn't work (and I've read that it's not a sufficient one) so I've tried to hide that via css.
I don't know whether it can be obtained through EM or hidden equation. It's filtered by users' choices so it seemed to me that javascript would be less complicated than thinking about all of the possible conditions.
Thank you for the response, anyway (:

Please Log in to join the conversation.

4 years 5 months ago #83897 by TMSWhite
OK, there are a couple of ways to tackle you need:
(1) Create an empty hidden equation on the page, and use JavaScript to populate its value. Equations are special - they always save their values even if hidden. If users use show source to see the JavaScript, they might be able to figure out what you are doing, but otherwise you are fine (since nothing will show on the screen)

(2) Use an Equation question type and find a way to use EM to do the random selection.

Given that you already have the working JavaScript, I'd take that approach.

Please Log in to join the conversation.

4 years 5 months ago - 4 years 5 months ago #83917 by tpartner
To hide the question with JavaScript (replace "QQ" with the question ID ):

To hide the question with CSS, add this to template.css (replace "QQ" with the question ID ):
#answerQQ {
	display: none;

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.

Please Log in to join the conversation.

4 years 5 months ago #83932 by TMSWhite
With EM, it's not quite that simple. Every time an answer changes that might affect the contents or visibility of a non-hidden question, EM updates that questions, making it visible or invisible as needed. So, if you try to use JavaScript or CSS to over-ride what EM is doing, the last one to run will 'win', in which case you may find that your JavaScript and/or CSS doesn't seem to work (e.g. if EM runs last).

For questions that are flagged as 'always-hidden', EM won't re-hide them. However, if they are not always hidden, EM will always try to manage the visibility of the question using the relevance and/or array filter equations.

So, rather than trying to over-ride the EM behavior with JavaScript and/or CSS, it may be easier to maintain your survey if you let EM do what it was designed to do, and use hidden Equation question types to store the value.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form