getTasks method
override
Fetches all tasks.
If courseId
is provided, only tasks for that course are fetched.
Implementation
@override
Future<List<MoodleTask>> getTasks(String token, {int? courseId}) async {
final all = courseId == null;
log(all ? 'Fetching all tasks' : 'Fetching tasks for course with id $courseId');
try {
final response = await _apiService.callFunction(
token: token,
function: all ? 'local_lbplanner_modules_get_all_modules' : 'local_lbplanner_modules_get_all_course_modules',
body: {
'courseid': courseId,
},
);
response.assertList();
log('Fetched ${response.asList.length} tasks');
return response.asList.map(MoodleTask.fromJson).toList();
} catch (e, s) {
log(all ? 'Failed to fetch all tasks' : 'Failed to fetch tasks for course with id $courseId', e, s);
rethrow;
}
}