Actions

Question type - Date

From LimeSurvey Manual

Revision as of 16:07, 7 October 2013 by FuzzyBot (talk | contribs) (Importing a new version from external source)

Short description

This question type can be used to ask for a certain date which can be entered directly, using the JavaScript calendar or by using a drop-down representation. Since version 1.80 you can also specify a minimum and maximum value for drop-down dates.

Core settings

Mandatory

Description

This option allows the survey administrators to request their respondents to answer certain survey questions. If the mandatory questions are not answered, the respondents will not be able to proceed further. If you have a question with multiple subquestions, and you require only certain subquestions to be answered, use the minimum answer attribute located under the Logic tab.

If you use any of the preinstalled themes and the mandatory question attribute is enabled, a red asterisk will be shown next to the question. If you wish to hide it, please check these instructions.


Available options

  • On - Question must be answered before the participant can proceed to the next page - the answer option 'No answer' is never shown.
  • Soft - If the question is not answered, a warning is shown when trying to proceed to the next page - however, the participant can choose to ignore the warning and proceed. Note that the 'No answer' option is still shown (if activated in survey presentation settings)
  • Off (default) - Question can be left unanswered


QS:Defaults


Condition (previously "Relevance equation")

Description

If the result value of the condition is "1" or "true", the question is "relevant" in the survey context, i.e. it is shown to the survey participant. If not, the question is hidden. Any survey question allows you to specify a relevance equation. This function is the successor of conditions and supports much more complex conditional logic.

Syntax Highlighting

Whenever you save the condition, it is evaluated and syntax-highlighted. Any errors will be color coded so that you can quickly detect and fix them.

 Hint: To check if all conditions are used correctly within your survey, read about our show logic file feature.


Valid values

  • Any condition that makes use of the ExpressionScript syntax, without surrounding curly braces.

Examples

Here are good examples of syntax highlighting.


Advanced settings

Reverse answer order (reverse)

Description

If activated, the order of the answers will be reversed.

Available options

  • On
  • Off (default)

Example

Let's assume that you want to use an Array (Numbers) question type. If this option is disabled (default value), then the possible answers a survey participant can select are: "1, 2, 3, ... , 10". If enabled, the setting will reverse the order of the available answers: "10, 9, 8, ... , 1".



Randomization group name (random_group)

Description

It places the questions into a specified randomization group, all questions included in the specified group being displayed in a random order to the survey respondents.

You can find a sample survey using randomization group name in ExpressionScript sample survey.

Valid values

Just enter any string you like (for example: 'group1'). All question which have set the same string within the randomization group name box will have their place in the survey randomized (=randomly exchanged among each other).


Preview To preview the questions use the preview survey instead of the preview question group function, as the second has been reported to not show the questions in a randomized order.



Display dropdown boxes (dropdown_dates)

Description

If enabled, the date/time question type will display a dropdown box to the respondents from where to choose the date/time, instead of the default popup.

Available options

  • On
  • Off (default)

Example

If it is turned on, the question will be displayed in the following way:



Always hide this question (hidden)

Description

If enabled, the question will always be hidden - it will not be displayed to the survey participants. This function can be used in the following scenarios:

  • If you wish to prefill a question with a URL and you want not to have it displayed on the screen. This overrides any conditions used within the survey because the respective question will not even be embedded on the page.
  • If you wish to store or calculate a value on the fly via the ExpressionScript - Presentation.
Note: A common question type that is used with this function is the Equation one.

Available options

  • On
  • Off (default)



Minimum year (dropdown_dates_year_min)

Description

This question attribute can be used to set the minimum year value for the calendar question. It applies to the dropdown- and to the popup-variant of the calendar.

Valid values

Any year value



Maximum year (dropdown_dates_year_max)

Description

This question attribute can be used to set the maximum year value for the calendar question. It applies to the dropdown- and to the popup-variant of the calendar.

Valid values

Any year value



Minimum date (date_min)

Description

This question attribute can be used to set the minimum value for a date question (in y-m-d format or any English valid string - see below for more details). It can be used for both popup and dropdown display options. If a minimum date is not set, then 1.1.1900 is used as default.


  Attention : The Expression Manager validation option can also be used for setting up a "minimum date". However, if you you use the popup calendar and the expression relies on a previous question located on the same page, the year will not be displayed correctly in the popup calendar.



Valid values

  • Any date value in format YYYY-MM-DD (eg., 2017-08-24);
  • Any year value;
  • Any English string : "now", "-10 years", "tomorrow";
  • Reference to another date/time question : AnotherDateQuestion (using the question code);
  • Expressions : With expressions, a minimum date can be dynamically calculated. For example, you can use a date from a previous answer + 3 days as a minimum for the present question by entering: date("Y-m-d",strtotime(departuredate)+3*60*60*24).



Maximum date (date_max)

Description

This question attribute can be used to set the maximum value for the date question (in y-m-d format or any other English valid string - see below for more options). It can be used for both popup and dropdown display options.

  Attention : The Expression Manager validation option can also be used for setting up a "maximum date". However, if you use the popup calendar and the expression relies on a previous question located on the same page, the year will not be displayed correctly in the popup calendar.


Valid values

  • Any date value in format YYYY-MM-DD (eg., 2018-08-24);
  • Any year value;
  • Any English string : "now", "-10 years", "tomorrow";
  • Reference to another date/time question : AnotherDateQuestion (using the question code);
  • Expressions: With expressions, a date can be dynamically calculated. For example, you can use a date from a previous answer + 3 days as a maximum date for the present question by entering: date("Y-m-d",strtotime(departuredate)+3*60*60*24).



Question validation equation (em_validation_q)

Description

This is an equation that is used to validate the entire question (e.g, all of its parts collectively for a multi-answer question). If the question fails the validation criteria, then em_validation_q_tip message will be displayed (it uses the CSS style .error). This tip uses the .em_q_fn_validation CSS style, which is hidden by default within template.css.

The main difference between this feature and the subquestion validation equations (em_validation_sq option) is that for this feature, if the question (or question parts) fail validation, then an error message could be shown. For the subquestion validation, each text entry cell (e.g., in an array question type, but it can also be applied to single entry question types) will be styled so that the background color is (light) red.

Valid values

  • Any equation that makes use of the ExpressionScript syntax, without surrounding curly braces.

Example

  • You want to collect demographic information from users via a multiple short text question, and you want to validate that the user has entered a valid email address and phone number.

This example shows how the question looks with invalid answers:

And here is what it looks like with one invalid answer:

Here is how you edit a question to enter that information:

And here is part of the Show Logic File output that lets you check the accuracy of your expression and ensure that there are no syntax errors:

As you can see, the validation equation tests that both the email and phone number are either empty or match a regular expression filter.

The validation tip only shows the warning message if the phone or email appears invalid.

 Hint: In order to create complex validation messages, read about the usage of the ExpressionScript.


If you wish to import the example from above into your LimeSurvey installation, download the following .lsq file: Em_validation_q_example.zip.

 Hint: Remember, LimeSuvey uses the Perl syntax for regular expressions, so they should start and end with / (slash character)!


Validation on date

  Dates in Limesurvey are saved as a string (text format).


To really be able to work (and calculate) with dates, these have to be converted to a number format. The function strtotime (New in 2.0 build 130515) , which calculates the number of seconds from the 1st January 1970 to a given date can be used for this. Using strtotime() one can for example enforce that only dates before "today" are entered using the following expression: strtotime(self)<=strtotime("now"). Or enforce that that only dates after a certain date can be entered: strtotime(self)>strtotime("2013-03-27")


Tip for whole question validation equation (em_validation_q_tip)

Description

If you are using the question validation equation, you can use this box in order to display an optional message as question tip on how the question has to be filled out.

Valid values

Example

See the example from the question validation equation wiki section- it shows how the tip can be tailored to show which parts of a multiple short text question fail the validation criteria.



Insert page break in printable view (page_break)

Description

This attribute is only active when you actually print a survey from the Printable View. It forces a page break before the question.

Available options

  • On
  • Off (default)


Insert page break in printable view (page_break)

Description

This attribute is only active when you actually print a survey from the Printable View. It forces a page break before the question.

Available options

  • On
  • Off (default)