open-demographics icon indicating copy to clipboard operation
open-demographics copied to clipboard

JSON standard for formatting questions

Open drnikki opened this issue 6 years ago • 6 comments

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.

drnikki avatar May 17 '18 19:05 drnikki

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 avatar Jun 01 '18 19:06 hestenet

@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"} ]},

drnikki avatar Jun 01 '18 21:06 drnikki

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 avatar Jun 02 '18 18:06 drnikki

@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.

  1. inputex-json-schema

mradcliffe avatar Jun 02 '18 19:06 mradcliffe

@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.

drnikki avatar Jun 02 '18 19:06 drnikki

Please see #43 , #44 , #45 (and the rest of the stuff in the JSON Endpoint milestone) for specific aspects of the JSON schema.

drnikki avatar Jun 02 '18 20:06 drnikki