Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: variable endurl upon radio button question - how can I do that?

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #93962

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
Hello,
once I found a workaround to redirect users to different surveys upon an answer in the main survey - the problem is i dont know how to modify it for my needs (which are simpler then that example).

Ive got one main survey, where there is only one radio question with 3 answers.

If the user picks 1 and ends the survey i want to take him to url1 if he picks 2, url 2 and so on.

I created the main question, and created a expression question named endURL with this code inside:

{if (druzyna.NAOK == "1"), 'google.pl', if(druzyna.NAOK == "2"), 'onet.pl', if(druzyna.NAOK == "3"), 'gazeta.pl', 'defaultValue' ))) }

end set my endurl in survey settings to: {endURL}

problem is i cant make it work :(

could anyone please help me?
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #93965

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
The original solution ive tried to use is here

www.limesurvey.org/en/forum/can-i-do-thi...ssed-to-external-url
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #93983

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
blazko wrote:
{if (druzyna.NAOK == "1"), 'google.pl', if(druzyna.NAOK == "2"), 'onet.pl', if(druzyna.NAOK == "3"), 'gazeta.pl', 'defaultValue' ))) }

end set my endurl in survey settings to: {endURL}

problem is i cant make it work :(
endURL is a equation question type ? You need the http:// before the url.

Maybe use another question code (myEndURL)

Because i use it a lot and it work good.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #93990

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5417
  • Thank you received: 806
  • Karma: 239
EM is nice, but this would work with quota as well, wouldn't it? Just have zero quotas for each response that needs a different endurl.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #93996

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
yes, endURL is a equation question type

the code actually look like this:

{if (druzyna.NAOK == "1"), 'google.pl', if(druzyna.NAOK == "2"), 'onet.pl', if(druzyna.NAOK == "3"), 'gazeta.pl', 'defaultValue' ))) }

should the endrl be placed in normal brackets () or in theses {}?
Last Edit: 3 years 8 months ago by blazko.
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #93997

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
holch wrote:
EM is nice, but this would work with quota as well, wouldn't it? Just have zero quotas for each response that needs a different endurl.

im not that familar with quotas. How would that look like and how would a differrent url connect with it?
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94001

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
I found something strange.

My LimeSurvey copy is installed in Polish and thats the default lang.


When i make an equation question in a polish survey it looks like its not trated in any special way.
An english survey with equation question deals with redirection pretty fine.

Is this a bug or im still doing something wrong?
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94003

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
If you can,
plase have a look at the attached example (oonly 2 quesions).
No matter wich option is chosen it redirects only to link1
Attachments:
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94014

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5417
  • Thank you received: 806
  • Karma: 239
Let's say you 3 possible responses:

A
B
C

You'll create a quote for each of them and set it to zero (0).

So whenever someone marks this response, they will run into the endpage for this quota. At the endpage of this quota you can set an individual endurl.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | [url=https://manual.limesurvey.org/Workarounds[/url]

If you found this answer helpful and it saved you some time please consider a [url=https://donate.limesurvey.org[/url] to the...
The administrator has disabled public write access.
The following user(s) said Thank You: blazko

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94028

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
Thanks for the hint.

I do have one other question.

Is there a way to forward a answer with the link?

What im trying to do is to redirect (after question 1) to different surveys.
There is a java script with a random number selection from 1 to 1000. If I could automatically forward which number has been picked and place it within answers of the forwarded survey it would awesome.

Sample file (2 question) is attached.

Question "walidacja" is the one responsible for random number generation

<script type="text/javascript">

$(document).ready(function() {


var randNumber = Math.floor(Math.random()*1000 + 1);


$('input#answer249246X52X3592').val(randNumber);
// $('#question1174').hide();
});
</script>
Attachments:
Last Edit: 3 years 8 months ago by blazko.
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94038

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
blazko wrote:
yes, endURL is a equation question type

the code actually look like this:

{if (druzyna.NAOK == "1"), 'google.pl', if(druzyna.NAOK == "2"), 'onet.pl', if(druzyna.NAOK == "3"), 'gazeta.pl', 'defaultValue' ))) }

should the endrl be placed in normal brackets () or in theses {}?

*Please use code:
{if(druzyna.NAOK == "1","http://example.org","")}{if(druzyna.NAOK == "2","http://example.com","")}{if(druzyna.NAOK == "3","http://example.net","")}
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.
The following user(s) said Thank You: blazko

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94039

  • blazko
  • blazko's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Karma: 0
Thanks Denis.

I already used the quota solution.

But if you could help me out in passing an aswer between surveys I would be greatful.

Those redirect url's are in fact 3 different surveys. Survey 1 that stores the url redirect code (quota actually) has also a random number variable. Is it possible to pass this number to the next survey (after redirect) and store it somewhere as a hidden answer for future participant matching?
The administrator has disabled public write access.

variable endurl upon radio button question - how can I do that? 3 years 8 months ago #94059

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9555
  • Thank you received: 1373
  • Karma: 389
You can use:

docs.limesurvey.org/tiki-index.php?page=Workarounds%3A+Survey+behaviour#Prefilling_survey_elements

And use EM in Quota too.

For this example, you can use:

ENDURLPARAMATER
?111X2X3={THEQCODE}

Where {THEQCODE} is the Expression to fill in next survey. Here the next surveyid is 111, the question is in the group 2, and the qid is 3.

(see SGQA ).

Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time (Need support ?).
A bug not reported is a bug not corrected. | 2.61lts version improved | Need plugins for LimeSurvey ?
The administrator has disabled public write access.
The following user(s) said Thank You: blazko
Time to create page: 0.407 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form