client set up to recieve and display multiple choice questions with some display tweaks

pull/1384/head
William Jordan-Cooley 1 year ago
parent d6a56cbd43
commit 15f493709f

@ -577,18 +577,18 @@ class PangeaMessageEvent {
// this is just showActivityIcon now but will include // this is just showActivityIcon now but will include
// logic for showing // logic for showing
bool get showMessageButtons => showActivityIcon; bool get showMessageButtons => hasUncompletedActivity;
/// Returns a boolean value indicating whether to show an activity icon for this message event. /// Returns a boolean value indicating whether to show an activity icon for this message event.
/// ///
/// The [showActivityIcon] getter checks if the [l2Code] is null, and if so, returns false. /// The [hasUncompletedActivity] getter checks if the [l2Code] is null, and if so, returns false.
/// Otherwise, it retrieves a list of [PracticeActivityEvent] objects using the [practiceActivities] function /// Otherwise, it retrieves a list of [PracticeActivityEvent] objects using the [practiceActivities] function
/// with the [l2Code] as an argument. /// with the [l2Code] as an argument.
/// If the list is empty, it returns false. /// If the list is empty, it returns false.
/// Otherwise, it checks if every activity in the list is complete using the [isComplete] property. /// Otherwise, it checks if every activity in the list is complete using the [isComplete] property.
/// If any activity is not complete, it returns true, indicating that the activity icon should be shown. /// If any activity is not complete, it returns true, indicating that the activity icon should be shown.
/// Otherwise, it returns false. /// Otherwise, it returns false.
bool get showActivityIcon { bool get hasUncompletedActivity {
if (l2Code == null) return false; if (l2Code == null) return false;
final List<PracticeActivityEvent> activities = practiceActivities(l2Code!); final List<PracticeActivityEvent> activities = practiceActivities(l2Code!);

@ -38,6 +38,16 @@ 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 {
if (responses.isEmpty) {
return null;
}
responses.sort((a, b) => a.timestamp.compareTo(b.timestamp));
return responses.length - 1;
}
void addResponse({ void addResponse({
String? text, String? text,
Uint8List? audioBytes, Uint8List? audioBytes,

@ -189,6 +189,12 @@ class MessageToolbarState extends State<MessageToolbar> {
return; return;
} }
// if there is an uncompleted activity, then show that
// we don't want the user to user the tools to get the answer :P
if (widget.pangeaMessageEvent.hasUncompletedActivity) {
newMode = MessageMode.practiceActivity;
}
if (mounted) { if (mounted) {
setState(() { setState(() {
currentMode = newMode; currentMode = newMode;

@ -15,6 +15,7 @@ class GeneratePracticeActivityButton extends StatelessWidget {
required this.onActivityGenerated, required this.onActivityGenerated,
}); });
//TODO - probably disable the generation of activities for specific messages
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ElevatedButton( return ElevatedButton(

@ -47,6 +47,7 @@ class MessagePracticeActivityContentState
); );
} else { } else {
recordModel = recordEvent!.record; recordModel = recordEvent!.record;
selectedChoiceIndex = recordModel!.latestResponseIndex;
recordSubmittedPreviousSession = true; recordSubmittedPreviousSession = true;
recordSubmittedThisSession = true; recordSubmittedThisSession = true;
} }

Loading…
Cancel
Save