migrated to work with new iserv and units versions
This commit is contained in:
@@ -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 node = substitutions.ChildNodes[i];
|
||||
if (node.ChildNodes.Count < 9) 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
|
||||
var cols = new UnitsCollumns {
|
||||
Classes = 0,
|
||||
Times = 1,
|
||||
Repre = 2,
|
||||
Teacher = 3,
|
||||
Lesson = 4,
|
||||
Room = 5,
|
||||
Type = 6,
|
||||
Desc = 7
|
||||
};
|
||||
|
||||
var classes = node.ChildNodes[0].InnerText;
|
||||
for (int i = 1; i < substitutions.ChildNodes.Count; i++) {
|
||||
var node = substitutions.ChildNodes[i];
|
||||
if (node.ChildNodes.Count < 8) continue;
|
||||
if (!node.ChildNodes[cols.Times].InnerText.Contains("-")) continue;
|
||||
|
||||
var substitution = new Substitution {
|
||||
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[cols.Classes].InnerText;
|
||||
|
||||
if (!classes.StartsWith("Q")) {
|
||||
string grade = new string(classes.ToCharArray().Where(char.IsNumber).ToArray());
|
||||
|
||||
12
BetterIServ.Backend/Entities/UnitsCollumns.cs
Normal file
12
BetterIServ.Backend/Entities/UnitsCollumns.cs
Normal 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; }
|
||||
}
|
||||
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user