How to decode sgqa identifier

More
3 years 8 months ago #102811 by fransmarcelissen
fransmarcelissen created the topic: How to decode sgqa identifier
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

Please Log in to join the conversation.

More
3 years 8 months ago #102814 by holch
holch replied the topic: How to decode sgqa identifier
I am sure that 312 in this case can only be the question ID and not a mix of question ID and option.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
3 years 8 months ago - 3 years 8 months ago #102816 by fransmarcelissen
fransmarcelissen replied the topic: How to decode sgqa identifier
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: 3 years 8 months ago by fransmarcelissen.

Please Log in to join the conversation.

More
3 years 8 months ago #102820 by supercosh
supercosh replied the topic: How to decode sgqa identifier
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

Please Log in to join the conversation.

More
3 years 8 months ago #102827 by DenisChenu
DenisChenu replied the topic: How to decode sgqa identifier
HI,

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

Please :reprort bug or feature request.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
3 years 8 months ago #102830 by supercosh
supercosh replied the topic: How to decode sgqa identifier
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

Please Log in to join the conversation.

More
3 years 8 months ago #102831 by DenisChenu
DenisChenu replied the topic: How to decode sgqa identifier
Hi,

Maybe you can use :
viewHelper::getFieldCode($field);
Some where ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
3 years 8 months ago #102864 by supercosh
supercosh replied the topic: How to decode sgqa identifier
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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now