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

Fix #2324: Changes in Submitted Answer List Items [A11y] #3353

Merged
merged 3 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 20 additions & 11 deletions app/src/main/res/layout/submitted_answer_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/submitted_answer_background"
android:contentDescription="@{accessibleAnswer ?? submittedAnswer}"
android:contentDescription="@{viewModel.isCorrectAnswer() ? String.format(@string/correct_submitted_answer_with_append, accessibleAnswer.length() > 0 ? accessibleAnswer : submittedAnswer) : String.format(@string/incorrect_submitted_answer_with_append, accessibleAnswer.length() > 0 ? accessibleAnswer : submittedAnswer)}"
android:padding="12dp"
android:text="@{submittedAnswer}"
android:textColor="@color/oppiaPrimaryText"
Expand All @@ -67,26 +67,35 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/submitted_answer_recycler_view"
<LinearLayout
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
android:id="@+id/submitted_answer_recycler_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/submitted_answer_background"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:visibility="gone"
app:itemDecorator="@{@drawable/divider}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:contentDescription="@{viewModel.isCorrectAnswer ? @string/correct_submitted_answer : @string/incorrect_submitted_answer}"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:list="@{submittedListAnswer.setOfHtmlStringsList}" />
app:layout_constraintTop_toTopOf="parent">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/submitted_answer_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/submitted_answer_background"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:visibility="gone"
app:itemDecorator="@{@drawable/divider}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:list="@{submittedListAnswer.setOfHtmlStringsList}" />
</LinearLayout>

<ImageView
android:id="@+id/answer_tick"
android:layout_width="@dimen/answer_tick_size"
android:layout_height="@dimen/answer_tick_size"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/answer_tick_margin"
android:importantForAccessibility="no"
rt4914 marked this conversation as resolved.
Show resolved Hide resolved
android:src="@drawable/ic_check_primary"
android:visibility="@{viewModel.isCorrectAnswer &amp;&amp; !viewModel.hasConversationView ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,8 @@
<string name="audio_player_on">Audio, ON</string>
<string name="audio_player_off">Audio, OFF</string>
<string name="hints_android_solution_correct_answer">%s/%s</string>
<string name="correct_submitted_answer">Correct submitted answer</string>
<string name="correct_submitted_answer_with_append">Correct submitted answer: %s</string>
<string name="incorrect_submitted_answer">Incorrect submitted answer</string>
<string name="incorrect_submitted_answer_with_append">Incorrect submitted answer: %s</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,48 @@ class StateFragmentTest {
}
}

@Test
fun testStateFragment_loadExp_secondState_submitWrongAnswer_contentDescriptionIsCorrect() {
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()
clickContinueInteractionButton()

// Attempt to submit an wrong answer.
typeFractionText("1/4")
clickSubmitAnswerButton()

scrollToViewType(SUBMITTED_ANSWER)
onView(withId(R.id.submitted_answer_text_view)).check(
matches(
withContentDescription(
"Incorrect submitted answer: 1/4"
)
)
)
}
}

@Test
fun testStateFragment_loadExp_secondState_submitCorrectAnswer_contentDescriptionIsCorrect() {
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()
clickContinueInteractionButton()

// Attempt to submit an wrong answer.
typeFractionText("1/2")
clickSubmitAnswerButton()

scrollToViewType(SUBMITTED_ANSWER)
onView(withId(R.id.submitted_answer_text_view)).check(
matches(
withContentDescription(
"Correct submitted answer: 1/2"
)
)
)
}
}

@Test
fun testStateFragment_loadExp_firstState_previousAndNextButtonIsNotDisplayed() {
launchForExploration(TEST_EXPLORATION_ID_2).use {
Expand Down Expand Up @@ -518,6 +560,53 @@ class StateFragmentTest {
}
}

@Test
fun testStateFragment_loadDragDropExp_wrongAnswer_contentDescriptionIsCorrect() {
launchForExploration(TEST_EXPLORATION_ID_4).use {
startPlayingExploration()

mergeDragAndDropItems(position = 0)
clickSubmitAnswerButton()

scrollToViewType(SUBMITTED_ANSWER)
onView(withId(R.id.submitted_answer_recycler_view_container)).check(
matches(
withContentDescription(
context.getString(R.string.incorrect_submitted_answer)
)
)
)
}
}

@Test
fun testStateFragment_loadDragDropExp_correctAnswer_contentDescriptionIsCorrect() {
launchForExploration(TEST_EXPLORATION_ID_2).use {
startPlayingExploration()
playThroughPrototypeState1()
playThroughPrototypeState2()
playThroughPrototypeState3()
playThroughPrototypeState4()
playThroughPrototypeState5()
playThroughPrototypeState6()
playThroughPrototypeState7()
playThroughPrototypeState8()

// Drag and drop interaction without grouping.
// Ninth state: Drag Drop Sort. Correct answer: Move 1st item to 4th position.
dragAndDropItem(fromPosition = 0, toPosition = 3)
clickSubmitAnswerButton()
scrollToViewType(SUBMITTED_ANSWER)
onView(withId(R.id.submitted_answer_recycler_view_container)).check(
matches(
withContentDescription(
context.getString(R.string.correct_submitted_answer)
)
)
)
}
}

@Test
@RunOn(TestPlatform.ESPRESSO) // TODO(#1612): Enable for Robolectric.
fun testStateFragment_loadDragDropExp_mergeFirstTwoItems_dragItem_worksCorrectly() {
Expand Down Expand Up @@ -918,7 +1007,7 @@ class StateFragmentTest {
clickSubmitAnswerButton()

onView(withId(R.id.submitted_answer_text_view))
.check(matches(withContentDescription("4 to 5")))
.check(matches(withContentDescription("Correct submitted answer: 4 to 5")))
}
}

Expand Down