Welcome to the LimeSurvey Community Forum

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

Prefilling answer with listbox / checkboxes questions types

  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #161955 by simogeo
Hi all,


I'm using limesurvey and try to prefill answer by passing arguments in URL.
It is ok with text or date questions types but I'm facing issues when prefilling listbox or checkboxes ....

Could somebody point me the right way to do so ?



Here is my url (displayed at the end of the survey) :
Code:
http://mydomainname.tld/index.php?r=survey/index&sid=646543&lang=fr&newtest;=Y&e2={INSERTANS:558129X5X40}&e1={INSERTANS:558129X5X41}&e3={INSERTANS:558129X5X58}&e4={INSERTANS:558129X5X54}&e5={INSERTANS:558129X5X59}&calid={SAVEDID}

Thanks for your reply,
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #161962 by tpartner
Well, it's impossible for us to answer that without knowing the structure of your survey.
I would use Expression Manager variables instead if INSERTANS.

So, for a select-radio question it might look like this, where the value passed is the answer code to question code Q1 (not the answer text).
Code:
http://example.com?param1=Q1

And, it would look like this when passing the results of a multiple-choice code Q1, subquestion code SQ001 (the passed value will be "Y" or nothing).
Code:
http://example.com?param1=Q1_SQ001

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #161963 by tpartner
Having said that, you refer to prefilling but your URL does not look like a valid survey URL anyway.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: simogeo
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #161974 by simogeo

tpartner wrote: Well, it's impossible for us to answer that without knowing the structure of your survey.
I would use Expression Manager variables instead if INSERTANS.

So, for a select-radio question it might look like this, where the value passed is the answer code to question code Q1 (not the answer text).

Code:
http://example.com?param1=Q1


Interesting (but still it works with INSERTANS).

I also have to say that the new survey I'm passing variables to is not the same I just filled up.
I'll try this tomorrow. (It works passing data on same survey)

tpartner wrote: And, it would look like this when passing the results of a multiple-choice code Q1, subquestion code SQ001 (the passed value will be "Y" or nothing).

Code:
http://example.com?param1=Q1_SQ001


Since I don't know which one is checked, that's mean I need to pass all values I guess. I've tried this with no success :
Code:
index.php?r=survey/index&sid=747676&newtest=Y&lang=fr&q2={q2}&q3_SQ001={q3_SQ001}&q3_SQ002={q3_SQ002}&q3_SQ003={q3_SQ003}

Any clue ?

By the way, could you tell me why is my (previous) URL not valid ?

Thanks again
The topic has been locked.
More
6 years 3 months ago #161978 by jelo
Code:
r=survey/index&sid=646543&lang=fr&newtest;=Y
E.g. &newtest;=Y was an eyecatcher. In you second URL you no longer have that ";".
r=survey/index looks strange too. What is r?


INSERTANS works but changes with every copy of the survey (surveyid changes). So it is better to use variables which are unchanged when copying the survey.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #161990 by simogeo
Thanks jelo. The advantage of using variables is now obvious to me ! Prefilling a listbox works perfectly.

Regarding the URL, the semicolon is still there. I just forgot it when typing ... THe URL is now like this :
Code:
index.php?r=survey/index&sid=646543&lang=fr&newtest;=Y&e1={e1}&e2={e2}&e3={e3}&e4={e4}&e5={e5}&calid={calid}

the 'r=survey' parameter/value is the default way LS works without URL rewriting I guess ...


Testing a bit more , I'm able to prefill checkboxes with the following syntax :
Code:
index.php?r=survey/index&sid=747676&newtest=Y&lang=fr&q2={q2}&747676X1X545SQ001={q3_SQ001}&747676X1X545SQ002={q3_SQ002}&747676X1X545SQ003={q3_SQ003}

but this is not confortable since it hardcodes SGQA identifier. I've tried the following with no success :
Code:
index.php?r=survey/index&sid=747676&newtest=Y&lang=fr&q2={q2}&q3SQ001={q3_SQ001}&q3SQ002={q3_SQ002}&q3SQ003={q3_SQ003}

Is there a way to do it without SGQA identifier ? Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago - 6 years 3 months ago #161996 by tpartner
It seems to me that you are missing underscores in your variable names.

Code:
index.php?r=survey/index&sid=747676&newtest=Y&lang=fr&q2={q2}&q3_SQ001={q3_SQ001}&q3_SQ002={q3_SQ002}&q3_SQ003={q3_SQ003}

If this does not work, please provide a SMALL test survey.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 3 months ago by tpartner.
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #161997 by simogeo
I tried already but it does not work.

Here is a survey sample !

Thanks for your support
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 3 months ago #161998 by tpartner
I can reproduce the problem and would say that it is a bug. Please report it - bugs.limesurvey.org/my_view_page.php

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • simogeo
  • simogeo's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 3 months ago #162007 by simogeo
Just did it : bugs.limesurvey.org/view.php?id=13098

Thanks again for the support
The topic has been locked.
More
6 years 3 months ago #162011 by jelo
You entered the MySQL client library version (libmysql - mysqlnd 5.0.12-dev - 20150407) instead of the MySQL version. 5.0 wouldn't work ;-)

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose