import Calendar from "models/Calendar" ; import Discipline from "models/Discipline" ; import Evaluation from "models/Evaluation" ; import History from "models/History" ; import Schedule from "models/Schedule" ; import SchoolGrade from "models/SchoolGrade" ; export enum EmailIntegration { fatec , etec , preferential , websai } interface IRegisteredEmail { email ? : string ; integration : EmailIntegration ; } interface IAttendance { absenses : number ; presences : number ; } interface IPartialGrade { finalScore : number ; frequency : number ; discipline : Discipline ; evaluations : Evaluation [ ] ; } interface IProfile { averageGrade : number ; birthday : Date ; code : string ; course : string ; cpf : string ; email : string ; name : string ; period : string ; picture ? : string ; progress : number ; unit : string ; } export default class Student { private averageGrade : number ; private name : string ; private birthday : Date ; private code : string ; private course : string ; private cpf : string ; private email : string ; private period : string ; private picture : string ; private progress : number ; private unit : string ; private registeredEmails : IRegisteredEmail [ ] ; private partialGrades : IPartialGrade [ ] ; private enrolledDisciplines : Discipline [ ] = [ ] ; private schedules : Schedule [ ] ; private history : History ; private schoolGrade : SchoolGrade ; private academicCalendar : Calendar ; public isEnrolledAtDiscipline ( discipline ) { return this . enrolledDisciplines . filter ( ( _discipline ) => _discipline . getCode ( ) === discipline . getCode ( ) ) . length > 0 ; } public setProfile ( profile ) { this . averageGrade = profile . averageGrade ; this . birthday = profile . birthday ; this . code = profile . code ; this . course = profile . course ; this . cpf = profile . cpf ; this . email = profile . email ; this . name = profile . name ; this . period = profile . period ; this . picture = profile . picture ; this . progress = profile . progress ; this . unit = profile . unit ; } public getProfile ( ) { return { averageGrade : this . averageGrade , birthday : this . birthday , code : this . code , course : this . course , cpf : this . cpf , email : this . email , name : this . name , period : this . period , picture : this . picture , progress : this . progress , unit : this . unit , } ; } public setPicture ( picture ) { this . picture = picture ; } public getPicture ( ) { return this . picture ; } public setAcademicCalendar ( calendar ) { this . academicCalendar = calendar ; } public getAcademicCalendar ( ) { return this . academicCalendar ; } public setSchoolGrade ( schoolGrade ) { this . schoolGrade = schoolGrade ; } public getSchoolGrade ( ) { return this . schoolGrade ; } public setHistory ( history ) { this . history = history ; } public getHistory ( ) { return this . history ; } public setSchedules ( schedules ) { this . schedules = schedules ; } public getSchedules ( ) { return this . schedules ; } public getEnrolledDisciplineByCode ( code ) { return this . enrolledDisciplines . filter ( ( d ) => d . getCode ( ) === code ) [ 0 ] ; } public setName ( name ) { this . name = name ; } public getName ( ) { return this . name ; } public setRegisteredEmails ( registeredEmails ) { this . registeredEmails = registeredEmails ; } public getRegisteredEmails ( ) { return this . registeredEmails ; } public setPartialGrades ( partialGrades ) { this . partialGrades = partialGrades ; } public getPartialGrades ( ) { return this . partialGrades ; } public setEnrolledDisciplines ( disciplines ) { disciplines . forEach ( ( discipline ) => this . setEnrolledDiscipline ( discipline ) ) ; } public setEnrolledDiscipline ( discipline ) { if ( this . isEnrolledAtDiscipline ( discipline ) ) { this . updateDiscipline ( discipline ) ; } else { this . enrolledDisciplines . push ( discipline ) ; } } public getEnrolledDisciplineIndexByCode ( code ) { return this . enrolledDisciplines . indexOf ( this . getEnrolledDisciplineByCode ( code ) ) ; } public getEnrolledDisciplines ( ) { return this . enrolledDisciplines ; } private updateDiscipline ( discipline ) { const index = this . getEnrolledDisciplineIndexByCode ( discipline . getCode ( ) ) ; this . enrolledDisciplines [ index ] = Object . assign ( this . enrolledDisciplines [ index ] , JSON . parse ( JSON . stringify ( discipline ) ) ) ; } }