If suppose there are three questions and there are multiple checkbox for each question, how do I select all possibilities of checkboxes for these three questions?
So far I got all possible combinations for each question seperately.
For first question there are three answers. The possibilities are:
[A1]
[A2]
[A3]
[A1, A2]
[A1, A3]
[A2, A3]
[A1, A2, A3]
For second question there are two answers. The possibilities are:
[B1]
[B2]
[B1, B2]
So far I got these two lists. I can loop through each element of list using nested for loop to loop through each question:
for (int i = 0; i < questionAList.size(); i++) {
for (int j = 0; j < questionBList.size(); j++) {
// select questionA answer
// for each questionA answer select question B answer
}
}
This way I can select all the possible answers for multiple questions.
But this nested for loop works only if there are only two questions. How can I solve this with a more generic approach?
Here is what I have got so far:
{
"Q: Headache:" : {
"1" : "[wakes you up at night]",
"2" : "[about the same time of day]",
"3" : "[None of the above]",
"4" : "[wakes you up at night, about the same time of day]"
},
"Q: Confusion" : {
"1" : "[better with drinking fluids]",
"2" : "[better with rest]",
"3" : "[None of the above]",
"4" : "[better with drinking fluids, better with rest]"
},
"Q: Confusion associated with …" : {
"1" : "[HIV illness]",
"2" : "[None of the above]"
}
}
There is only combination for answer "None of the above".