Welcome to the LimeSurvey Community Forum

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

How do I Store Answer Code only in Array Question

  • Dreardon
  • Dreardon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 6 days ago #270818 by Dreardon
I'm using array question type for two checklists in my survey.  Each has a list of sub-questions identifying psych symptoms with the code value for each subquestion renamed to a summary abbreviated Code like "Guilt."  There are four answer options from "not at all" to "very much" which are coded from 0 to 3.   

The problem is that the answer is recorded in the database as Guilt[1] not just as the numeric value 1.

How do I get the responses to be stored as the numeric value of the Answer option value in the Code for Answer Options?  

Attached is the export of the array checklist.

Please Log in to join the conversation.

  • Dreardon
  • Dreardon's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 6 days ago #270819 by Dreardon
I finally discovered that I was being misled and given the run around by ChatGPT which failed to recognize the difference between . and underscore.

Checklist1.Circumstance returns the label but Checklist1_Circumstance returns the value

So all my efforts to sum the . version of the variables failed, but this was fixed when using the _ versions.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 6 days ago - 2 weeks 6 days ago #270820 by Joffm
Hi, this is not quite correct.

1. Underscore:
This is used to build the QCode.
In single questions (list(radio)) it is just the questioncode  (  Q1 )
In question with one axis of subquestions (multiple, array) it is questioncode_subquestioncode ( Q1_SQ001 ).
In questions with two axis of subquestions (array(text), array(number)) it is questioncode_subquestionYcode_subquestionXcode (Q1_Y001_X001)

So to address a variable you have to use this QCode.
Please read here:
[url] www.limesurvey.org/manual/ExpressionScri...code_variable_naming [/url]

2. Dot
Hereby you add some properties (what exactly you want to receive)
This you find in the manual here
[url] www.limesurvey.org/manual/ExpressionScri...#Access_to_variables [/url]
You see that 
something like {Q1} returns the either the response code (in coded questions - list(radio), multiple, etc.) or the text (in not coded questions - short text, numbers ,etc).
Analogue {Q1_SQ001} returns the response code of the subquestion SQ001 in array Q1.

But {Q1.shown} returns the displayed text of the selected response, resp. subquestion {Q1_SQ001.shown}

See the manual for other properties, like
".value" to access the assessment value,
".question" to access the question resp. subqestion text,
".qid", ".gid" to access the order in which questions resp. groups were displayed
and many more.

The problem is that the answer is recorded in the database as Guilt[1] not just as the numeric value 1.

In the database there is only the code; this construct "Guilt[1]" is only shown in the response table of the GUI.

And if you export your data you have the option to choose whether you would like to get the code or the text.

Joffm

I was being misled and given the run around by ChatGPT which failed to recognize the difference between . and underscore.

Not surprising. ChatGPT has no knowledge of LimeSurvey.


  

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 weeks 6 days ago by Joffm.

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 3 days ago #270839 by holch
Yet another nice case of AI hallucinations. :-)

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.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose