Skip to content

Commit

Permalink
feat: added type field in every plan
Browse files Browse the repository at this point in the history
fix: added missing export for EducationalUnit
  • Loading branch information
SachsenspieltCoding committed Feb 11, 2024
1 parent 98c6009 commit cd7f900
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/interface/generic/eduUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ export interface EducationalUnit {
* The planned lessons are used to represent the substitution plan.
*/
plannedLessons: PlannedLesson[];

/**
* The type of the educational unit.
* The type can be "schoolClass", "room", or "teacher".
*/
type: 'schoolClass' | 'room' | 'teacher';
}
2 changes: 2 additions & 0 deletions src/interface/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Course } from './course';
import { EducationalUnit } from './generic/eduUnit';
import { Lesson } from './lesson';
import { PlannedLesson } from './plannedLesson';
import { Room } from './room';
Expand All @@ -8,6 +9,7 @@ import { Teacher } from './teacher';

export type {
Course,
EducationalUnit,
ISubstitutionPlan,
Lesson,
PlannedLesson,
Expand Down
4 changes: 3 additions & 1 deletion src/interface/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ import { EducationalUnit } from './generic/eduUnit.js';
/**
* A room represents a room in a school, which is used in the timetable.
*/
export interface Room extends EducationalUnit {}
export interface Room extends EducationalUnit {
readonly type: 'room';
}
2 changes: 2 additions & 0 deletions src/interface/schoolclass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Lesson } from './lesson.js';
* A school class represents a classical class or course in a school.
*/
export interface SchoolClass extends EducationalUnit {
readonly type: 'schoolClass';

/**
* The timetable of the school class.
* It is a merge of all lessons and courses, where all courses get an id of `-1`.
Expand Down
4 changes: 3 additions & 1 deletion src/interface/teacher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ import { EducationalUnit } from './generic/eduUnit.js';
/**
* A teacher represents a teacher in a school (obviously -_-).
*/
export interface Teacher extends EducationalUnit {}
export interface Teacher extends EducationalUnit {
readonly type: 'teacher';
}
1 change: 1 addition & 0 deletions src/parser/schoolClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class SchoolClassParser implements IndiwareParser<SchoolClass> {

return {
name: `${xml.Kurz}`,
type: 'schoolClass',
timetable,
courses,
lessons,
Expand Down
2 changes: 2 additions & 0 deletions src/parser/substitutionPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class SubstitutionPlanParser implements IndiwareParser<SubstitutionPlan>
rooms.push({
name: lesson.room.value,
plannedLessons: [lesson],
type: 'room',
});
}
}
Expand All @@ -51,6 +52,7 @@ export class SubstitutionPlanParser implements IndiwareParser<SubstitutionPlan>
teachers.push({
name: teacher,
plannedLessons: [lesson],
type: 'teacher',
});
}
}
Expand Down

0 comments on commit cd7f900

Please sign in to comment.