Actions

Default answers: Difference between revisions

From LimeSurvey Manual

No edit summary
 
(30 intermediate revisions by 5 users not shown)
Line 4: Line 4:
<onlyinclude>
<onlyinclude>


===Default values (defaults)=== <!--T:2-->


<!--T:3-->
=Introduction= <!--T:2-->
'''Description'''


<!--T:4-->
This lets you set the default values for certain list and multiple choice question types.


<!--T:5-->
<!--T:12-->
<div class="simplebox">Starting in version 1.92, you can also set default values for text-entry questions.</div>
You can assign for different question types a default value to be recorded in the case in which the survey participant skips the question or decides that he or she is happy with the provided default answer. To access this option, look for the '''edit default answers''' button located on the question panel:


<!--T:6-->
'''Valid values'''
*For multiple choice questions, you will see drop-down boxes letting you  select the desired default
*For text-entry questions, you will have a text entry field in which you can enter any string or [[Expression Manager|expression]].  If you use an expression, you need to include curly braces


<!--T:7-->
<!--T:13-->
'''Example'''
<center>[[FIle:Edit default answers example.png]]</center>
*You have a non-anonymous survey, where {TOKEN:ATTRIBUTE_1} is the person's age as of the time the tokens table was created. You want to prefill a question with the person's age and ask them to validate that the age is accurate, or let them change the age value if it is not accurate.  In the text entry field for the default value, you would enter {TOKEN:ATTRIBUTE_1}


<!--T:8-->
</onlyinclude>


[[Category:Advanced question settings]]
=Valid values= <!--T:18-->


<!--T:14-->
*For single choice questions, you will see drop-down boxes from where you can select the desired default value.
*For multi-choice questions, you will see checkboxes from where you can select the desired default state (checked or not checked).
*For text-entry questions, you will have a text entry field in which you can enter any string or [[ExpressionScript - Presentation|expression]]. If you use an expression, curly brackets must be used.
*For date-time questions, if you set a fixed value the format of the fixed value needs to be YYYY-MM-DD (for example: 2022-02-28). If you're using an expression to set a date, the format must be like date ('Y-m-d') or date ('Y-m-d H:s'). For example, if you want to set the current time as default in a date question with format HH:MM (hour and minute), you would have to use the full-time format in the default answer box: '''date ('Y-m-d H:s')'''. The format in the expression is independent of the format from the question settings.
<!--T:10-->
{{Alert|Title=Attention|text= '''Attention:'''
* For hidden question, an alternative solution can be ExpressionScript with [[ExpressionScript - Presentation#Caution_about_using_Assignment_Operator_.28.3D.29|assignment operator]].}}
=Default value with ExpressionScript= <!--T:16-->
<!--T:17-->
Only "Text" and "Yes/No" question types allow the survey administrator to make use of the LimeSurvey [[ExpressionScript - Presentation|ExpressionScript]] to change the default value. For all the other question types you can use [[ExpressionScript - Presentation#Using_Assignment_Operator|assignment operators]].
=Example= <!--T:19-->
<!--T:15-->
*You have a non-anonymous survey, where {TOKEN:ATTRIBUTE_1} is the person's age as of the time the survey participants table was created. You want to prefill a question/default answer with the person's age and ask them to validate the age or to let him or her change the age value if it is not accurate. To do that, enter {TOKEN:ATTRIBUTE_1} in the text entry field for the default answer.


</translate>
</translate>

Latest revision as of 22:40, 15 February 2023


Introduction

You can assign for different question types a default value to be recorded in the case in which the survey participant skips the question or decides that he or she is happy with the provided default answer. To access this option, look for the edit default answers button located on the question panel:



Valid values

  • For single choice questions, you will see drop-down boxes from where you can select the desired default value.
  • For multi-choice questions, you will see checkboxes from where you can select the desired default state (checked or not checked).
  • For text-entry questions, you will have a text entry field in which you can enter any string or expression. If you use an expression, curly brackets must be used.
  • For date-time questions, if you set a fixed value the format of the fixed value needs to be YYYY-MM-DD (for example: 2022-02-28). If you're using an expression to set a date, the format must be like date ('Y-m-d') or date ('Y-m-d H:s'). For example, if you want to set the current time as default in a date question with format HH:MM (hour and minute), you would have to use the full-time format in the default answer box: date ('Y-m-d H:s'). The format in the expression is independent of the format from the question settings.
  Attention:



Default value with ExpressionScript

Only "Text" and "Yes/No" question types allow the survey administrator to make use of the LimeSurvey ExpressionScript to change the default value. For all the other question types you can use assignment operators.


Example

  • You have a non-anonymous survey, where {TOKEN:ATTRIBUTE_1} is the person's age as of the time the survey participants table was created. You want to prefill a question/default answer with the person's age and ask them to validate the age or to let him or her change the age value if it is not accurate. To do that, enter {TOKEN:ATTRIBUTE_1} in the text entry field for the default answer.