Open stevenglover opened 4 years ago
Good suggestion! A few thoughts on how to implement.
other
right? Cause that would mean that we can only do this test on English language forms. Or is there another way?I think it is not too difficult to implement a test for if specify other exist, once we have comprehensively laid out the case how that field can appear.
The most difficult part to code is to test if it is coded correctly, as there could be different styles, multiple conditions (e.g. only ask for specify other if two conditions apply) etc. That part I think is more difficult to implement. Unless we give a warning for all cases that is not coded like the most simple case, and then the user has to ignore the false positives.
Instead of testing on a string, I would test on a unique value assigned to all 'other' option choices. For example, the surveys I program always have -9 for 'other', -8: don't know, -7: refuse, etc... So in this case the test for whether the text specify other field exists could then be for whether the relevance expression exists in any text field for this value. This would require the survey to have a unique value for 'other' choices, and this value to be defined in the ietestform command by the user.
So my idea would be that if a select_one or _multiple has 'othervalue' as a potential choice, then a text field would have either ${question} = 'othervalue'
or selected(${question}, 'othervalue')
as the relevance. I think this would overcome the issues you mention about the text field not coming directly after.
As you mention, it will be difficult to account for all situations, so therefore best probably to flag as warnings for incorrect cases. Perhaps output like this would be informative:
Check that there is an associated text field whenever 'other' is listed as a choice in a select_one or _multiple fields. Generate warning if text field doesn't exist or relevance isn't coded correctly.
I suppose this would need users to define a standard value that 'other, specify' is coded as in the input to running iefieldkit.