Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass original response items instead of copy to getEnabledResponses #1787

Merged
merged 0 commits into from
Mar 30, 2023

Conversation

joiskash
Copy link
Collaborator

@joiskash joiskash commented Jan 3, 2023

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #1776

Description
In getQuestionnaireResponse we are passing the questionnaire response items of the copy of the quesitonnaireResponse and in the EnablementEvaluator we create the questionnaireResponseItemPreOrderList and questionnaireResponseItemParentMap from the questionnaireResponse. This would result in itemIndex = -1 for all indexOf search, since we are trying to search for objects in the original list whereas the list item that is being searched for is part of the copy list.
The code change is to pass [email protected] . This will search for items in the original list and the enablementEvaluator will work as expected

Alternative(s) considered
No

Type
Choose one: Bug fix

Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@jingtang10
Copy link
Collaborator

ok so i think the root cause of this bug is actually here:

val enablementEvaluator = EnablementEvaluator(questionnaireResponse)

where we are creating the enablement evaluator from the questionnaire response in the view model.

this kinda means that the current interface (if we see it as an internal/private interface) of getEnabledResponseItems is kinda broken. it only works if questionnaire response items passed to it belong to the questionnaire response in the view model.

maybe create another wrapper function in which you create the evaluator and then make the current function take an enablement evaluator with the condition that it is created from the same questionnaire response?

@jingtang10 jingtang10 assigned joiskash and unassigned jingtang10 Jan 5, 2023
Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment.

also would be excellent if we have a test case that can catch this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants