Actions

URL fields: Difference between revisions

From LimeSurvey Manual

mNo edit summary
mNo edit summary
Line 11: Line 11:
<!--T:32-->
<!--T:32-->
URL fields parameters can be used in the:
URL fields parameters can be used in the:
* End URL field of the survey (see the [[Text elements|survey text elements]]);
* [[URL_fields#End_URL_field|End URL]] field of the survey (see [[Text elements|survey text elements]])  
* URL field of the quota rule (read more about [[Survey quotas|survey quotas here]])
* URL field of the quota rule (read more about survey quotas [[Survey quotas|here]])
* Start URL field of the survey.
* [[URL_fields#Start_URL|Start URL]] field of the survey (see [[Text elements|survey text elements]]).




Line 23: Line 23:


<!--T:4-->
<!--T:4-->
However, there are a number of fields available to be used to enhance the functionality of this URL.
However, LimeSurvey offers the possibility to use URL fields in many other ways which in turn allows you to enhance the functionality of your survey.




Line 30: Line 30:


<!--T:6-->
<!--T:6-->
You can use '''{SAVEDID}''', '''{TOKEN}''', '''{SID}''' and '''{LANG}''' in this URL:
You can use '''{SAVEDID}''', '''{TOKEN}''', '''{SID}''', and '''{LANG}''' in the end URL:
*'''SAVEDID''' is the id assigned to this particular submission;
*'''SAVEDID''' is the id assigned to this particular submission;
*'''TOKEN''' is the token used to participate in the survey;
*'''TOKEN''' is the token used to participate in the survey;
Line 41: Line 41:
<!--T:8-->
<!--T:8-->
<code>
<code>
<nowiki>http://www.limesurvey.org/test.php?var1={SAVEDID}&var2={TOKEN}&var3={SID}&lang={LANG}</nowiki>
<nowiki>https://www.limesurvey.org/test.php?var1={SAVEDID}&var2={TOKEN}&var3={SID}&lang={LANG}</nowiki>
</code>
</code>


Line 49: Line 49:


<!--T:10-->
<!--T:10-->
You can also use '''{INSERTANS:SGQA}'''. This URL field allows you to add the response to a specific question in the survey into the end URL. This can be useful for sending a response to an external script (ie an email address collected during the survey).
You can also use '''{INSERTANS:SGQA}'''. This URL field allows you to add the response to a specific question in the survey into the end URL. This can be useful for sending a response to an external script (i.e. an email address collected during the survey).


<!--T:11-->
<!--T:11-->
Line 56: Line 56:
<!--T:12-->
<!--T:12-->
<code><nowiki>
<code><nowiki>
http://www.limesurvey.org/test.php?email={INSERTANS:1234X56X7}
https://www.limesurvey.org/test.php?email={INSERTANS:1234X56X7}
</nowiki></code>
</nowiki></code>


Line 74: Line 74:


<!--T:53-->
<!--T:53-->
(see: https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/115371-prefilling-survey-answers-using-the-survey-url-version-3)
For more details, check the following LimeSurvey forum post: [https://www.limesurvey.org/forum/can-i-do-this-with-limesurvey/115371-prefilling-survey-answers-using-the-survey-url-version-3 link].




Line 81: Line 81:


<!--T:14-->
<!--T:14-->
You can also use any [[Expression Manager|Expression Manager]] expression here.
You can also use any [[Expression Manager - presentation|expression]] here.


<!--T:15-->
<!--T:15-->
Line 99: Line 99:


<!--T:48-->
<!--T:48-->
Let's suppose that you defined [[Panel integration|a parameter]] named "foobar". The survey is started with a link like
Let's suppose that you defined [[Panel integration|a parameter]] named "foobar". The survey is started with a link like this one:


<!--T:21-->
<!--T:21-->
Line 111: Line 111:
<!--T:23-->
<!--T:23-->
The end URL of a survey with the following URL <code><nowiki>http://www.limesurvey.org/test.php?foobarout={PASSTHRU:foobar}</nowiki></code> would then be converted to <code><nowiki>http://www.limesurvey.org/test.php?foobarout=XYZ123</nowiki></code>
The end URL of a survey with the following URL <code><nowiki>http://www.limesurvey.org/test.php?foobarout={PASSTHRU:foobar}</nowiki></code> would then be converted to <code><nowiki>http://www.limesurvey.org/test.php?foobarout=XYZ123</nowiki></code>
<!--T:49-->
{{Alert|title=Attention|text=Please note that the passthrough fields can be used only with LimeSurvey 2.x or later!}}




Line 124: Line 120:


<!--T:36-->
<!--T:36-->
You can prefill all answer except upload and equation question type. You can use [[Expression Manager#Access to Variables|qcode naming]] for the parameters and set the value for single question types. For multiple question type, you must use a [[SGQA identifier]].
You can prefill all answers except the [[Question_type_-_File_upload|upload]] and [[Question type - Equation|equation question type]]. You can use [[Expression Manager - presentation#Access to Variables|qcode naming]] for parameters and set the value for single question types. For the multiple question type, you must use a [[SGQA identifier]].


<!--T:37-->
<!--T:37-->
Then answer are set to the pre-filled value, for single choice option, you must use the code of the answer, for multi choice question, you must use Y if you want to check the answer.
Then answer are set to the prefilled value. For single choice option, you must use the code of the answer, for multi choice question, you must use Y if you want to check the answer.


<!--T:38-->
<!--T:38-->
Here are some start URL '''examples''':
Here are some start URL examples:


<!--T:39-->
<!--T:39-->
* <code><nowiki>http://ls.example.org/1234?QTEXT=prefilled</nowiki></code> : Fill the question with code QTEXT with <nowiki>'prefilled'</nowiki>
* <code><nowiki>http://ls.example.org/1234?QTEXT=prefilled</nowiki></code> : Fill in the question with code QTEXT with <nowiki>'prefilled'</nowiki>
* <code><nowiki>http://ls.example.org/1234?MULTI_SQ001=prefilled</nowiki></code> {{NewIn|v=3.14.1}} : Fill the sub question SQ001 of question with title MULTI with <nowiki>'prefilled'</nowiki> (for a multiple text question for example).
* <code><nowiki>https://ls.example.org/1234?MULTI_SQ001=prefilled</nowiki></code> {{NewIn|v=3.14.1}} : Fill in the subquestion SQ001 of question with title MULTI with <nowiki>'prefilled'</nowiki> (for a multiple text question for example).
* <code><nowiki>http://ls.example.org/1234?single=-oth-&single_other=Other%20text</nowiki></code> {{NewIn|v=3.14.1}} : Check other at the single choice question single and fill other value by “Other text»
* <code><nowiki>https://ls.example.org/1234?single=-oth-&single_other=Other%20text</nowiki></code> {{NewIn|v=3.14.1}} : Select the "other" answer option of a single choice question single and fill in the other value with the text "Other text"
* <code><nowiki>http://ls.example.org/1234?1234X1X1SQ001=prefilled</nowiki></code> : Fill the sub question SQ001 of question number 1 in group 1 with <nowiki>'prefilled'</nowiki>
* <code><nowiki>https://ls.example.org/1234?1234X1X1SQ001=prefilled</nowiki></code> : Fill in the subquestion SQ001 of question with ID: 1 from group with ID: 1 with <nowiki>'prefilled'</nowiki>
* <code><nowiki>http://ls.example.org/1234?1234X1X1SQ001=A1</nowiki></code> : Check the answer <nowiki>'A1'</nowiki> at the sub question SQ001 of question number 1 in group 1 .
* <code><nowiki>https://ls.example.org/1234?1234X1X1SQ001=A1</nowiki></code> : Preselect the answer option <nowiki>'A1'</nowiki> of the subquestion SQ001 of question with ID: 1 from group that has ID: 1.
* <code><nowiki>http://ls.example.org/1234?1234X1X1SQ001=Y</nowiki></code> : Check the sub question SQ001 at question number 1 in group 1.
* <code><nowiki>https://ls.example.org/1234?1234X1X1SQ001=Y</nowiki></code> : Preselect the subquestion SQ001 of the question that has the ID 1, from the group that has ID: 1.
 


<!--T:40-->
<!--T:40-->
{{Hint|Text=GET parameters use "?" for the first parameter and "&" for the subsequent ones. If you already have "?" in your URL, you must use "&" to add more GET parameters.}}
{{Hint|Text=GET parameters use "?" for the first parameter and "&" for the subsequent ones. If you already have "?" in your URL, you must use "&" to add more GET parameters.}}
{{Hint|Text=The extra GET parameters are only filled when the survey starts anew. Therefore, for testing, always add newtest=Y to start a fresh survey. For example: <code><nowiki>http://ls.example.org/1234?QTEXT=prefilled&newtest=Y</nowiki></code>}}
 
 
{{Hint|Text=The extra GET parameters are only filled in when the survey starts anew. Therefore, for testing, always add newtest=Y to start a fresh survey. For example: <code><nowiki>http://ls.example.org/1234?QTEXT=prefilled&newtest=Y</nowiki></code>}}




==Prefilling a survey using GET parameters using URL parameters tab== <!--T:41-->
==Prefilling a survey using GET parameters using URL parameters tab== <!--T:41-->


<!--T:42-->
<!--T:42-->
You can prefill (sometimes easier) answers using URL parameters which can be configured in the [[Panel integration|panel integration]].
You can prefill (sometimes easier) answers using URL parameters which can be configured in [[Panel integration|panel integration]].




Line 155: Line 155:


<!--T:44-->
<!--T:44-->
You can use hidden advanced settings to hide the question from your respondents. If so, the question still remains prefilled.
You can use the [[QS:Hidden|hidden attribute]] of a question to hide it from your respondents. If so, the question still remains prefilled.


</translate>
</translate>

Revision as of 12:29, 24 January 2019


Introduction

URL fields parameters can be used in the:


End URL field

At the end of a survey or when a quota causes a survey to terminate, there is the option to set an ending URL. This URL is presented to the participant who has finished the survey on the end page or you can optionally set the participant to be automatically redirected to the respective URL. This can be done by filling in the End URL option from the Survey text elements panel and by enabling the automatic load of the end URL from the Presentation panel once a survey is completed .

However, LimeSurvey offers the possibility to use URL fields in many other ways which in turn allows you to enhance the functionality of your survey.


Basic fields

You can use {SAVEDID}, {TOKEN}, {SID}, and {LANG} in the end URL:

  • SAVEDID is the id assigned to this particular submission;
  • TOKEN is the token used to participate in the survey;
  • SID is the survey ID;
  • LANG is the language code.

For example:

https://www.limesurvey.org/test.php?var1={SAVEDID}&var2={TOKEN}&var3={SID}&lang={LANG}


Answer fields

You can also use {INSERTANS:SGQA}. This URL field allows you to add the response to a specific question in the survey into the end URL. This can be useful for sending a response to an external script (i.e. an email address collected during the survey).

For example:

https://www.limesurvey.org/test.php?email={INSERTANS:1234X56X7}


However its important to add "newtest/y" to the URL. See this


https://exampletest.limequery.com/index.php/survey/index/sid/48315/newtest/Y?48315X2X222007=Y&48315X2X222008=Y


That URL pertains to a survey with ID = 48315, group =2, question=22 and answercodes = 2007 and 2008.

For more details, check the following LimeSurvey forum post: link.


Expressions

You can also use any expression here.

For example:

http://www.limesurvey.org/test.php?gender={if(sex=='Male','M','F')}&name;={name}


Passthrough fields

To use passhtrough fields, you have to define any additional parameters that should be passed into the end URL in the survey settings (read more about the LimeSurvey panel integration feature). To use such a parameter in the end URL, just insert the tag {PASSTHRU:<paramname>} where <paramname> is the name of your input parameter.

Let's suppose that you defined a parameter named "foobar". The survey is started with a link like this one:

http://example.org/limesurvey/index.php/survey/index/sid/12345/lang/eb?foobar=XYZ123

The XYZ123 is the value you want "to pass".

The end URL of a survey with the following URL http://www.limesurvey.org/test.php?foobarout={PASSTHRU:foobar} would then be converted to http://www.limesurvey.org/test.php?foobarout=XYZ123


Start URL

Prefilling a survey using GET parameters

You can prefill all answers except the upload and equation question type. You can use qcode naming for parameters and set the value for single question types. For the multiple question type, you must use a SGQA identifier.

Then answer are set to the prefilled value. For single choice option, you must use the code of the answer, for multi choice question, you must use Y if you want to check the answer.

Here are some start URL examples:

  • http://ls.example.org/1234?QTEXT=prefilled : Fill in the question with code QTEXT with 'prefilled'
  • https://ls.example.org/1234?MULTI_SQ001=prefilled (New in 3.14.1 ) : Fill in the subquestion SQ001 of question with title MULTI with 'prefilled' (for a multiple text question for example).
  • https://ls.example.org/1234?single=-oth-&single_other=Other%20text (New in 3.14.1 ) : Select the "other" answer option of a single choice question single and fill in the other value with the text "Other text"
  • https://ls.example.org/1234?1234X1X1SQ001=prefilled : Fill in the subquestion SQ001 of question with ID: 1 from group with ID: 1 with 'prefilled'
  • https://ls.example.org/1234?1234X1X1SQ001=A1 : Preselect the answer option 'A1' of the subquestion SQ001 of question with ID: 1 from group that has ID: 1.
  • https://ls.example.org/1234?1234X1X1SQ001=Y : Preselect the subquestion SQ001 of the question that has the ID 1, from the group that has ID: 1.


 Hint: GET parameters use "?" for the first parameter and "&" for the subsequent ones. If you already have "?" in your URL, you must use "&" to add more GET parameters.


 Hint: The extra GET parameters are only filled in when the survey starts anew. Therefore, for testing, always add newtest=Y to start a fresh survey. For example: http://ls.example.org/1234?QTEXT=prefilled&newtest=Y


Prefilling a survey using GET parameters using URL parameters tab

You can prefill (sometimes easier) answers using URL parameters which can be configured in panel integration.


Prefilling and hiding the answer

You can use the hidden attribute of a question to hide it from your respondents. If so, the question still remains prefilled.