Open apomalyn opened 7 months ago
Implement the AssociationQuestion model extending Question. It should be implemented using freezed
AssociationQuestion
Question
Implement a AssociationQuestionViewModel that:
AssociationQuestionViewModel
QuestionViewModel
format: QuestionFormats.association
instruction: InstructionTypes.custom
src/practice/questions
int leftSelectedIndex = -1
int rightSelectedIndex = -1
bool error = false
List<{String text, String? tts, bool isDisabled = false}> leftColumn
List<{String text, String? tts, bool isDisabled = false}> rightColumn
int _remainingPairs
AssociationQuestion question
leftColumn
rightColumn
question.pairs
_remainingPairs = question.pairs.lenght
_reset()
leftSelectedIndex = -1
rightSelectedIndex = -1
error = false
_validateSelectedPair()
leftSelectedIndex == -1 || rightSelectedIndex == -1
AssociationQuestionPair
leftColumn[leftSelectedIndex]
rightColumn[rightSelectedIndex]
error
KnowledgeUpdate
_onError(false, isFinished: false, onContinuePressed: _reset)
_remainingPairs = 1
_onSuccess(skipResultDialog: true)
_remainingPairs > 1
_remainingPairs
onOptionPressed(int index, bool isLeft)
leftSelectedIndex
rightSelectedIndex
isLeft
Child of #172
Depends on:
Requirements
Implement the
AssociationQuestion
model extendingQuestion
. It should be implemented using freezedAssociationQuestion
schema is available in #172Implement a
AssociationQuestionViewModel
that:QuestionViewModel
What needs to be done
AssociationQuestion
model extendingQuestion
format: QuestionFormats.association
instruction: InstructionTypes.custom
AssociationQuestionViewModel
view-model undersrc/practice/questions
:QuestionViewModel
int leftSelectedIndex = -1
indicates the current left item selectedint rightSelectedIndex = -1
indicates the current right item selectedbool error = false
List<{String text, String? tts, bool isDisabled = false}> leftColumn
List<{String text, String? tts, bool isDisabled = false}> rightColumn
int _remainingPairs
AssociationQuestion question
QuestionViewModel
constructorleftColumn
andrightColumn
based on thequestion.pairs
. Shuffle the columns after initialization_remainingPairs = question.pairs.lenght
_reset()
, it should:leftSelectedIndex = -1
rightSelectedIndex = -1
error = false
_validateSelectedPair()
, it should:leftSelectedIndex == -1 || rightSelectedIndex == -1
stop thereAssociationQuestionPair
associated withleftColumn[leftSelectedIndex]
, check if therightColumn[rightSelectedIndex]
correspond to the pair.error
should be trueKnowledgeUpdate
associated with the pair by 1._onError(false, isFinished: false, onContinuePressed: _reset)
_remainingPairs = 1
:_onSuccess(skipResultDialog: true)
_remainingPairs > 1
:_reset()
_remainingPairs
by 1.onOptionPressed(int index, bool isLeft)
thatleftSelectedIndex
orrightSelectedIndex
based onisLeft
_validateSelectedPair()
Dependencies
Child of #172
Depends on:
171
176
Dev notes