Archived
Private
Public Access
1
0

migrated to work with new iserv and units versions

This commit is contained in:
2023-08-31 15:17:28 +02:00
parent aba84e41ec
commit 969f6a4e8e
5 changed files with 63 additions and 14 deletions

View File

@@ -38,22 +38,34 @@ public class UnitsController : ControllerBase {
} }
var substitutions = html.DocumentNode.SelectNodes("//body/center[1]")[0].ChildNodes[6]; 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]; 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 { var substitution = new Substitution {
Times = node.ChildNodes[1].InnerText.Split(" - ").Select(int.Parse).ToArray(), Times = node.ChildNodes[cols.Times].InnerText.Split(" - ").Select(int.Parse).ToArray(),
Type = node.ChildNodes[2].InnerText, Type = node.ChildNodes[cols.Type].InnerText.Replace("Vtr. ohne Lehrer", "Stillarbeit"),
Representative = node.ChildNodes[3].InnerText, Representative = node.ChildNodes[cols.Repre].InnerText,
NewLesson = node.ChildNodes[4].InnerText, NewLesson = node.ChildNodes[cols.Lesson].InnerText,
Lesson = node.ChildNodes[5].InnerText, Lesson = node.ChildNodes[cols.Lesson].InnerText,
Room = node.ChildNodes[6].InnerText, Room = node.ChildNodes[cols.Room].InnerText,
Teacher = node.ChildNodes[7].InnerText, Teacher = node.ChildNodes[cols.Teacher].InnerText,
Description = node.ChildNodes[9].InnerText Description = node.ChildNodes[cols.Desc].InnerText
}; };
var classes = node.ChildNodes[0].InnerText; var classes = node.ChildNodes[cols.Classes].InnerText;
if (!classes.StartsWith("Q")) { if (!classes.StartsWith("Q")) {
string grade = new string(classes.ToCharArray().Where(char.IsNumber).ToArray()); string grade = new string(classes.ToCharArray().Where(char.IsNumber).ToArray());

View File

@@ -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; }
}

View File

@@ -118,17 +118,30 @@ export class IServService {
result.class = grades[0].replace("Jahrgang ", "").toUpperCase(); 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); await this.storage.setItem("class", result.class);
for (let group of groups) { for (let group of groups) {
if (!group.includes(".") || !group.toLowerCase().startsWith("q")) continue; 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")) { if (result.class.startsWith("Q")) {
const courses: Course[] = []; const courses: Course[] = [];
for (let course of result.courses) { for (let course of result.courses) {
const short = course.substring(1, 3); const short = course.substring(0, 2);
const name = this.courseNames[short]; const name = this.courseNames[short];
if (name == undefined) continue; if (name == undefined) continue;
courses.push({ courses.push({

View File

@@ -34,6 +34,14 @@ export class SchedulePage implements OnInit {
this.timetable = await this.storage.getItem("timetable"); this.timetable = await this.storage.getItem("timetable");
if (this.timetable == undefined) { if (this.timetable == undefined) {
this.timetable = {
mon: [],
tue: [],
wed: [],
thu: [],
fri: []
};
for (let day of ['mon', 'tue', 'wed', 'thu', 'fri']) { for (let day of ['mon', 'tue', 'wed', 'thu', 'fri']) {
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
this.timetable[day].push(undefined); this.timetable[day].push(undefined);

View File

@@ -82,7 +82,11 @@ export class SubstitutionPage implements OnInit {
public hasClass(course: string): boolean { public hasClass(course: string): boolean {
if (!this.filterByClasses) return true; if (!this.filterByClasses) return true;
return this.courses.includes(course); if (course == "&nbsp;") return true;
return this.courses.includes(course
.replace("1", "")
.replace("2", ""));
} }
public addFakeSubstitution(event: any) { public addFakeSubstitution(event: any) {