By this we wanted to generate the following concern, with the survey solutions api, we use the end point:
to get the information, but when we try to get the information of a survey, in the variable that we declare in the following image (ge01) of type Multiple choice (Yes/No).
It brings us the information in a text array with all the options (Direct payment from the pocket or discounted by payroll, Scholarship, Credit or loan, Free higher education, Free school or preschool, Contribution in money from another household (relatives, friends, etc.)), but it does not declare which ones were selected with Yes or NO.
Our question is: is there a way to obtain this answer from the API, and if not, how could we obtain this data without having to incur in the downloads provided by HQ?
I have no context as to what you are trying to do. But I wanted to point that the following is not accurate:
Notice the pipe character | in the middle of the answer. I’ve marked the YES and NO portions in the graphics stored in the GitHub ticket. Provided that your options don’t have a pipe character in them, you could:
Parse the response to separate into YES and NO options by locating the | character (YES selections are before it and NO selections are after it).
Treat each part as a collection of items delimited by commas, where you need to find the ones from your questionnaire template and replace back with numeric codes. This could be a bit more challenging in the case where the items themselves may contain embedded commas, and this looks like your case:
Contribution in money from another household (relatives, friends, etc.))
This should still be solvable, unless you have categories like:
- 1 Free
- 2 loan
- 3 Free, loan
(in which case the combination “Free, loan” can be satisfy both situations of 1 and 2 being selected, or just 3 being selected). Capitalization for the items helps preventing such collisions.
If your questionnaire is multilingual, take this into account when matching the textual labels in step Nr.2 above.
If you are currently at the stage where the questionnaire can still be modified and you absolutely must go this way, you could include the categories’ codes into the categories’ labels like “[7] Scholarship”, which will make it much easier to parse the content later.
In practice it may be simpler to export an interview with the export procedure, but this seems to be the step that you’ve specifically prohibiting (for reasons beyond my knowledge):
This would be the last resort measure if your categories did possibly include a pipe character in their textual labels, which would be a rather exotic, but still possible case.
Thanks Sergiy, we generated a review with the information that we download from the API, and correspond the data with the logic that you gave us, we will generate a couple more tests, and we intend to generate a preload data, of this same variable.
Dear @sergiy , first of all thank you for the help provided above, and from the same we have the following query, when trying to preload the data of the variable with which we created the thread of this topic, it brings us error.
We tried to preload it through the api by means of the following endpoint:
We have tried several ways, starting by sending the data as it arrives to us:
All the described options do not allow us to preload the data, how could this kind of variables be preloaded from the api, we have generated tests in version 23.09 and version 25.01
we remain attentive to your comments, thank you in advance
to preload a multiselect question with Y/N representation via Survey Solutions API, supply your preloading data as an array of strings, each having items of the form: code->const where:
code is the numeric option code that was specified in the Designer,
Note that the order of selection (for ordered questions) is not specified, and the program takes the order of items from their mentioning in the string that you provide (this guarantees no gaps in selection orders). In the example above, option 5 was the first positively selected, hence it is “selection nr. 1” and option 4 was the second positively selected, hence it is “selection nr. 2”.
We’d like to thank you for the response you provided. We’ve run the first tests and the results have been positive. We’ll carry out more tests, but we already want to express our sincere thanks for your support and help.