XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
77 stars 134 forks source link

Warning given when converting a form with choices option with `image` but no `label` #610

Closed jkuester closed 2 years ago

jkuester commented 2 years ago

Software and hardware versions

pyxform v1.10.0, Python 3.8.10

Problem description

When converting a form that has options specified on the "choices" sheet that have a value for image but not for label, I see a warning:

Warnings:
On the choices sheet there is a option with no label. [list_name : a_b]

This happens when following the pattern from the example Enekto Widgets form where you can have a select question where the user picks based on images and there are no labels:

image

Steps to reproduce the problem

  1. Download the example Enketo Widgets form
  2. Convert it with xls2xform
  3. See warnings

Expected behavior

If the option has an image value, I would not expect to see a warning when there is no label value.

lindsay-stevens commented 2 years ago

Could you please add where the example widgets form is linked from? I can't seem to find it on the xlsforms docs, reference table, or xforms-spec pages.

The xlsforms docs page states that the label column is mandatory in the choices worksheet:

The choices worksheet has 3 mandatory columns as well: list name, name, and label.

  • The list name column lets you group together a set of related answer choices, i.e., answer choices that should appear together under a question.
  • The name column specifies the unique variable name for that answer choice.
  • The label column shows the answer choice exactly as you want it to appear on the form. Alternatively, label translation columns can be used.

However users may ignore warnings if they're sure that the form design is as desired.

If possible please add more info about your use case, particularly if the warning has started showing when it did not before.

jkuester commented 2 years ago

@lindsay-stevens Thanks for the response here! After looking at this some more, I am thinking that this is just an Enekto "feature" that is technically out-of-spec (thanks for your link regarding what is required in the choices worksheet!).

For the record, I cannot remember exactly where I first ran across the link to that example widgets form. But, it is a pretty commonly referenced example form in Enekto discussions.

An interesting counter-example is the bird watching form referenced by the xlsform media docs. That form contains a bunch of images in the choices sheet, but they all also have a label (which is then also displayed in the generated form). There is no example of a choice without a label.

Closing this since there does not seem to be any reason to expect pyxform to support behavior that is out-of-spec....

lognaturel commented 2 years ago

It is indeed acceptable to use an image in place of a label for either questions or choices. I think keeping the warning for that case is fine, though, because pyxform has no idea what the intent is.

The no-buttons appearance is intended to build grids of images and is generally used without labels. But pyxform generally passes through appearances and does no additional checks based on it so even then I think keeping the warning and avoiding too many special cases is fine.

The original All Widgets form is maintained here and linked to from the Collect repo and the ODK docs. It could also be linked from the XLSForm doc.

lognaturel commented 2 years ago

Huh, there's an Enketo bug (or maybe a form design bug?) -- the no-buttons appearance is supposed to not display buttons which it does for the second case in the screenshot but not the first.