Welcome to the LimeSurvey Community Forum

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

prefill yesterday's date via survey url

  • Kvyncke
  • Kvyncke's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 9 months ago #230109 by Kvyncke
Your LimeSurvey version: Version 3.22.24+200630

==================
Hi all,

I will be sending an invitation email for my survey to my respondents, asking them to fill in the survey for "today", "yesterday" and "two days ago". I am hoping to include separate survey urls in this email, each of which autofills the date question for either yesterday or two days ago (the exact date thus depends on when the survey is filled in). Can anyone tell me if it is possible - and if yes, how - to adapt the survey url in order to auto-select yesterday or the day before in a datepicker? My question id is "Date" and other from "Maximum date" ("now") I haven't set any restrictions to the question.

Thanks in advance for your help!

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 9 months ago #230120 by holch
Replied by holch on topic prefill yesterday's date via survey url
I assume this is a token based survey.

The issue I see with 3 different URLs is that they might fill in the survey on 3 different days. So let's assume the first fill the "today" survey. Everything fine, you just write todays date into a question to save it.

Now they do something else and come back to the "yesterday" survey the next day. Meaning that suddenly "today" and "yesterday" is the same day.

I personally probably wouldn't use the datepicker at all and just write the actual date into a hidden equation question. You can then use this to make any calculation about yesterday, tomorrow, in 10 days, 50 days ago, whatever you want. And you can also display it.

In a token based questionnaire I would add a custom attribute and add "today", "yesterday", and "the day before" into it, so you know which questionnaire is which. You can access these token attributes from within the surveh with something like {TOKEN:ATTRIBUTE_1} and show that this questionnaire refers to "yesterday" for example. With the current date in your hidden equation question, you can calculate yesterdays date by substracting 1 day, and so on.

Of course, this doesn't solve the issue that I described in the beginning. So if the survey isn't too long, I would just create 3 question groups, one for today, yesterday and the day before and check if they respondent on the same day.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: Kvyncke

Please Log in to join the conversation.

  • Kvyncke
  • Kvyncke's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 years 9 months ago #230126 by Kvyncke
Replied by Kvyncke on topic prefill yesterday's date via survey url
Thank you for the elaborate reply, holch!

It is indeed a token-based questionnaire. You are absolutely right about the risk of the survey being filled in for the same date twice. In theory, this should not happen. To give you an idea without sharing the actual survey (it concerns COVID cases): we are actually adapting an existing survey that is currently being filled in on a daily basis to a survey that is filled in two days a week (Monday and Thursdays) for the preceding days as well.
We could simply have the respondent click the same survey url several times and ask them to select the date for which they are reporting but have noticed in the past that, in our survey, such selection is an important source of error. Also, several existing questions will only need to be answered on Mondays and Thursdays, we wish to autofill them with a default value for all other days, which is easily done in the survey url. Hence our wish to add a different survey url for each day to the invitation email. Fyi, we are sending the invitation emails via an R-script, not via LS itself.

This being said, I do think that your suggestion of using custom token attributes + hidden equation could allow us to do all of the above. Or perhaps, instead of token attributes, a simple hidden question (prefilled via the survey link for a specific day of the week) + hidden equation?

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 9 months ago #230133 by holch
Replied by holch on topic prefill yesterday's date via survey url
The token attribute does the same as the simple hidden question, without the risk that someone modifies the variable that is passed on via the link.

I personally find token attributes far better to work with, and far less risk involved. But this might be a personal preference.

I personally prefer to have everything within the database already instead of passing it through the survey link via a variable.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.
The following user(s) said Thank You: Kvyncke

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 9 months ago #230148 by tpartner
Replied by tpartner on topic prefill yesterday's date via survey url
Yes, if you can it's more secure to define the variables in the token table.

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: Kvyncke

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose