fix: throw exception if no activities can be loaded in analytics practice session (#5799)
This commit is contained in:
parent
a754d16fc3
commit
fd319aa105
2 changed files with 16 additions and 2 deletions
|
|
@ -313,6 +313,8 @@ class AnalyticsPracticeState extends State<AnalyticsPractice>
|
|||
Future<void> skipActivity(MessageActivityRequest request) async {
|
||||
// Record a 0 XP use so that activity isn't chosen again soon
|
||||
_sessionController.skipActivity();
|
||||
progress.value = _sessionController.progress;
|
||||
|
||||
await _analyticsController.addSkippedActivityAnalytics(
|
||||
request.target,
|
||||
_l2!.langCodeShort,
|
||||
|
|
|
|||
|
|
@ -152,12 +152,18 @@ class PracticeSessionController {
|
|||
Future Function(MessageActivityRequest) onSkip,
|
||||
Future Function(MultipleChoicePracticeActivityModel) onFetch,
|
||||
) async {
|
||||
final session = this.session;
|
||||
if (session == null) {
|
||||
throw Exception("Called getNextActivity without loading session");
|
||||
}
|
||||
|
||||
if (!session!.isComplete && _queue.isEmpty) {
|
||||
return _initActivityData(onSkip, onFetch);
|
||||
if (!session.isComplete && _queue.isEmpty) {
|
||||
final initialActivity = await _initActivityData(onSkip, onFetch);
|
||||
if (initialActivity == null && session.state.currentIndex == 0) {
|
||||
// No activities were successfully loaded, and we haven't completed any yet, so throw an error
|
||||
throw Exception("Failed to load any activities");
|
||||
}
|
||||
return initialActivity;
|
||||
}
|
||||
|
||||
while (_queue.isNotEmpty) {
|
||||
|
|
@ -171,6 +177,12 @@ class PracticeSessionController {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (session.state.currentIndex == 0) {
|
||||
// No activities were successfully loaded, and we haven't completed any yet, so throw an error
|
||||
throw Exception("Failed to load any activities");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue