XLSForm / pyxform

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

Improve error message when a question's label and/or hint is missing #334

Open jim-moore opened 5 years ago

jim-moore commented 5 years ago

The validation error message returned when a question's label is missing is misleading - it suggests that either a label or a hint is required. As per the XLSForm spec, only the label is mandatory (the hint is not).

If a question has a hint but no label, a different warning message is returned. This message should be the same regardless of whether the question has a hint or not.

Suggest changing the error message to be the same in both instances, for example:

The survey element named '<question name>' has no label.

Examples from Survey123 Connect

Both label and hint missing:

Error converting XLSForm The survey element named 'question1' has no label or hint.

No label or hint error

Question has a hint but label is missing:

XLSForm converted with warnings [row : 2] Question has no label: {u'type': u'text', u'name': u'question1', u'hint': u'Test'}

No label warning

nribeka commented 5 years ago

The fix is not going in this repo I think. The validator is calling the odk-validate which in turn will call the javarosa code base.

jim-moore commented 5 years ago

Thanks @nribeka

Looking at the code, it appears the error checks and messages are in this repo:

https://github.com/XLSForm/pyxform/blob/2b741999779d36dc2e7ef5df2036ef4e37f44069/pyxform/survey_element.py#L371-L372

https://github.com/XLSForm/pyxform/blob/077972c59970d445f1b1fe48e8a42937490e6769/pyxform/xls2json.py#L836-L846

nribeka commented 5 years ago

@jim-moore wow! I thought the message was coming from the odk validator! Thank you for pointing this.