Skip to content

Commit

Permalink
Nested questionnaireResponseComponent with enableWhen in repeated gro…
Browse files Browse the repository at this point in the history
…up is missing from questionnaire response. (#1940)

* Nested questionnaireResponseComponent with enableWhen in repeated group is missing from questionnaire response.

* Add android test.

* Address review comments.

* Address review comments.

---------

Co-authored-by: Santosh Pingle <[email protected]>
  • Loading branch information
santosh-pingle and Santosh Pingle committed Apr 7, 2023
1 parent 0d00d7e commit 135feb2
Show file tree
Hide file tree
Showing 3 changed files with 382 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,14 @@ internal class QuestionnaireViewModel(application: Application, state: SavedStat
*/
fun getQuestionnaireResponse(): QuestionnaireResponse {
return questionnaireResponse.copy().apply {
item = getEnabledResponseItems(this@QuestionnaireViewModel.questionnaire.item, item)
// Use the view model's questionnaire and questionnaire response for calculating enabled items
// because the calculation relies on references to the questionnaire response items.
item =
getEnabledResponseItems(
this@QuestionnaireViewModel.questionnaire.item,
questionnaireResponse.item
)
.map { it.copy() }
unpackRepeatedGroups(this@QuestionnaireViewModel.questionnaire)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ internal class EnablementEvaluator(val questionnaireResponse: QuestionnaireRespo
questionnaireResponseItemParentMap[child] = item
buildParentList(child)
}
for (answer in item.answer) {
for (nestedItem in answer.item) {
buildParentList(nestedItem)
}
}
}

for (item in questionnaireResponse.item) {
Expand Down
Loading

0 comments on commit 135feb2

Please sign in to comment.