open-demographics
open-demographics copied to clipboard
JSON standard for formatting questions
in #37, @rwholeb proposed a format for recording the question in JSON. As a precursor to that, can we identify the data points we'll need to store about a question first?
A starting list:
- id
- question prompt
- description
- format (radio buttons, check boxes)
- options -- user-facing text -- option id -- other?
There are existing libraries/projects to generate forms from JSON schemas, and we could take as much or as little of that as we need: http://clicrdv.github.io/inputex/docs/ for example.
InputEx seems like a promising example to work from. http://clicrdv.github.io/inputex/docs/inputex-jsonschema/jsonschema-1.html is a good example schema in particular.
@hestenet Yes, it's a good schema, but the questions are less complex than ours, it seems like - this is designed to push an entire form rather than one question or question set.
I noticed that the choices doesn't specify a UI element type.
"gender" : { "type":"string", "choices": [ {"value":"male","label":"Guy"}, {"value":"female","label":"Girl"} ]},
I need a review/JSON thoughts on https://github.com/drnikki/open-demographics/blob/json-standard/doc-source/references/example.json This is an abbreviated (in terms of choices listed) representation of the age, religion and disability questions which I think contain all of the permutations of question UI formats we have identified.
@drnikki, do you think that the _inputex property would allow to override the UI element type? I am not familiar with inputEx enough, but this example seems promising:
Use the "_inputEx" attribute on json-schema properties. This object will override inputEx' default properties in the field definition. You may also override the inputEx type through the "_type" attribute.
"born" : { "type":"string", "format":"date", "optional":true, "_inputex": {"_type": "datepicker", valueFormat: 'Y-m-d', value: '2009-01-01', label: 'Birthdate'} },
1.
I do not know if using this property is appropriate or not. I think that various software implementations could map storage and input definitions into a format.
@mradcliffe thanks for looking! that's a great question - I certainly don't know if folks consuming the API would be using inputex, but I think the idea of suggesting a date or default value is on point.
Please see #43 , #44 , #45 (and the rest of the stuff in the JSON Endpoint milestone) for specific aspects of the JSON schema.