Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output a string bind type for selects #410

Merged
merged 3 commits into from
Jan 27, 2020
Merged

Conversation

yanokwa
Copy link
Contributor

@yanokwa yanokwa commented Dec 20, 2019

Closes #168

@lognaturel lognaturel changed the title Issue 168 Output a string bind type for select1s Dec 20, 2019
@lognaturel lognaturel changed the title Output a string bind type for select1s Output a string bind type for selects Dec 20, 2019
@lognaturel
Copy link
Contributor

lognaturel commented Jan 19, 2020

I am running the failing test with nosetests pyxform.tests.xform2json_test.DumpAndLoadXForm2JsonTests. It looks like SurveyElement._link_children is hitting a case where something that was previously a SurveyElement is now a dict. I thought it might have something to do with the presence of or_other but I think this affects any select.

For example, in the specify_other.xls case, I see the following json generated for the male choice when the tests pass:
{'name': 'male', 'compact_tag': '', 'sms_field': '', 'sms_option': '', 'label': {'English': 'Male'}, 'hint': '', 'guidance_hint': '', 'default': '', 'type': '', 'appearance': '', 'parameters': '', 'intent': '', 'jr:count': '', 'bind': {}, 'instance': {}, 'control': {}, 'media': {}, 'parent': None, 'children': [], 'itemset': '', 'choice_filter': '', 'query': '', 'autoplay': '', 'flat': False, 'action': '', 'list_name': ''}

This suggests to me that select choices are being represented as SurveyElement objects which do have children attributes.

When the tests fail, select choices are represented as dictionaries:
{'name': 'male', 'label': {'English': 'Male'}}

I don't know why a select choice would be represented as a SurveyElement or why that json output would be desirable. I don't believe that any of the SurveyElement attributes could be populated.

XForm2json support is experimental and as far as I know, it is unused. There are three forms in that test that contain selects and thus result in the failure: specify_other.xls, loop.xls, xlsform_spec_test.xlsx, yes_or_no_question.xls

@lognaturel
Copy link
Contributor

The XForms to json functionality was using the bind type rather than the body type to identify selects. I have added a commit to override this. I have run nosetests locally and confirmed they pass. I have also run black pyxform.

I fully expect that some other downstream integrations use the bind type this way. We just need to be ready to react when folks run into issues.

@yanokwa yanokwa merged commit 8fb7934 into XLSForm:master Jan 27, 2020
@yanokwa yanokwa deleted the issue-168 branch January 28, 2020 19:12
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 25, 2020
Change SELECT_ONE and SELECT_MULTIPLE bind type to 'string'. More
Info: XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 25, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 26, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 26, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 27, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 2, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 3, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 3, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 13, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 27, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 27, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 27, 2020
Add MULTI_SELECT_TYPE and SELECT_BIND_TYPE tags removing the previously
used SELECT_ONE and SELECT_MULTIPLE variables. More info:
XLSForm/pyxform#410
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bind for select1 nodeset is "select1" and this throws an XForms syntax error
2 participants