Welcome, Guest
Username: Password: Remember me

TOPIC: How to decode sgqa identifier

How to decode sgqa identifier 7 months 4 weeks ago #102811

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 143
  • Thank you received: 23
  • Karma: 6
I have written a report generator in R for limesurvey surveys. I read the date directly from the mysql database, without exporting them ("select * from lime_survey_12345 where (etc)") (in this way many limitations in limesurvey can be solved. In the future I will write an article about it. My program has some problems that have to be solved first).
Now I have problems with the decoding of column names. The column names are the SGQA code of the question. For example: 225629X4X312 means sid 225629, gid 4, and qid 31, option 2. But 312 could also mean: qid 312. Is there a good way to decide which of both is the case? I want to give the extracted column names like "food2", just like happens in the spss and r exporter.
What I do now, is just try: if code 312 exists in the question table with the particular sid and gid, 312 is considered to be a qid, else strip off the last chararter, and try again. Of course this is not a smart "algoritm", but it works. There must be a better way.
Yes I know, SGQA code is explained in manual.limesurvey.org/SGQA_identifier, but there it is only explained how to construct the code, not how to decode it. And yes, I know the solution must be buried somewhere in the php code, but where?
Limesurvey guru's: I will be grateful for the rest of my life, and I am willing to give a donation if my problem is solved, just when my program is ready. Limesurvey is the best survey software in the world, but i can become just a little bit better/more general.
Frans
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102814

  • holch
  • holch's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2607
  • Thank you received: 302
  • Karma: 110
I am sure that 312 in this case can only be the question ID and not a mix of question ID and option.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102816

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 143
  • Thank you received: 23
  • Karma: 6
What makes you so sure? In fact you are right, but what do you think of 225629X4X691? That _is_ option 1 of question 69...... qid 691 does also exist, on another survey. So probably one has to look at the sid and gid.
Frans
Last Edit: 7 months 4 weeks ago by fransmarcelissen.
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102820

  • supercosh
  • supercosh's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Thank you received: 9
  • Karma: 1
I would also be interested in an answer, in my online report generator I did it the same way as you did, Frans - and was wondering if there would be a smarter way. I noted on my todo list to analyze the source code in LS regarding that, but hadn't found time yet to do so.

Regards,
Gregor
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102827

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6252
  • Thank you received: 799
  • Karma: 239
HI,

If it's done in SPSS, surely we can do it too in R.

Please :reprort bug or feature request.
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102830

  • supercosh
  • supercosh's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Thank you received: 9
  • Karma: 1
Hi,

Okay, well if it's working without "the hack" in SPSS, than I will have a look at the code. When the feature request is reported and I find a solution, I'll contribute it.

Please update in here, I subscribed the topic.

Regards
Gregor
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102831

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6252
  • Thank you received: 799
  • Karma: 239
Hi,

Maybe you can use :
viewHelper::getFieldCode($field);
Some where ?
The administrator has disabled public write access.

How to decode sgqa identifier 7 months 4 weeks ago #102864

  • supercosh
  • supercosh's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 25
  • Thank you received: 9
  • Karma: 1
Hi Denis,

Thank you for the hint. I have checked the function viewHelper::getFieldCode() and getFieldText(), but those functions require some field array information and won't lookup the texts in the model/database. The first step would be to get that array.

What we are looking for is a way of passing the SGQA Code (and the language) to a function and the return value being the question text / label.

After christmas I'll start looking deeper into that, but if you could give me directions on which classes or even methods to start, I'd be very grateful!

Regards,
Gregor
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.119 seconds
Donation Image