diff --git a/BetterIServ.Backend/Controllers/UnitsController.cs b/BetterIServ.Backend/Controllers/UnitsController.cs index 7697739..8ce7710 100644 --- a/BetterIServ.Backend/Controllers/UnitsController.cs +++ b/BetterIServ.Backend/Controllers/UnitsController.cs @@ -38,22 +38,34 @@ public class UnitsController : ControllerBase { } var substitutions = html.DocumentNode.SelectNodes("//body/center[1]")[0].ChildNodes[6]; - for (int i = 4; i < substitutions.ChildNodes.Count; i++) { + var cols = new UnitsCollumns { + Classes = 0, + Times = 1, + Repre = 2, + Teacher = 3, + Lesson = 4, + Room = 5, + Type = 6, + Desc = 7 + }; + + for (int i = 1; i < substitutions.ChildNodes.Count; i++) { var node = substitutions.ChildNodes[i]; - if (node.ChildNodes.Count < 9) continue; + if (node.ChildNodes.Count < 8) continue; + if (!node.ChildNodes[cols.Times].InnerText.Contains("-")) continue; var substitution = new Substitution { - Times = node.ChildNodes[1].InnerText.Split(" - ").Select(int.Parse).ToArray(), - Type = node.ChildNodes[2].InnerText, - Representative = node.ChildNodes[3].InnerText, - NewLesson = node.ChildNodes[4].InnerText, - Lesson = node.ChildNodes[5].InnerText, - Room = node.ChildNodes[6].InnerText, - Teacher = node.ChildNodes[7].InnerText, - Description = node.ChildNodes[9].InnerText + Times = node.ChildNodes[cols.Times].InnerText.Split(" - ").Select(int.Parse).ToArray(), + Type = node.ChildNodes[cols.Type].InnerText.Replace("Vtr. ohne Lehrer", "Stillarbeit"), + Representative = node.ChildNodes[cols.Repre].InnerText, + NewLesson = node.ChildNodes[cols.Lesson].InnerText, + Lesson = node.ChildNodes[cols.Lesson].InnerText, + Room = node.ChildNodes[cols.Room].InnerText, + Teacher = node.ChildNodes[cols.Teacher].InnerText, + Description = node.ChildNodes[cols.Desc].InnerText }; - var classes = node.ChildNodes[0].InnerText; + var classes = node.ChildNodes[cols.Classes].InnerText; if (!classes.StartsWith("Q")) { string grade = new string(classes.ToCharArray().Where(char.IsNumber).ToArray()); diff --git a/BetterIServ.Backend/Entities/UnitsCollumns.cs b/BetterIServ.Backend/Entities/UnitsCollumns.cs new file mode 100644 index 0000000..a98a170 --- /dev/null +++ b/BetterIServ.Backend/Entities/UnitsCollumns.cs @@ -0,0 +1,12 @@ +namespace BetterIServ.Backend.Entities; + +public sealed class UnitsCollumns { + public int Classes { get; set; } + public int Times { get; set; } + public int Repre { get; set; } + public int Teacher { get; set; } + public int Lesson { get; set; } + public int Room { get; set; } + public int Type { get; set; } + public int Desc { get; set; } +} \ No newline at end of file diff --git a/BetterIServ.Mobile/src/app/api/iserv.service.ts b/BetterIServ.Mobile/src/app/api/iserv.service.ts index 91ae8fb..ff483c8 100644 --- a/BetterIServ.Mobile/src/app/api/iserv.service.ts +++ b/BetterIServ.Mobile/src/app/api/iserv.service.ts @@ -118,17 +118,30 @@ export class IServService { result.class = grades[0].replace("Jahrgang ", "").toUpperCase(); } } + + switch (result.class) { + case "12": + result.class = "Q1"; + break; + + case "13": + result.class = "Q2"; + break; + } + await this.storage.setItem("class", result.class); for (let group of groups) { if (!group.includes(".") || !group.toLowerCase().startsWith("q")) continue; - result.courses.push(group.split(".")[1]); + result.courses.push(group.split(".")[1] + .replace("1", "") + .replace("2", "")); } if (result.class.startsWith("Q")) { const courses: Course[] = []; for (let course of result.courses) { - const short = course.substring(1, 3); + const short = course.substring(0, 2); const name = this.courseNames[short]; if (name == undefined) continue; courses.push({ diff --git a/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts b/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts index ffd070d..247a578 100644 --- a/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts +++ b/BetterIServ.Mobile/src/app/pages/schedule/schedule.page.ts @@ -34,6 +34,14 @@ export class SchedulePage implements OnInit { this.timetable = await this.storage.getItem("timetable"); if (this.timetable == undefined) { + this.timetable = { + mon: [], + tue: [], + wed: [], + thu: [], + fri: [] + }; + for (let day of ['mon', 'tue', 'wed', 'thu', 'fri']) { for (let i = 0; i < 10; i++) { this.timetable[day].push(undefined); diff --git a/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.ts b/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.ts index d6878e5..7742555 100644 --- a/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.ts +++ b/BetterIServ.Mobile/src/app/pages/substitution/substitution.page.ts @@ -82,7 +82,11 @@ export class SubstitutionPage implements OnInit { public hasClass(course: string): boolean { if (!this.filterByClasses) return true; - return this.courses.includes(course); + if (course == " ") return true; + + return this.courses.includes(course + .replace("1", "") + .replace("2", "")); } public addFakeSubstitution(event: any) {