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

Add boolean type widget with support for error correction (unselect by tapping again) #781

Merged
merged 21 commits into from
Nov 24, 2021

Conversation

maanuanubhav999
Copy link
Contributor

@maanuanubhav999 maanuanubhav999 commented Sep 11, 2021

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

Fixes #530

Description
Added Boolean type widget which would replace checkbox type widget.

Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
#546

Type
Choose one:Bug fix

Screenshots (if applicable)
image

Checklist

  • I have read and acknowledged the Code of conduct
  • I have read How to Contribute
  • I have read the Developer's guide
  • 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 reference app(s) to verify my change fixes the issue and/or does not break the reference app(s)

@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2021

Codecov Report

Merging #781 (33c0b29) into master (1945917) will decrease coverage by 0.21%.
The diff coverage is 56.92%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #781      +/-   ##
============================================
- Coverage     88.78%   88.56%   -0.22%     
- Complexity      467      469       +2     
============================================
  Files           106      107       +1     
  Lines          9095     9157      +62     
  Branches        580      611      +31     
============================================
+ Hits           8075     8110      +35     
  Misses          715      715              
- Partials        305      332      +27     
Impacted Files Coverage Δ
...droid/fhir/datacapture/QuestionnaireItemAdapter.kt 53.62% <50.00%> (ø)
...tionnaireItemBooleanTypePickerViewHolderFactory.kt 56.45% <56.45%> (ø)
...hir/datacapture/QuestionnaireItemViewHolderType.kt 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1945917...33c0b29. Read the comment docs.

@Tarun-Bhardwaj Tarun-Bhardwaj added this to In progress in Data capture library via automation Sep 15, 2021
@maanuanubhav999
Copy link
Contributor Author

Do we have to add "Not answered" even in the check box type?

I have not yet added it. Since users can unselect the check box and remove answers unlike radio groups or dropdown.
But we may add it if we want uniformity in all the choice types.

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.

Thanks @maanuanubhav999! 👍 A couple of high-level comments:

  1. Can you please remove QuestionnaireItemCheckBoxViewHolderFactory and all references to it?
  2. Can you reuse QuestionnaireItemRadioGroupviewHolderFactory instead of creating a new widget type (QuestionnaireItemBooleanTypePickerViewHolderFactory)? The new widget factory you created does pretty much what the radio group does. I think the only difference is that if the question is boolean type it needs to generate two answer options true/false, and you have to translate them to the correct answers when the user answers the questions.

@jingtang10
Copy link
Collaborator

Do we have to add "Not answered" even in the check box type?

I have not yet added it. Since users can unselect the check box and remove answers unlike radio groups or dropdown. But we may add it if we want uniformity in all the choice types.

If you're talking about checkox group - you're right we don't need not answered option, because the user can just untick everything. If you're talking about a single checkbox - I think we should just get rid of it since there won't be any use for it (I commented in my review already).

@jingtang10
Copy link
Collaborator

Please also rename your PR title to something that reads better e.g. "Add 'not answered' option to radio button group and use it for boolean type questions"

@maanuanubhav999 maanuanubhav999 changed the title Ma/add not answered or clear Add 'not answered' option to radio button group and use it for boolean type questions Sep 30, 2021
@jingtang10
Copy link
Collaborator

HI @maanuanubhav999 -- thanks for working on this! any update on changing this to use the existing radio button group widget?

@maanuanubhav999
Copy link
Contributor Author

Hey, @jingtang10 I will try to complete it in 2-3 days.

@jingtang10
Copy link
Collaborator

@shelaghm and I are discussing some alternative solutions - will update and hopefully will provide some mocks to guide implementation

@maanuanubhav999
Copy link
Contributor Author

Okay, that would be great!

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.

thanks so much for this - can you add a couple of screenshots for your new widget?

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.

Thanks very much for perseverance - this should be the last round of comments.

Following the same design pattern of the yes/no radio button, I don't believe we want to add another radio button for the radio button group. I would suggest revert the changes for the radio button group and drop down and create two separate issues (and raise 2 separate PRs if you wish) for them.

questionnaireItemViewItem.singleAnswerOrNull?.valueBooleanType?.value ?: false
val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem
val answer = questionnaireResponseItem.answer.singleOrNull()?.valueBooleanType
boolTypeHeader.text = questionnaireItem.localizedText
Copy link
Collaborator

Choose a reason for hiding this comment

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

move this 2 lines above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, didn't get this, why would we need to shift this? @jingtang10

Copy link
Collaborator

Choose a reason for hiding this comment

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

can you move this line to the top:

val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem

so that the if else block can use questionnaireItem rather than questionnaireItemViewItem.questionnaireItem

also, move boolTypeHeader setup before the answer setup because that's consistent with the order of the widgets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, also removed answer since it was not needed anywhere.

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.

did you push the changes addressing the comments from the previous review? i can't seem to see any.

thanks!

questionnaireItemViewItem.singleAnswerOrNull?.valueBooleanType?.value ?: false
val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem
val answer = questionnaireResponseItem.answer.singleOrNull()?.valueBooleanType
boolTypeHeader.text = questionnaireItem.localizedText
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you move this line to the top:

val (questionnaireItem, questionnaireResponseItem) = questionnaireItemViewItem

so that the if else block can use questionnaireItem rather than questionnaireItemViewItem.questionnaireItem

also, move boolTypeHeader setup before the answer setup because that's consistent with the order of the widgets.

@maanuanubhav999 maanuanubhav999 changed the title Add 'not answered' option to radio button group, drop down and add boolean type widget Add boolean type widget with support for error correction (unselect by tapping again) Nov 22, 2021
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.

Great work! Thanks @maanuanubhav999! 👍 🎉

@jingtang10 jingtang10 enabled auto-merge (squash) November 24, 2021 17:34
@jingtang10 jingtang10 merged commit e1d1530 into google:master Nov 24, 2021
Data capture library automation moved this from In progress to Done Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Nested items are still revealed after deselecting / removing the answer for the parent item
5 participants