Welcome to the LimeSurvey Community Forum

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

fill ranking array with answers from previous question

More
12 years 6 months ago #65931 by stigchelg
I'll try and create a sample survey.

I'm not sure what you mean be firing the auto-checks.

The multiops is on the same page as the rank, but it is listed first. You would encounter it first if it wasn't hidden (which it isn't, yet).

The whole spiel takes place on page 5 though. Does that matter? I noticed a prefpage ==1 somewhere in the long script. Does that refer to the very first page of the survey or to the first previous page?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 6 months ago #65935 by tpartner

I'm not sure what you mean be firing the auto-checks.

I mean running the code that automatically checks the boxes in the multi-opts.

I noticed a prefpage ==1 somewhere in the long script.

We don't need to worry about that. It is only for a multi-opts that has an array filter from a question on a previous page. Your multi-opts is not (I believe).

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
12 years 6 months ago #65963 by stigchelg
Rightio. I made a test survey and now it works. So the script that I pasted into the template works just fine and the small script I pasted into the ranking question works fine too.

The problem therefore is in the question groups that preceed it. I'm using script to add the answers from page 1, page 2 and page 3 to a separate cookie and on page 4 a script that calls for these cookies and prefills a multi ops question from them. This works. I then on page five made another multiops question that uses the prefilled one on page 4 as an array filter. The ranking question with the small script is on the same page as the array filtered multiops. When I test the survey the answers from p1,2 and 3 come together nicely on page 4. The prefill to page 5 also works. But the ranking question just won't fill.

I'm thinking I should just start over and see where that takes me.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 6 months ago #65974 by tpartner
Oh, wait...

The prefill to page 5 also works. But the ranking question just won't fill.


The prefill works or the filter works?

If you have a filter question on a previous page you need to indicate that in the function call:

rankFilter(245, 264, 1);

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
12 years 6 months ago #65979 by stigchelg
I noticed that before and I've tried it. No luck.
I think with all the tinkering I messed up something else somewhere. I have a working test survey now, so I know how it works and how to implement it properly. I'm just gonna expand from there and see if I can make it work that way.

You have been invaluable so far. Many many thanks. I have a much better grasp on javascript now.

I'll chime in again when I have something new.
The topic has been locked.
More
12 years 6 months ago - 12 years 6 months ago #65984 by stigchelg
WOOHOO SUCCESSSSSS!!!

Well partly anyway.

I started from scratch and now I have a working construct.

3 multiple options quesions that collect their anwers into one collection question. This collecting then serves as the source of the filter array that fills the ranking question.

A new problem arises though. The collection question, the source for the filter array and the filter array itself are obviously for technical reasons only. I had thought to hide them onces the whole thing is done. However when I hide either one of these, the construct stops working. If I hide the collection question, the source question won't prefill so the filter array filters nothing and the ranking question is filled with all possible options.

In short, how do I hide questions from the viewer, but still make them available for filtering and such?
Last edit: 12 years 6 months ago by stigchelg.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 6 months ago #65988 by tpartner
If you hide them with JavaScript the code should work. In fact, the code is already set to hide the multi-opt on the same page as the ranking:
Code:
if(prevPage == 1) {
$('#question'+q1ID+' li[id^="javatbd"]:visible input.checkbox').attr('checked', true);
$('#question'+q1ID+'').hide();
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
12 years 6 months ago #65997 by stigchelg
Ok, I'll give that a go.

Can the script be adapted to read from 3 source questions on 3 different pages instead of just 1? I'm thinking it probably can, but will that require a complete rewrite or do I simply add a q2ID and a q3ID whereever I see the q1ID marker pop up? That way I eliminate the need for hiding questions alltogether.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
12 years 6 months ago #66001 by tpartner

Can the script be adapted to read from 3 source questions on 3 different pages

That should be possible - you would need to use {INSERTANS} (or cookies) to retrieve the previous answers and then check the appropriate boxes in the multi-opt on page 5.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
12 years 6 months ago #66027 by stigchelg
Hmm. Ok. That's just a little above my head. No matter. Hiding the questions is fine. However, when I hide the questions I don't need with
<script> $(document).ready(function() { $('#question4444').hide(); });</script>
where I replace question4444 with the ID of the actual question. This hides the question just fine, but now I'm left with an empty page to click through. Any way to fix that?
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
12 years 6 months ago #66034 by Mazi
You could either switch to group-by-group or all-in-one survey mode or add another line of JS code if you are using question-by-question format. That code could click the "next" button so the hidden question would be skipped automatically.

See docs.limesurvey.org/Workarounds%3A+Manip...ing_the_welcome_page for example.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
12 years 6 months ago #66057 by stigchelg
Hmm, ok I tried this and it does work as describe only that page flash is a bit strange even with a fake loading text. Surely there is a more elegant solution.

This may be the stupid question of the week, but why can't I just route past these questions? When question 3 has been answers, skip straight to question 5.

Oh and even though the construct works now, I'm still having trouble. I can only get it to prefill from a question on the same page. When I change it with the ID of the question on the previous page and add ", 1" to the small script, It doesn't work.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose