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

PYXForm should fail if a choiceList has two or more choices sharing the same value. #23

Closed
mitchellsundt opened this issue Jan 31, 2015 · 3 comments · Fixed by #310
Closed

Comments

@mitchellsundt
Copy link
Contributor

When processing the XLSX file, it would be helpful if the conversion failed if a user has entered two rows in the choices sheet for a given choice list that have the same value.

The use case is someone copy-and-pasting a series of answers:

listA val1 Yes
listA val2 No
listA val2 Maybe

and not noticing that val2 is repeated twice (Maybe should be val3).

If we want to support the current mechanism where this is allowed, we should probably have
a settings tab flag that allows for duplicated choice values.

@dorey
Copy link
Contributor

dorey commented Jan 31, 2015

At one point we did something like this in koboform but there were cases where people want to be able to have multiple labels represented as the same value, and now I think a rule like this would be restrictive. Would it help to pass back a warning if duplicate values are used?

@mitchellsundt
Copy link
Contributor Author

Yes, if there is any way to get a warning back, that would be great.

I haven't been following how pyxform deals with external itemsets. If it wraps everything into a single zip, if the zip contained a warnings file, that would, I think, be helpful. Or if it produces multiple files, adding a warnings file for these sorts of things would be useful.

@dorey
Copy link
Contributor

dorey commented Sep 26, 2016

This is coming back and leading to a number of reported issues when users accidentally make bad forms.

I suggest we have a settings that protects the cases where duplicate choices are intended, and then we automatically reject forms with duplicate choice values.

# survey

...

# choices (example where duplicate choice values are desired)

| list_name |    value     |      label      |
|-----------|--------------|-----------------|
| age       | out_of_range | 0-20 years old  |
| age       | out_of_range | 21-40 years old |
| age       | out_of_range | 41-60 years old |
| age       | in_range     | 61-80 years old |
| age       | out_of_range | 80+ years old   |

# settings

| allow_choice_duplicates |
|-------------------------|
| Yes                     |

I'm proposing that if this setting is not present, this form would get rejected.

DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Fix failing tests related to the change in /meta/instanceID binding
  More info: XLSForm/pyxform#94
- Fix failing test related to a change in the PyXform error raised
  when an invalid XML tag is found. More info: XLSForm/pyxform#22
- Fix failing tests related to the 'allow_duplicate_choice' setting
  not being present. More info: XLSForm/pyxform#23
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Fix failing tests related to the change in /meta/instanceID binding
  More info: XLSForm/pyxform#94
- Fix failing test related to a change in the PyXform error raised
  when an invalid XML tag is found. More info: XLSForm/pyxform#22
- Fix failing tests related to the 'allow_duplicate_choice' setting
  not being present. More info: XLSForm/pyxform#23
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Fix failing tests related to the change in /meta/instanceID binding
  More info: XLSForm/pyxform#94
- Fix failing test related to a change in the PyXform error raised
  when an invalid XML tag is found. More info: XLSForm/pyxform#22
- Fix failing tests related to the 'allow_duplicate_choice' setting
  not being present. More info: XLSForm/pyxform#23
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
- Replace choice_filter.xls file with choice_filter.xlsx; Duplicate of
  choice_filter.xls with allow_duplicate_choices setting
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
- Replace choice_filter.xls file with choice_filter.xlsx; Duplicate of
  choice_filter.xls with allow_duplicate_choices setting
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Fix failing tests related to the change in /meta/instanceID binding
  More info: XLSForm/pyxform#94
- Fix failing test related to a change in the PyXform error raised
  when an invalid XML tag is found. More info: XLSForm/pyxform#22
- Fix failing tests related to the 'allow_duplicate_choice' setting
  not being present. More info: XLSForm/pyxform#23
DavisRayM added a commit to onaio/onadata that referenced this issue Jan 28, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
- Replace choice_filter.xls file with choice_filter.xlsx; Duplicate of
  choice_filter.xls with allow_duplicate_choices setting
DavisRayM added a commit to onaio/onadata that referenced this issue Feb 10, 2020
- Fix failing tests related to the change in /meta/instanceID binding
  More info: XLSForm/pyxform#94
- Fix failing test related to a change in the PyXform error raised
  when an invalid XML tag is found. More info: XLSForm/pyxform#22
- Fix failing tests related to the 'allow_duplicate_choice' setting
  not being present. More info: XLSForm/pyxform#23
DavisRayM added a commit to onaio/onadata that referenced this issue Feb 10, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
- Replace choice_filter.xls file with choice_filter.xlsx; Duplicate of
  choice_filter.xls with allow_duplicate_choices setting
DavisRayM added a commit to onaio/onadata that referenced this issue Feb 12, 2020
- Fix failing tests related to the change in /meta/instanceID binding
  More info: XLSForm/pyxform#94
- Fix failing test related to a change in the PyXform error raised
  when an invalid XML tag is found. More info: XLSForm/pyxform#22
- Fix failing tests related to the 'allow_duplicate_choice' setting
  not being present. More info: XLSForm/pyxform#23
DavisRayM added a commit to onaio/onadata that referenced this issue Feb 12, 2020
- Duplicate choice values are no longer allowed in PyXForm.
  More info: XLSForm/pyxform#23
- Rename new_cascading_select.xls to duplicate_choice_form.xls
- Replace choice_filter.xls file with choice_filter.xlsx; Duplicate of
  choice_filter.xls with allow_duplicate_choices setting
jnm added a commit to kobotoolbox/kobocat that referenced this issue May 25, 2021
* Recognize select questions from the question elements themselves
    instead of checking the bind type; see XLSForm/pyxform#168
* Recognize new error message when a group name matches the form name
    See XLSForm/pyxform#510
* Set `allow_choice_duplicates` to `yes` in cascade test XLSForms
    See XLSForm/pyxform#23; XLSForm/pyxform#373 (comment)
* Update tests to use `default_name` instead of relying on the XLSForm file name
    See XLSForm/pyxform#130
* Update expected XML in tests to match new pyxform behavior:
    * `<model>` becomes `<model odk:xforms-version="1.0.0">`
        * See XLSForm/pyxform#393
    * The bind type for `select` and `select1` becomes `string`
        * See XLSForm/pyxform#168
    * `calculate="concat('uuid:', uuid())"` becomes `jr:preload="uid"`
        * See XLSForm/pyxform#94

This squashed set of changes includes work from #699.
Thanks to @duvld for that contribution.
jnm added a commit to kobotoolbox/kobocat that referenced this issue May 25, 2021
* Recognize select questions from the question elements themselves
    instead of checking the bind type; see XLSForm/pyxform#168
* Recognize new error message when a group name matches the form name
    See XLSForm/pyxform#510
* Set `allow_choice_duplicates` to `yes` in cascade test XLSForms
    See XLSForm/pyxform#23; XLSForm/pyxform#373 (comment)
* Update tests to use `default_name` instead of relying on the XLSForm file name
    See XLSForm/pyxform#130
* Update expected XML in tests to match new pyxform behavior:
    * `<model>` becomes `<model odk:xforms-version="1.0.0">`
        * See XLSForm/pyxform#393
    * The bind type for `select` and `select1` becomes `string`
        * See XLSForm/pyxform#168
    * `calculate="concat('uuid:', uuid())"` becomes `jr:preload="uid"`
        * See XLSForm/pyxform#94

This squashed set of changes includes work from #699.
Thanks to @duvld for that contribution.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants