diff --git a/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt b/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt index a0b73c6d137..bd3e37c5bc4 100755 --- a/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StateFragmentPresenter.kt @@ -367,9 +367,7 @@ class StateFragmentPresenter @Inject constructor( private fun subscribeToAnswerOutcome( answerOutcomeResultLiveData: LiveData> ) { - if (stateViewModel.getCanSubmitAnswer().get() == true) { - recyclerViewAssembler.resetUserAnswerState() - } + recyclerViewAssembler.resetUserAnswerState() val answerOutcomeLiveData = getAnswerOutcome(answerOutcomeResultLiveData) answerOutcomeLiveData.observe( fragment, diff --git a/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt b/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt index 2804539dd78..8f1e627d77a 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt @@ -1430,7 +1430,7 @@ class StatePlayerRecyclerViewAssembler private constructor( resourceBucketName: String, entityType: String, profileId: ProfileId, - userAnswerState: UserAnswerState = UserAnswerState.getDefaultInstance() + userAnswerState: UserAnswerState ): Builder { return Builder( accessibilityService, diff --git a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/FractionInteractionViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/FractionInteractionViewModel.kt index 4900b369341..b09059e8086 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/FractionInteractionViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/FractionInteractionViewModel.kt @@ -32,8 +32,8 @@ class FractionInteractionViewModel private constructor( userAnswerState: UserAnswerState ) : StateItemViewModel(ViewType.FRACTION_INPUT_INTERACTION), InteractionAnswerHandler { private var pendingAnswerError: String? = null - var answerText: CharSequence = userAnswerState.textualAnswer - private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR_UNSPECIFIED + var answerText: CharSequence = userAnswerState.textInputAnswer + private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR var isAnswerAvailable = ObservableField(false) var errorMessage = ObservableField("") @@ -118,7 +118,7 @@ class FractionInteractionViewModel private constructor( override fun getUserAnswerState(): UserAnswerState { return UserAnswerState.newBuilder().apply { - this.textualAnswer = answerText.toString() + this.textInputAnswer = answerText.toString() this.answerErrorCategory = answerErrorCetegory }.build() } diff --git a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/MathExpressionInteractionsViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/MathExpressionInteractionsViewModel.kt index 8d2ca8eb69a..9f6bd6682bf 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/MathExpressionInteractionsViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/MathExpressionInteractionsViewModel.kt @@ -74,7 +74,7 @@ class MathExpressionInteractionsViewModel private constructor( * Defines the current answer text being entered by the learner. This is expected to be directly * bound to the corresponding edit text. */ - var answerText: CharSequence = userAnswerState.textualAnswer + var answerText: CharSequence = userAnswerState.textInputAnswer // The value of ths field is set from the Binding and from the TextWatcher. Any // programmatic modification needs to be done here, so that the Binding and the TextWatcher // do not step on each other. @@ -82,7 +82,7 @@ class MathExpressionInteractionsViewModel private constructor( field = value.toString().trim() } - private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR_UNSPECIFIED + private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR /** * Defines whether an answer is currently available to parse. This is expected to be directly @@ -126,7 +126,7 @@ class MathExpressionInteractionsViewModel private constructor( override fun getUserAnswerState(): UserAnswerState { return UserAnswerState.newBuilder().apply { - this.textualAnswer = answerText.toString() + this.textInputAnswer = answerText.toString() this.answerErrorCategory = answerErrorCetegory }.build() } diff --git a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/NumericInputViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/NumericInputViewModel.kt index bdcba83eedc..347c2d5ccc7 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/NumericInputViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/NumericInputViewModel.kt @@ -26,8 +26,8 @@ class NumericInputViewModel private constructor( private val resourceHandler: AppLanguageResourceHandler, userAnswerState: UserAnswerState ) : StateItemViewModel(ViewType.NUMERIC_INPUT_INTERACTION), InteractionAnswerHandler { - var answerText: CharSequence = userAnswerState.textualAnswer - private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR_UNSPECIFIED + var answerText: CharSequence = userAnswerState.textInputAnswer + private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR private var pendingAnswerError: String? = null val errorMessage = ObservableField("") var isAnswerAvailable = ObservableField(false) @@ -77,7 +77,7 @@ class NumericInputViewModel private constructor( override fun getUserAnswerState(): UserAnswerState { return UserAnswerState.newBuilder().apply { - this.textualAnswer = answerText.toString() + this.textInputAnswer = answerText.toString() this.answerErrorCategory = answerErrorCetegory }.build() } diff --git a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/RatioExpressionInputInteractionViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/RatioExpressionInputInteractionViewModel.kt index 05f6850a226..215dfb811ff 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/RatioExpressionInputInteractionViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/RatioExpressionInputInteractionViewModel.kt @@ -33,8 +33,8 @@ class RatioExpressionInputInteractionViewModel private constructor( userAnswerState: UserAnswerState ) : StateItemViewModel(ViewType.RATIO_EXPRESSION_INPUT_INTERACTION), InteractionAnswerHandler { private var pendingAnswerError: String? = null - var answerText: CharSequence = userAnswerState.textualAnswer - private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR_UNSPECIFIED + var answerText: CharSequence = userAnswerState.textInputAnswer + private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR var isAnswerAvailable = ObservableField(false) var errorMessage = ObservableField("") @@ -102,7 +102,7 @@ class RatioExpressionInputInteractionViewModel private constructor( override fun getUserAnswerState(): UserAnswerState { return UserAnswerState.newBuilder().apply { - this.textualAnswer = answerText.toString() + this.textInputAnswer = answerText.toString() this.answerErrorCategory = answerErrorCetegory }.build() } diff --git a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/SelectionInteractionViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/SelectionInteractionViewModel.kt index fce0f3bcead..d5f4b7016c7 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/SelectionInteractionViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/SelectionInteractionViewModel.kt @@ -64,7 +64,7 @@ class SelectionInteractionViewModel private constructor( ?: listOf() } - private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR_UNSPECIFIED + private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR private val minAllowableSelectionCount: Int by lazy { interaction.customizationArgsMap["minAllowableSelectionCount"]?.signedInt ?: 1 diff --git a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/TextInputViewModel.kt b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/TextInputViewModel.kt index 14cc21e21c2..88082ac39b3 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/TextInputViewModel.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/itemviewmodel/TextInputViewModel.kt @@ -30,8 +30,8 @@ class TextInputViewModel private constructor( private val translationController: TranslationController, userAnswerState: UserAnswerState ) : StateItemViewModel(ViewType.TEXT_INPUT_INTERACTION), InteractionAnswerHandler { - var answerText: CharSequence = userAnswerState.textualAnswer - private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR_UNSPECIFIED + var answerText: CharSequence = userAnswerState.textInputAnswer + private var answerErrorCetegory: AnswerErrorCategory = AnswerErrorCategory.NO_ERROR val hintText: CharSequence = deriveHintText(interaction) private var pendingAnswerError: String? = null @@ -107,7 +107,7 @@ class TextInputViewModel private constructor( override fun getUserAnswerState(): UserAnswerState { return UserAnswerState.newBuilder().apply { - this.textualAnswer = answerText.toString() + this.textInputAnswer = answerText.toString() this.answerErrorCategory = answerErrorCetegory }.build() } diff --git a/model/src/main/proto/exploration.proto b/model/src/main/proto/exploration.proto index 7f6f9c5912a..9c62edc2b9f 100644 --- a/model/src/main/proto/exploration.proto +++ b/model/src/main/proto/exploration.proto @@ -421,31 +421,37 @@ enum CheckpointState { CHECKPOINT_UNSAVED = 3; } -// Corresponds to a item selection answer that user has selected. +// Represents the state of item selection answers that the user has selected. message ItemSelectionAnswerState { + // List of selected item indexes repeated int32 selected_indexes = 1; } -// Corresponds to a raw representation of the current answer entered by the user -// which is used to retain state on configuration changes +// Represents the user's answer state, retaining state across configuration changes. message UserAnswerState { + // Represents the last error state. AnswerErrorCategory answer_error_category = 1; - oneof answer_input_type{ - ItemSelectionAnswerState item_selection = 2; - // A raw answer entered by user in a text-based interactions. - string textual_answer = 3; + // Type of answer input: + oneof answer_input_type { + // User's selection for selection input interactions. + ItemSelectionAnswerState item_selection = 2; + // Raw answer entered by the user in text-based interactions. + string text_input_answer = 3; } } // Represents categories of errors that can be inferred from a pending answer. enum AnswerErrorCategory { + // The error is unknown or not specified. + ERROR_UNSPECIFIED = 0; + // Corresponds to the pending answer having no error. - NO_ERROR_UNSPECIFIED = 0; + NO_ERROR = 1; // Corresponds to errors that may be found while the user is trying to input an answer. - REAL_TIME = 1; + REAL_TIME = 2; // Corresponds to errors that may be found only when a user tries to submit an answer. - SUBMIT_TIME = 2; + SUBMIT_TIME = 3; }