- Posts: 12
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
LimesurveyRC: Is it possible to retrieve answer options with list_questions?
- datamunger
- Topic Author
- Offline
- New Member
Less
More
4 years 8 months ago - 4 years 8 months ago #187686
by datamunger
LimesurveyRC: Is it possible to retrieve answer options with list_questions? was created by datamunger
I am working on an application where I need to retrieve the questions including answer options for a bunch of surveys in python. Currently, I have a nested loop that goes through each survey, and retrieves anweroptions for each qid within that survey. The query time for this is about 15 - 60 seconds per survey, whereas a simple list_questions query only takes a few seconds. Is there any way to retrieve the answeroptions alongside other question with the list_questions (or another) command to speed this process up, and to avoid bombarding the API with queries?
Currently, my API query looks like this:
Currently, my API query looks like this:
Code:
method = "get_question_properties" for i in surveyIDs: # surveyIDs is a list of the surveyIDs the user has access to # 'questions[i]' is a dataframe containing the results of a 'list_questions' query questions[i]['answeroptions'] = None # add column for answeroptions for index, row in questions[i].iterrows(): # for each question ID, we need to make a new API call row['answeroptions'] = api.query(method=method, params=OrderedDict([ ("sSessionKey", api.session_key), ("iQuestionID", row['qid']), ("aQuestionSettings", ['answeroptions']) ]))['answeroptions'] if row['answeroptions'] == 'No available answer options': # if no answer options are provided, we try to use the parent's answer options (e.g. array questions) try: row['answeroptions'] = questions[i][questions[i]['qid']==row['parent_qid']]['answeroptions'].reset_index(drop=True)[0] except: row['answeroptions'] = None # if this fails too (usually means there is no parent, and the question is not a real question), set it to None
Last edit: 4 years 8 months ago by datamunger.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
4 years 8 months ago #187770
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic LimesurveyRC: Is it possible to retrieve answer options with list_questions?
You can create your own extended function for remotecontrol :
extensions.sondages.pro/development-and-...i/documentation.html
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- datamunger
- Topic Author
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
4 years 7 months ago #187826
by datamunger
Replied by datamunger on topic LimesurveyRC: Is it possible to retrieve answer options with list_questions?
Thanks! Unfortunately, I am not the administrator of this installation, so I don't have the kind of access that would enable me to do this.
The topic has been locked.