Stream: questionnaire
Topic: enableWhen for repeated groups?
Spencer Evans (Oct 21 2019 at 23:46):
What should the behavior be for determining "shouldEnable" when either/one of/both the "enableWhen item" and the "conditioned upon question" are within repeatable groups?
Quick terminology clarification:
- I'm using "enableWhen item" to mean the item that has an enableWhen condition in it and "conditioned upon question" to be the item referenced via linkId by item.enableWhen.question.
As I see it there are four possible scenarios:
- the enableWhen item and the conditioned upon question are nested within the same repeatable group.
- the enableWhen item is not within any repeatable group, but the conditioned upon question is.
- the enableWhen item and the conditioned upon question are both in separate repeatable groups.
- the enableWhen item is within a repeatable group but the conditioned upon question is not.
what I might expect, but is not clear from the spec is:
- the enableWhen item should only be enabled when the corresponding conditioned upon question meets the given criteria. Determine the corresponding question via the index of the repeated item (seems like there could be a lot of complexity here). Potentially could also rely on the hierarchy to determine the correct condition upon question to derive behavior from.
- potentially use whatever is specified by enableBehavior (though it seems like it wasn't exactly intended for this purpose) but since that need not necessarily be set just b/c repeat === true, implementors decide on a default?
- try to use indices again, same as in situation 1
- all enableWhen items toggle on/off when the conditioned upon question changes to meet/not meet the given criteria.
I'd be curious if anyone else has run into this or have thoughts on a proper implementation?
Lloyd McKenzie (Oct 22 2019 at 03:21):
We probably need to provide guidance on that. In general, if the referenced enableWhen conditions repeat for a single question, my leaning would be that the answers are "or"ed across the repetitions. (And if that's not what you want, use the enableWhenExpression extension to define different behavior)
Paul Lynch (Oct 22 2019 at 15:20):
The description for enableWhen says,
If multiple question occurrences are present for the same question (same linkId), then this refers to the nearest question occurrence reachable by tracing first the "ancestor" axis and then the "preceding" axis and then the "following" axis.
That seems to imply that just one question with the specified linkId is considered.
Lloyd McKenzie (Oct 22 2019 at 15:23):
True. Though if pointing to something in a repeating group, that behaviour would be rather odd...
Last updated: Apr 12 2022 at 19:14 UTC