Welcome, Guest
Username: Password: Remember me

TOPIC: Hide questions?

Hide questions? 1 year 8 months ago #83890

  • kamelia
  • kamelia's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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.
The administrator has disabled public write access.

Aw: Hide questions? 1 year 8 months ago #83894

  • kamelia
  • kamelia's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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:

#answerSIDXGIDXQID {
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+.
The administrator has disabled public write access.

Re: Aw: Hide questions? 1 year 8 months ago #83895

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 81
  • Karma: 36
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.
The administrator has disabled public write access.

Re: Aw: Hide questions? 1 year 8 months ago #83896

  • kamelia
  • kamelia's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
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 (:
The administrator has disabled public write access.

Re: Aw: Hide questions? 1 year 8 months ago #83897

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 81
  • Karma: 36
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.
The administrator has disabled public write access.

Re: Aw: Hide questions? 1 year 8 months ago #83917

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
To hide the question with JavaScript (replace "QQ" with the question ID):
$('#questionQQ').hide();

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

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 1 year 8 months ago by tpartner.
The administrator has disabled public write access.

Re: Aw: Hide questions? 1 year 8 months ago #83932

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 81
  • Karma: 36
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.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.131 seconds
Donation Image