client set up to recieve and display multiple choice questions with some display tweaks
This commit is contained in:
parent
d6a56cbd43
commit
15f493709f
5 changed files with 21 additions and 3 deletions
|
|
@ -577,18 +577,18 @@ class PangeaMessageEvent {
|
|||
|
||||
// this is just showActivityIcon now but will include
|
||||
// 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.
|
||||
///
|
||||
/// 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
|
||||
/// with the [l2Code] as an argument.
|
||||
/// If the list is empty, it returns false.
|
||||
/// 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.
|
||||
/// Otherwise, it returns false.
|
||||
bool get showActivityIcon {
|
||||
bool get hasUncompletedActivity {
|
||||
if (l2Code == null) return false;
|
||||
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({
|
||||
String? text,
|
||||
Uint8List? audioBytes,
|
||||
|
|
|
|||
|
|
@ -189,6 +189,12 @@ class MessageToolbarState extends State<MessageToolbar> {
|
|||
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) {
|
||||
setState(() {
|
||||
currentMode = newMode;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class GeneratePracticeActivityButton extends StatelessWidget {
|
|||
required this.onActivityGenerated,
|
||||
});
|
||||
|
||||
//TODO - probably disable the generation of activities for specific messages
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class MessagePracticeActivityContentState
|
|||
);
|
||||
} else {
|
||||
recordModel = recordEvent!.record;
|
||||
selectedChoiceIndex = recordModel!.latestResponseIndex;
|
||||
recordSubmittedPreviousSession = true;
|
||||
recordSubmittedThisSession = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue