Skip to content

Master mk 2790 #2805

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 Google LLC
* Copyright 2023-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -146,6 +146,9 @@ class DemoQuestionnaireFragment : Fragment() {
.LOCATION_WIDGET_PROVIDER,
)
setQuestionnaire(args.questionnaireJsonStringKey!!)
if (args.questionnaireTitleKey == "Attachment") {
showReviewPageBeforeSubmit(true)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

change this back - this is the attachment widget, and we're not trying to show the review page when the user opens the attachment widget.

but we can add the attachment widget to the review page questionnaire, and i think that's reasonable.

}
.build()
add(R.id.container, questionnaireFragment, QUESTIONNAIRE_FRAGMENT_TAG)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 Google LLC
* Copyright 2023-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -195,7 +195,11 @@ data class QuestionnaireViewItem(
* if question is answered else 'Not Answered'
*/
fun answerString(context: Context): String {
if (!questionnaireResponseItem.hasAnswer()) return context.getString(R.string.not_answered)
if (!questionnaireResponseItem.hasAnswer()) {
return context.getString(R.string.not_answered)
} else if (questionnaireItem.type == Questionnaire.QuestionnaireItemType.ATTACHMENT) {
return context.getString(R.string.answered)
}
Comment on lines +200 to +202
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
} else if (questionnaireItem.type == Questionnaire.QuestionnaireItemType.ATTACHMENT) {
return context.getString(R.string.answered)
}
}
if (questionnaireItem.type == Questionnaire.QuestionnaireItemType.ATTACHMENT) {
return context.getString(R.string.answered)
}

return questionnaireResponseItem.answer.joinToString { it.value.displayString(context) }
}

Expand Down
3 changes: 2 additions & 1 deletion datacapture/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<!-- 2. The following sections include strings used in widgets -->

<!-- 2.1 All Widgets -->
<string name="not_answered">"Not Answered"</string>
<string name="not_answered">Not Answered</string>
<string name="answered">Answered</string>
<string name="help">Help</string>

<!-- 2.2 Boolean -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022-2024 Google LLC
* Copyright 2022-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1003,4 +1003,20 @@ class QuestionnaireViewItemTest {
)
.isTrue()
}

@Test
fun `answerString() should return answered with answered`() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
fun `answerString() should return answered with answered`() {
fun `answerString() should return answered with answered`() {

val questionnaireViewItem =
QuestionnaireViewItem(
Questionnaire.QuestionnaireItemComponent(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

you need to set the type to attachment

QuestionnaireResponse.QuestionnaireResponseItemComponent()
.addAnswer(
QuestionnaireResponse.QuestionnaireResponseItemAnswerComponent()
.setValue(StringType("Attachment")),
),
validationResult = Valid,
answersChangedCallback = { _, _, _, _ -> },
)
assertThat(questionnaireViewItem.answerString(context)).isEqualTo("Attachment")
}
}
Loading