Parsing, enforcing constraints etc. formDef.json in ODK Survey

Hi all,

I am very new to ODK, so i do apologize if some of this are elementary questions. From what i have been able to understand from wikis, github and old posts here is what i have understood so far:

Here is my question. In ODK Collect world, the collect app uses javarosa code to parse XML on the client and do things like constraint enforcement. What is the equivalent in ODK Survey ? I am looking in ODK Survey code, as well as in androidcommon and androidlibrary. Is the JSON parsing, validation part of one of these modules ? I will continue digging into the code but would appreciate some pointers.

Thanks
-Giri

Apologies for double post. There was some eventual consistency with google
groups with my first post (did not show up) and i thought it failed. Sorry
did not mean to spam.

··· On Tuesday, July 12, 2016 at 9:25:41 AM UTC-7, Giri Anantharaman wrote: > > Hi all, > > I am very new to ODK, so i do apologize if some of this are elementary > questions. From what i have been able to understand from wikis, github and > old posts here is what i have understood so far: > > - ODK 2.0 uses JSON serialization for surveys (unlike XForm XML in ODK > Collect). > > - The JSON schema is documented to some extent in wiki here - > https://github.com/opendatakit/opendatakit/wiki/ODK-2.0-Form-Specification > > - Since formDef.json is generated from XLSX, documentation is the source > of schema truth to some extent. I could locate this from the latest > distribution. > https://opendatakit.org/use/2_0_tools/active-distribution/application-designer-rev-204/xlsx-converter-rev-204/ > > Here is my question. In ODK Collect world, the collect app uses javarosa > code to parse XML on the client and do things like constraint enforcement. > What is the equivalent in ODK Survey ? I am looking in ODK Survey code, as > well as in androidcommon and androidlibrary. Is the JSON parsing, > validation part of one of these modules ? I will continue digging into the > code but would appreciate some pointers. > > Thanks > -Giri >

Thank you Clarice.

··· On Tuesday, July 12, 2016 at 9:25:41 AM UTC-7, Giri Anantharaman wrote: > > Hi all, > > I am very new to ODK, so i do apologize if some of this are elementary > questions. From what i have been able to understand from wikis, github and > old posts here is what i have understood so far: > > - ODK 2.0 uses JSON serialization for surveys (unlike XForm XML in ODK > Collect). > > - The JSON schema is documented to some extent in wiki here - > https://github.com/opendatakit/opendatakit/wiki/ODK-2.0-Form-Specification > > - Since formDef.json is generated from XLSX, documentation is the source > of schema truth to some extent. I could locate this from the latest > distribution. > https://opendatakit.org/use/2_0_tools/active-distribution/application-designer-rev-204/xlsx-converter-rev-204/ > > Here is my question. In ODK Collect world, the collect app uses javarosa > code to parse XML on the client and do things like constraint enforcement. > What is the equivalent in ODK Survey ? I am looking in ODK Survey code, as > well as in androidcommon and androidlibrary. Is the JSON parsing, > validation part of one of these modules ? I will continue digging into the > code but would appreciate some pointers. > > Thanks > -Giri >

In ODK Survey, a lot of the functionality that you are looking for exists
in the JavaScript code. The repo that you will want to look at is the
App-Designer (https://github.com/opendatakit/app-designer). The code
responsible for generating the formDef.json that Survey uses can be found
at
https://github.com/opendatakit/app-designer/blob/master/xlsxconverter/XLSXConverter2.js.
Survey then uses the formDef.json to render and navigate through the form.
In terms of where to look for the code that does the validation for most
prompts, that can be found at
https://github.com/opendatakit/app-designer/blob/master/app/system/survey/js/prompts.js.
The function that you will want to take a look at is _isValid(isStrict).

Clarice

··· On Tue, Jul 12, 2016 at 9:36 AM, Giri Anantharaman wrote:

Apologies for double post. There was some eventual consistency with google
groups with my first post (did not show up) and i thought it failed. Sorry
did not mean to spam.

On Tuesday, July 12, 2016 at 9:25:41 AM UTC-7, Giri Anantharaman wrote:

Hi all,

I am very new to ODK, so i do apologize if some of this are elementary
questions. From what i have been able to understand from wikis, github and
old posts here is what i have understood so far:

Here is my question. In ODK Collect world, the collect app uses javarosa
code to parse XML on the client and do things like constraint enforcement.
What is the equivalent in ODK Survey ? I am looking in ODK Survey code, as
well as in androidcommon and androidlibrary. Is the JSON parsing,
validation part of one of these modules ? I will continue digging into the
code but would appreciate some pointers.

Thanks
-Giri

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi Clarice

Thanks so much for quick response. One more thing. Are you saying that ODK
Survey android code base actually does the formDef.json parsing and
validation (say against constraints) in javascript ? Reason i ask is that i
do not find any js code in https://github.com/opendatakit/survey ?

-Giri

··· On Tuesday, July 12, 2016 at 11:53:14 AM UTC-7, clarice larson wrote: > > In ODK Survey, a lot of the functionality that you are looking for exists > in the JavaScript code. The repo that you will want to look at is the > App-Designer (https://github.com/opendatakit/app-designer). The code > responsible for generating the formDef.json that Survey uses can be found > at > https://github.com/opendatakit/app-designer/blob/master/xlsxconverter/XLSXConverter2.js. > Survey then uses the formDef.json to render and navigate through the form. > In terms of where to look for the code that does the validation for most > prompts, that can be found at > https://github.com/opendatakit/app-designer/blob/master/app/system/survey/js/prompts.js. > The function that you will want to take a look at is _isValid(isStrict). > > Clarice > > On Tue, Jul 12, 2016 at 9:36 AM, Giri Anantharaman <gi...@premise.com > wrote: > >> Apologies for double post. There was some eventual consistency with >> google groups with my first post (did not show up) and i thought it failed. >> Sorry did not mean to spam. >> >> >> On Tuesday, July 12, 2016 at 9:25:41 AM UTC-7, Giri Anantharaman wrote: >>> >>> Hi all, >>> >>> I am very new to ODK, so i do apologize if some of this are elementary >>> questions. From what i have been able to understand from wikis, github and >>> old posts here is what i have understood so far: >>> >>> - ODK 2.0 uses JSON serialization for surveys (unlike XForm XML in ODK >>> Collect). >>> >>> - The JSON schema is documented to some extent in wiki here - >>> https://github.com/opendatakit/opendatakit/wiki/ODK-2.0-Form-Specification >>> >>> - Since formDef.json is generated from XLSX, documentation is the source >>> of schema truth to some extent. I could locate this from the latest >>> distribution. >>> https://opendatakit.org/use/2_0_tools/active-distribution/application-designer-rev-204/xlsx-converter-rev-204/ >>> >>> Here is my question. In ODK Collect world, the collect app uses javarosa >>> code to parse XML on the client and do things like constraint enforcement. >>> What is the equivalent in ODK Survey ? I am looking in ODK Survey code, as >>> well as in androidcommon and androidlibrary. Is the JSON parsing, >>> validation part of one of these modules ? I will continue digging into the >>> code but would appreciate some pointers. >>> >>> Thanks >>> -Giri >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "ODK Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to opendatakit-developers+unsubscribe@googlegroups.com >> . >> For more options, visit https://groups.google.com/d/optout. >> > >

Yes, we use an Android WebView to render and parse the formDef.json. The
actual JavaScript code is bundled into the Survey APK via two different zip
files (configzip and sytemzip) which can be found at
https://github.com/opendatakit/survey/tree/master/survey_app/src/main/res/raw.

Clarice

··· On Tue, Jul 12, 2016 at 3:43 PM, Giri Anantharaman wrote:

Hi Clarice

Thanks so much for quick response. One more thing. Are you saying that ODK
Survey android code base actually does the formDef.json parsing and
validation (say against constraints) in javascript ? Reason i ask is that i
do not find any js code in https://github.com/opendatakit/survey ?

-Giri

On Tuesday, July 12, 2016 at 11:53:14 AM UTC-7, clarice larson wrote:

In ODK Survey, a lot of the functionality that you are looking for exists
in the JavaScript code. The repo that you will want to look at is the
App-Designer (https://github.com/opendatakit/app-designer). The code
responsible for generating the formDef.json that Survey uses can be found
at
https://github.com/opendatakit/app-designer/blob/master/xlsxconverter/XLSXConverter2.js.
Survey then uses the formDef.json to render and navigate through the form.
In terms of where to look for the code that does the validation for most
prompts, that can be found at
https://github.com/opendatakit/app-designer/blob/master/app/system/survey/js/prompts.js.
The function that you will want to take a look at is _isValid(isStrict).

Clarice

On Tue, Jul 12, 2016 at 9:36 AM, Giri Anantharaman gi...@premise.com wrote:

Apologies for double post. There was some eventual consistency with
google groups with my first post (did not show up) and i thought it failed.
Sorry did not mean to spam.

On Tuesday, July 12, 2016 at 9:25:41 AM UTC-7, Giri Anantharaman wrote:

Hi all,

I am very new to ODK, so i do apologize if some of this are elementary
questions. From what i have been able to understand from wikis, github and
old posts here is what i have understood so far:

Here is my question. In ODK Collect world, the collect app uses
javarosa code to parse XML on the client and do things like constraint
enforcement. What is the equivalent in ODK Survey ? I am looking in ODK
Survey code, as well as in androidcommon and androidlibrary. Is the JSON
parsing, validation part of one of these modules ? I will continue digging
into the code but would appreciate some pointers.

Thanks
-Giri

--
You received this message because you are subscribed to the Google
Groups "ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.