Check out the LimeSurvey source code on GitHub!

random question sets

More
5 years 2 months ago #70661 by jochem
Dear LimeSurvey users/developers,

I really like the random question sets workaround:
docs.limesurvey.org/Workarounds%3A+Survey+behaviour

However, I would like to display the questions in the set in a question by question format not group by group. Any suggestions?

warm regards,

Jochem

Please Log in to join the conversation.

More
5 years 2 months ago #70662 by Mazi
Can you link the certain workaround directly so we all know what you are referring to?

At the next (or even the current?) Limesurvey version there is a feature to randomize all questions of a certain group. Have a look at docs.limesurvey.org/Advanced+question+se...no_bl=y#random_group


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 2 months ago #70674 by jochem
Dear Mazi,

Here is the direct link:
docs.limesurvey.org/Workarounds%3A+Surve...Random_question_sets

I saw the page you refer to.

Here the problem will be that I do not want to randomize and show all questions one by one of a certain group but just a random set of the group one by one (e.g. 4 out of 10).

Please Log in to join the conversation.

More
5 years 2 months ago #70676 by Mazi
Sorry, but as stated at the workaround page, we can't give support for those workarounds. Your problem probably requires some custom coding.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
5 years 2 months ago #70692 by tpartner
You will not be able to accomplish this with JavaScript - it would require modifying the core code which I don't recommend.

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
5 years 2 months ago #70694 by jochem
Thank you for thinking along.

Suppose I would like to ask 4 random questions out of a set of 10 (question by question). I put my 10 questions in a group and copy this group 4 times.
I could now use random question sets to pick one random question for group 1.
I do the same for group 2, 3 and 4.

The obvious problem is of course that I could pick the same question, which I do not want. Could we set a cookie with the value of the question(s) we picked in the previous group(s) and check if the new value is different?

Please Log in to join the conversation.

More
5 years 2 months ago #70696 by tpartner
The random question sets workaround that you linked to will only work if all questions are on the same page.

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
5 years 2 months ago - 5 years 2 months ago #70697 by jochem
Thank you. I know.


But I copy my groups. I use the workaround in 4 different groups. (In my proposed 'solution' each groups contains the same ten questions. I pick one random question in each group.)

In your workaround you check if you already shuffled the questions:

// Check to see if the question order has already been shuffled in this session

var cookieArray = getCookie ( 'sArray' + gID + '_' + sessionName );
// If already shuffled, use that question order
if ( cookieArray ) {
//qArray = $.trim(cookieArray);
qArray = cookieArray.split(',');
}
// If not, go ahead and shuffle

So, if we now not only could check in Group 2 if there is a cookieArray set in Group 1 but also check if the first element of qArray of Group 2 is different than the first element of cookieArray it may work. (If the cookieArray has to be on the sampe page, we may need to fill a predefined question with the value of its first element.)

...unfortunately, I do not know php. But I guess you already figured that out.
Last Edit: 5 years 2 months ago by jochem.

Please Log in to join the conversation.

More
5 years 2 months ago - 5 years 2 months ago #70698 by tpartner
Ah, I see where you are going. But a problem is that the questions are identified by ID which would be different in each group.

Maybe a simpler way to deal with it would be to:

1) Create 4 groups, each containing all 10 questions as you suggest.

2) In every group, use JavaScript to add a class to all questions - Q1, Q2, Q3... That way all common questions in each group could be identified with a common class.

3) In every group, hide all questions, shuffle an array of all of the new question classes and then show the first class.

4) In every group, load a hidden question with the class of the displayed question. This could be used to show the same question if a respondent returns to the group and to prevent this question from being shown in subsequent groups.

5) In groups 2, 3, and 4, use {INSERTANS} to find the question classes previously shown and remove them from the array before shuffling.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 2 months ago by tpartner.

Please Log in to join the conversation.

More
5 years 2 months ago #70829 by jochem
Hi Tony,

Apologies for the late reply.

Great to hear that the logic might work. I am afraid that I need some more php knowledge/experience or examples from you how to make the necessarry steps.

But if i put all my items in different groups (one item per group) couldn't I also follow the procedure described here?

docs.limesurvey.org/Workarounds%3A+Surve...f_groups_in_a_survey

the crucial part for me is of course:
"
Note: If you wish to select only a limited number of groups from a larger set, replace
$scratcharr = array_merge($scratcharr, $randarr);
with
$scratcharr = array_merge($scratcharr, array_slice($randarr,0,x));
"

Okay, I tried but it only works if I use this trick once in a survey. (in fact I want to do it twice: ask 4 random questions of two different set of 10 questions).

see also:http://bugs.limesurvey.org/view.php?id=557

It looks like more people would like this option in limesurvey.

Please Log in to join the conversation.

More
5 years 2 months ago #70838 by tpartner
I can't speak to the workaround you mentioned in your last post other than to say I don't recommend hacking the core code.

If you attach a test survey I'll try to put together a sample of the code required.

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.

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