We are currently working on project where a web user creates a survey which has cascading questions (cascading means questions that have few answers and depend on those answers rest of the questions changes) and then mobile users should get this survey in their android app. Sample JSON
structure we thought is as follows:
{
"status": "1",
"tabs": [
"Farmer Information",
"Signature",
"Crop Details",
"Land Parcel"
],
"survey":[
{
"type": "TextView",
"cascade": "0",
"value": "What is your name?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "What is your age?",
"survey" : ""
},
{
"type": "RadioButtonGroup",
"cascade": "1",
"value": "Do you have kids?",
"survey" : [
{
"type": "TextView",
"cascade": "1",
"value": "YES",
"survey": [
{
"type": "TextView",
"cascade": "1",
"value": "How many of them below 18?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "How many of them are girls?",
"survey" : ""
},
{
"type": "TextView",
"cascade": "1",
"value": "Where do you live in?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "How long you were there?",
"survey" : ""
}
]
},
{
"type": "TextView",
"cascade": "0",
"value": "NO",
"survey" : [
{
"type": "TextView",
"cascade": "1",
"value": "Where do you live in?",
"survey": ""
},
{
"type": "TextView",
"cascade": "0",
"value": "How long you were there?",
"survey" : ""
}
]
}
]
}
]
}
Is there anyway to achieve such a thing? What are the most suitable library which can be used for this scenario? We tried json2view, proteus. From all those we can pass a json and load the view but if there are cascading questions non of them can use.
Furthermore elaborating in the question via an example:
Suppose the user is given the question of Do you have any have kids?
. This question has possible two answers. Yes
& No
depending upon the answer which user give others questions have to be loaded dynamically.