fixing latestResponse
This commit is contained in:
parent
2227c9d22d
commit
a9ee9061b3
4 changed files with 17 additions and 3 deletions
|
|
@ -18,6 +18,8 @@ class MultipleChoice {
|
|||
|
||||
int get correctAnswerIndex => choices.indexOf(answer);
|
||||
|
||||
int choiceIndex(String choice) => choices.indexOf(choice);
|
||||
|
||||
Color choiceColor(int index) =>
|
||||
index == correctAnswerIndex ? AppConfig.success : AppConfig.warning;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ class PracticeActivityRecordModel {
|
|||
|
||||
/// get the latest response index according to the response timeStamp
|
||||
/// sort the responses by timestamp and get the index of the last response
|
||||
int? get latestResponseIndex {
|
||||
String? get latestResponse {
|
||||
if (responses.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
responses.sort((a, b) => a.timestamp.compareTo(b.timestamp));
|
||||
return responses.length - 1;
|
||||
return responses[responses.length - 1].text;
|
||||
}
|
||||
|
||||
void addResponse({
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class MessagePracticeActivityCardState extends State<PracticeActivityCard> {
|
|||
return langCode;
|
||||
}
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
void loadInitialData() {
|
||||
if (langCode == null) return;
|
||||
updatePracticeActivity();
|
||||
|
|
@ -75,6 +76,11 @@ class MessagePracticeActivityCardState extends State<PracticeActivityCard> {
|
|||
else if (activities.isNotEmpty) {
|
||||
practiceEvent = activities.last;
|
||||
}
|
||||
=======
|
||||
practiceEvent =
|
||||
widget.pangeaMessageEvent.practiceActivities(langCode).firstOrNull;
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,13 @@ class MessagePracticeActivityContentState
|
|||
);
|
||||
} else {
|
||||
recordModel = recordEvent!.record;
|
||||
selectedChoiceIndex = recordModel!.latestResponseIndex;
|
||||
|
||||
//Note that only MultipleChoice activities will have this so we probably should move this logic to the MultipleChoiceActivity widget
|
||||
selectedChoiceIndex = recordModel?.latestResponse != null
|
||||
? widget.practiceEvent.practiceActivity.multipleChoice
|
||||
?.choiceIndex(recordModel!.latestResponse!)
|
||||
: null;
|
||||
|
||||
recordSubmittedPreviousSession = true;
|
||||
recordSubmittedThisSession = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue