TypeAggregate.fromTasks constructor
- Iterable<
MoodleTask> tasks
Creates a TypeAggregate from a set of tasks.
Implementation
factory TypeAggregate.fromTasks(Iterable<MoodleTask> tasks) {
final required = tasks.where((t) => t.type == MoodleTaskType.required).length;
final optional = tasks.where((t) => t.type == MoodleTaskType.optional).length;
final compensation = tasks.where((t) => t.type == MoodleTaskType.participation).length;
final exam = tasks.where((t) => t.type == MoodleTaskType.exam).length;
final none = tasks.where((t) => t.type == MoodleTaskType.none).length;
return TypeAggregate(required: required, optional: optional, compensation: compensation, exam: exam, none: none);
}