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

Report the choice name in the JSON #354

Closed
wants to merge 19 commits into from

Conversation

qlands
Copy link
Contributor

@qlands qlands commented Aug 30, 2019

The current JSON output does not contain the list name for "normal" select_one or select_multiple variables. It is useful to have it specially if one wants to construct a data dictionary.

I used the same key ("query") as is already used by "select one external" types.

@codecov-io
Copy link

codecov-io commented Aug 30, 2019

Codecov Report

Merging #354 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #354      +/-   ##
==========================================
- Coverage   82.51%   82.49%   -0.02%     
==========================================
  Files          23       23              
  Lines        3255     3257       +2     
  Branches      758      758              
==========================================
+ Hits         2686     2687       +1     
  Misses        433      433              
- Partials      136      137       +1
Impacted Files Coverage Δ
pyxform/survey_element.py 90.36% <ø> (ø) ⬆️
pyxform/xls2json.py 77.95% <100%> (+0.06%) ⬆️
pyxform/xform2json.py 80.5% <0%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9fd520...5c31e99. Read the comment docs.

@lognaturel
Copy link
Contributor

lognaturel commented Sep 6, 2019

The query concept is introduced by the select one external feature and is not actually part of the form spec so I don't think it makes sense as an attribute name here.

In the case of dynamic selects, the name is exposed as itemset.

In the case of a static select, that name isn't used in the underlying XForms so that's probably why it wasn't exposed.

Perhaps list_name would be appropriate but I'm not sure it makes sense to expose something that doesn't exist in the underlying form. What are you using this for, @qlands?

I don't work on any tools that use the JSON representation. @jnm, you do, right? I think it's generally in an odd state and would be worth some cleanup if folks are depending on it.

@qlands
Copy link
Contributor Author

qlands commented Sep 6, 2019

Hi,

We use the JSON output extensively in our applications through ODK Tools which convert an ODK Excel Survey file into a MySQL database. The list name is used to create a child look-up table with the options that then is linked to the parent data-table. The list_name is important because we use it to name the look-up table.

I don't know who is the maintainer of the JSON part of pyxform but I would be happy to contribute if it does not have a patron.

I will upload the change to the PR soon.

@lognaturel
Copy link
Contributor

Thanks for that extra context, @qlands. I understand why in your case you'd want to represent the choice list once even though in the corresponding XForm it would be copied for each question that uses it. What I might do in that case is use a hash of the children to name the table. Could that possibly work for you?

In #203, I ask why static choice lists are ever generated. Another possible resolution to your issue would be to always generate secondary instances for choice lists since those do have names (accessible through itemset).

Because there is no concept corresponding to list_name in the XForm representation, I'm still not very comfortable with this but I'd like @jnm or @ukanga to chime in.

@qlands
Copy link
Contributor Author

qlands commented Sep 7, 2019

I could generate a hash as name but such name will not correspond to anything in the XLS form.

Secondary instances generate "itemset" or "query" however I cannot force users to a particular format for select. I understand that list_name is not part of XForm however I'm not asking to change the XForm representation just the JSON by adding the list name.

On other note: I ran black on my files....where can I check which file went without black?

@qlands
Copy link
Contributor Author

qlands commented Sep 7, 2019

Sorry people... I messes up with this PR. I will open other one cleaner without so many reverts!!!

@qlands qlands closed this Sep 7, 2019
@qlands qlands deleted the add_list_name_in_json branch September 7, 2019 00:40
@qlands qlands mentioned this pull request Sep 7, 2019
@qlands
Copy link
Contributor Author

qlands commented Sep 7, 2019

We can continue the discussion in #357 . Thanks.

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.

3 participants