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 part of #4470, Fix #4471, Fix 4474: Handle configuration change using onSavedInstance. #5458

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
32ee035
selection interaction state retain
Vishwajith-Shettigar Jul 6, 2024
673ba94
klint
Vishwajith-Shettigar Jul 6, 2024
c64e91f
fix checkbox state clearing when setting tint
Vishwajith-Shettigar Jul 9, 2024
d5b205e
seletion state retain support in question player
Vishwajith-Shettigar Jul 9, 2024
ee98317
klint
Vishwajith-Shettigar Jul 9, 2024
ea9ca3b
seletion state retain support with error
Vishwajith-Shettigar Jul 9, 2024
1a193a4
resolve warnings and static checks
Vishwajith-Shettigar Jul 9, 2024
64af426
proto lint fix
Vishwajith-Shettigar Jul 9, 2024
3ccf7b4
retain answer state in math,ratio, and numeric input interaction
Vishwajith-Shettigar Jul 10, 2024
4a84e3d
Addressed comments
Vishwajith-Shettigar Jul 11, 2024
4aa6f3d
Merge branch 'develop' into selection-state-retain
Vishwajith-Shettigar Jul 11, 2024
454c320
Addressed comments
Vishwajith-Shettigar Jul 12, 2024
c87bf9f
Merge branch 'develop' into selection-state-retain
Vishwajith-Shettigar Jul 24, 2024
42d348a
Merge branch 'develop' into selection-state-retain
Vishwajith-Shettigar Jul 29, 2024
3d81a55
Added tests for all interactions saved input state
Vishwajith-Shettigar Jul 30, 2024
128357e
klint
Vishwajith-Shettigar Jul 30, 2024
2a98efb
clean up
Vishwajith-Shettigar Jul 30, 2024
20c8ade
klint
Vishwajith-Shettigar Jul 30, 2024
9a8cc05
Removed changes made for running tests locally
Vishwajith-Shettigar Jul 30, 2024
ee784ce
Import OppiaTestRule
Vishwajith-Shettigar Jul 30, 2024
8bdd395
Merge branch 'develop' into selection-state-retain
Vishwajith-Shettigar Jul 30, 2024
cd1407a
Resolved conflicts
Vishwajith-Shettigar Aug 2, 2024
811b335
Klint
Vishwajith-Shettigar Aug 2, 2024
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
Expand Up @@ -375,9 +375,7 @@ class StateFragmentPresenter @Inject constructor(
private fun subscribeToAnswerOutcome(
answerOutcomeResultLiveData: LiveData<AsyncResult<AnswerOutcome>>
) {
if (stateViewModel.getCanSubmitAnswer().get() == true) {
recyclerViewAssembler.resetUserAnswerState()
}
recyclerViewAssembler.resetUserAnswerState()
val answerOutcomeLiveData = getAnswerOutcome(answerOutcomeResultLiveData)
answerOutcomeLiveData.observe(
fragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ class StatePlayerRecyclerViewAssembler private constructor(
resourceBucketName: String,
entityType: String,
profileId: ProfileId,
userAnswerState: UserAnswerState = UserAnswerState.getDefaultInstance()
userAnswerState: UserAnswerState
): Builder {
return Builder(
accessibilityService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>(false)
var errorMessage = ObservableField<String>("")

Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ 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.
set(value) {
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
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>("")
var isAnswerAvailable = ObservableField<Boolean>(false)
Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>(false)
var errorMessage = ObservableField<String>("")

Expand Down Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
}
Expand Down
26 changes: 16 additions & 10 deletions model/src/main/proto/exploration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
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.
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
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;
}
Loading