Skip to content
Snippets Groups Projects
Commit 4238a1eb authored by marcantoinem's avatar marcantoinem
Browse files

Start error detection

parent 866a0916
No related branches found
No related tags found
No related merge requests found
use compact_str::CompactString;
use super::{
//conflicts::Conflicts,
schedule::ScheduleBuilder,
......@@ -19,6 +21,13 @@ impl SchedulesOptions {
// pub fn get_simple_conflict<'a>(&'a self) -> Option<Conflicts> {
// }
pub fn get_impossible_course<'a>(&'a self) -> Vec<CompactString> {
self.courses_to_take
.iter()
.filter(|c| c.is_impossible())
.map(|c| c.sigle.clone())
.collect()
}
pub fn get_nb_combinations<'a>(&'a self) -> usize {
self.courses_to_take
.iter()
......
......@@ -155,4 +155,15 @@ impl Course {
.is_some_and(|g| g.open),
}
}
pub fn is_impossible(&self) -> bool {
match &self.course_type {
CourseType::TheoOnly { theo_groups } => theo_groups.is_impossible(),
CourseType::LabOnly { lab_groups } => lab_groups.is_impossible(),
CourseType::Both {
theo_groups,
lab_groups,
} => theo_groups.is_impossible() | lab_groups.is_impossible(),
CourseType::Linked { theo_groups, .. } => theo_groups.is_impossible(),
}
}
}
......@@ -61,6 +61,10 @@ impl Groups {
self[index].as_mut()
}
pub fn is_impossible(&self) -> bool {
self.iter().all(|c| !c.open)
}
pub fn get_closed(&self, group_type: GroupType, sigle: &CompactString) -> Vec<SigleGroup> {
self.iter()
.filter(|g| !g.open)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment