DIRKMJK / limepy

Download and summarise LimeSurvey data
MIT License
24 stars 8 forks source link

No way to get question code from Question object? #7

Closed fefrei closed 4 years ago

fefrei commented 4 years ago

I'm using limepy to create a PDF report for a survey.

Iterating through the questions, I have a Question object for every question, which is usually enough to build the report. However, it looks like some details are missing, e.g. for multiple choice questions with an Other option, I'm unable to find the freeform entries users made. I'd be happy to look them up manually in the survey's dataframe, but I don't see a way to get the question code from a Question object.

Maybe I'm overlooking something obvious – but if not: Could you add a code property to the Question class?

DIRKMJK commented 4 years ago

Thanks for your feedback. You can use the ‘other’ column in the question_list to determine which questions have an ‘other’ option containing free text; then you can use the write_open_ended method to get the answers submitted. See also the example code under the header ‘Write answers to an open-ended question’ in the Readme file. Hope this works for you!

fefrei commented 4 years ago

The write_open_ended method doesn't really work for me, as I don't want to write the answers out as text (but do some custom processing on them).

What I ended up doing was to get the code from question.metadata['title'] (this is what I was missing for quite some time), then inspect survey.dataframe[f"{code}[other]"] to get the answers.

Thanks for you reply, and for making limepy! Despite my struggles, it helped a lot.

If you want to improve on this, I think my main recommendations would be:

Again, thanks for making this! `

DIRKMJK commented 4 years ago

Thanks for your feedback, much appreciated! And thanks for the suggestions - I’ll look into them but it may take a while due to time constraints

DIRKMJK commented 4 years ago

Apologies for the long wait. I’ve added the question title to the question_list and added an explanation to readme.