fill ranking array with answers from previous question

More
6 years 1 month ago #65931 by stigchelg
stigchelg replied the topic: fill ranking array with answers from previous question
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?

Please Log in to join the conversation.

More
6 years 1 month ago #65935 by tpartner
tpartner replied the topic: fill ranking array with answers from previous question

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.

Please Log in to join the conversation.

More
6 years 1 month ago #65963 by stigchelg
stigchelg replied the topic: fill ranking array with answers from previous question
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.

Please Log in to join the conversation.

More
6 years 1 month ago #65974 by tpartner
tpartner replied the topic: fill ranking array with answers from previous question
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.

Please Log in to join the conversation.

More
6 years 1 month ago #65979 by stigchelg
stigchelg replied the topic: fill ranking array with answers from previous question
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.

Please Log in to join the conversation.

More
6 years 1 month ago - 6 years 1 month ago #65984 by stigchelg
stigchelg replied the topic: fill ranking array with answers from previous question
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: 6 years 1 month ago by stigchelg.

Please Log in to join the conversation.

More
6 years 1 month ago #65988 by tpartner
tpartner replied the topic: fill ranking array with answers from previous question
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:
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.

Please Log in to join the conversation.

More
6 years 1 month ago #65997 by stigchelg
stigchelg replied the topic: fill ranking array with answers from previous question
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.

Please Log in to join the conversation.

More
6 years 1 month ago #66001 by tpartner
tpartner replied the topic: fill ranking array with answers from previous question

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.

Please Log in to join the conversation.

More
6 years 1 month ago #66027 by stigchelg
stigchelg replied the topic: fill ranking array with answers from previous question
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?

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now