[+] Create courseInfo class

This commit is contained in:
Hykilpikonna
2020-04-19 19:18:30 -04:00
parent fce32881e3
commit 0306585cf8
+33 -3
View File
@@ -29,11 +29,16 @@ export default class CourseInfo
this.courseCount = this.courseIds.length;
this.gradeLevels = [];
this.uniqueName = this.name
this.uniqueName = CourseInfo.toUniqueName(this.name);
this.enrollments = 0;
}
static toUniqueName(name: string)
{
return name
.replace(/( Semester| Full Year|)/g, '')
.replace(/( Accelerated| Honors| College Prep|)/g, '')
.replace(/( A| Acc| CP| H| \(.*\))$/g, '')
this.enrollments = 0;
.replace(/( A| Acc| CP| H| \(.*\))$/g, '');
}
}
@@ -43,3 +48,28 @@ export interface UniqueCourse
courses: CourseInfo[]
enrollments: number
}
export class ClassInfo
{
id: number
name: string
teacher: string
level: string
uniqueName: string
/**
* Construct with a json object
*
* @param json
*/
constructor(json: any)
{
this.id = json.id;
this.name = json.name.trim().replace('&', '&').replace('"', '"')
this.teacher = json.teacher
this.level = json.level;
this.uniqueName = CourseInfo.toUniqueName(this.name);
}
}