Welcome to the LimeSurvey Community Forum

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

Autofill subquestions with Token Information

  • pierreb1968
  • pierreb1968's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #136180 by pierreb1968
Hi everyone - fairly new to LimeSurvey - we are using Version 2.50+ Build 160426.

We have a survey that our members must fill in every year. What I'd like to do is prepopulate some of the fields with the answers that were given last year. I have last year's answers as fields (attributes) in the token table. Now what I want to do is use them to prepopulate fields in the survey.

One question is an array (texts), that has a number of subquestions. The X Scale has a total subquestion, and this is the one I want to prepopulate with last year's answers.

I also want to do the same thing, only this time with a multiple choice question. I see there is an "Edit Default Answers" button, but that isn't much help.

I read the documentation, and thought maybe creating a hidden question/group at the beginning of the survey would accomplish it, but I guess my coding skills are not there yet. Im not even sure if its necessary to use Javascript.

Can anyone provide any guidance or assistance?

Much appreciated!
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136184 by holch
why do you need to pre-fill a question anyway?

The information from the token table can be accessed through the Expression manager within the survey.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • pierreb1968
  • pierreb1968's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 11 months ago #136205 by pierreb1968
Replied by pierreb1968 on topic Autofill subquestions with Token Information
I guess the better way to describe it is Im looking to set a default answer to a token field, in the question types I mentioned.

This survey is an annual one - Id like to populate these questions with what they answered last year, but give them the option to override the default to put in a new answer.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136210 by holch

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136234 by tpartner
Replied by tpartner on topic Autofill subquestions with Token Information
You can use the Expression Manager assignment operator to set the default value of an input in an array texts type question.

Assuming a question code "Q1" , x-scale sub-question codes "X1, X2, X3..." and y-scale sub-question codes "Y1, Y2, Y3...":

Insert a new equation type question directly after the array question with something like this as a value:
Code:
{Q1_Y1_X4 = if(is_empty(Q1_Y1_X4), TOKEN:ATTRIBUTE_1, Q1_Y1_X4)}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #136237 by tpartner
Replied by tpartner on topic Autofill subquestions with Token Information
Setting default values for a multiple-choice depending on token values is a little trickier because you have to check whether the group has been previously visited.

Assuming the the multiple-choice has question code "Q2" and sub-question codes "SQ1, SQ2, SQ3...":

Place a short text question (code qHidden1) directly after the multiple-choice and use the "Always hide this question" setting. We'll use Expression Manager to set this as an indicator if the page has been previously visited.

Place an equation question (code equation2) directly after qHidden1 with something like this as a value:
Code:
{Q2_SQ2 = (if(is_empty(qHidden1) AND TOKEN:ATTRIBUTE_1 == 'Some value', 'Y', Q2_SQ2))}

Place an equation question directly after equation2 with this as a value:
Code:
{qHidden1 = 1}

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: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose