class Teacher: """School teacher or employee :var int ~.id: Teacher ID :var str ~.first_name: Teacher first name :var str ~.last_name: Teacher last name (surname) :var str ~.short: Code (short name) of the teacher :var int ~.login_id: Teacher account ID """ id = IntegerField(key="Id") first_name = StringField(key="Imie") last_name = StringField(key="Nazwisko") short = StringField(key="Kod") login_id = IntegerField(key="LoginId") @property def name(self): """Returns the teacher's full name as "Name Surname". :rtype: str """ return "{} {}".format(self.first_name, self.last_name) @property def name_reversed(self): return "{} {}".format(self.last_name, self.first_name)
class Period: """School year period :var int ~.id: Period ID :var int ~.number: Number of the period :var int ~.level: Level (class level) of the period :var `datetime.date` ~.from_: Period start date :var `datetime.date` ~.to: Period end date """ id = IntegerField(key="IdOkresKlasyfikacyjny") number = IntegerField(key="OkresNumer") level = IntegerField(key="OkresPoziom") from_ = DateField(key="OkresDataOdTekst", required=False) to = DateField(key="OkresDataDoTekst", required=False) @staticmethod def only_keys(json): return dict_only( json, { "IdOkresKlasyfikacyjny", "OkresNumer", "OkresPoziom", "OkresDataOdTekst", "OkresDataDoTekst", }, )
class PresenceType(Serializable): """Presence type :var int ~.id: attendance ID :var str ~.name: attendance name :var str ~.symbol: attendance symbol :var int ~.category_id: attendance category ID :var str ~.category_name: attendance category name :var int ~.position: attendance position :var bool ~.presence: presence on lesson :var bool ~.absence: absence on lesson :var bool ~.exemption: exemption from lesson :var bool ~.late: is late for lesson :var bool ~.justified: justified absence :var bool ~.deleted: whether the entry is deleted """ id = IntegerField(key="Id") name: str = StringField(key="Name") symbol: str = StringField(key="Symbol") category_id: int = IntegerField(key="CategoryId") category_name: str = StringField(key="CategoryName") position: int = IntegerField(key="Position") presence: bool = BooleanField(key="Presence") absence: bool = BooleanField(key="Absence") exemption: bool = BooleanField(key="LegalAbsence") late: bool = BooleanField(key="Late") justified: bool = BooleanField(key="AbsenceJustified") deleted: bool = BooleanField(key="Removed")
class GradeColumn(Serializable): """A grade column. Represents a topic which a student may get a grade from (e.g. a single exam, short test, homework). :var int ~.id: grade column's ID :var str ~.key: grade column's key (UUID) :var int ~.period_id: ID of the period when the grade is given :var str ~.name: grade column's name (description) :var str ~.code: grade column's code (e.g. short name or abbreviation) :var str ~.group: unknown, yet :var int ~.number: unknown, yet :var int ~.weight: weight of this column's grades :var `~vulcan.hebe.model.Subject` ~.subject: the subject from which grades in this column are given :var `~vulcan.hebe.data.GradeCategory` ~.category: category (base type) of grades in this column :var `~vulcan.hebe.model.Period` ~.period: a resolved period of this grade """ id: int = IntegerField(key="Id") key: str = StringField(key="Key") period_id: int = IntegerField(key="PeriodId") name: str = StringField(key="Name") code: str = StringField(key="Code") group: str = StringField(key="Group") number: int = IntegerField(key="Number") weight: float = FloatField(key="Weight") subject: Subject = ChildField(Subject, key="Subject") category: GradeCategory = ChildField(GradeCategory, key="Category") period: Period = ChildField(Period, key="Period", required=False)
class Grade(Serializable): """A grade. :var int ~.id: grade's ID :var str ~.key: grade's key (UUID) :var int ~.pupil_id: the related pupil's ID :var str ~.content_raw: grade's content (with comment) :var str ~.content: grade's content (without comment) :var `~vulcan.model.DateTime` ~.date_created: grade's creation date :var `~vulcan.model.DateTime` ~.date_modified: grade's modification date (may be the same as ``date_created`` if it was never modified) :var `~vulcan.model.Teacher` ~.teacher_created: the teacher who added the grade :var `~vulcan.model.Teacher` ~.teacher_modified: the teacher who modified the grade :var `~vulcan.data.GradeColumn` ~.column: grade's column :var float ~.value: grade's value, may be `None` if 0.0 :var str ~.comment: grade's comment, visible in parentheses in ``content_raw`` :var float ~.numerator: for point grades: the numerator value :var float ~.denominator: for point grades: the denominator value """ id: int = IntegerField(key="Id") key: str = StringField(key="Key") pupil_id: int = IntegerField(key="PupilId") content_raw: str = StringField(key="ContentRaw") content: str = StringField(key="Content") date_created: DateTime = ChildField(DateTime, key="DateCreated") date_modified: DateTime = ChildField(DateTime, key="DateModify") teacher_created: Teacher = ChildField(Teacher, key="Creator") teacher_modified: Teacher = ChildField(Teacher, key="Modifier") column: GradeColumn = ChildField(GradeColumn, key="Column") value: float = FloatField(key="Value", required=False) comment: str = StringField(key="Comment", required=False) numerator: float = FloatField(key="Numerator", required=False) denominator: float = FloatField(key="Denominator", required=False) @classmethod async def get( cls, api, last_sync, deleted, **kwargs ) -> Union[AsyncIterator["Grade"], List[int]]: """ :rtype: Union[AsyncIterator[:class:`~vulcan.data.Grade`], List[int]] """ data = await api.helper.get_list( DATA_GRADE, FilterType.BY_PUPIL, deleted=deleted, last_sync=last_sync, **kwargs ) for grade in data: grade["Column"]["Period"] = api.student.period_by_id( grade["Column"]["PeriodId"] ).as_dict yield Grade.load(grade)
class LessonChanges(Serializable): """Lesson changes :var int ~.id: lesson change ID :var int ~.type: lesson change type :var bool ~.code: team separation """ id: int = IntegerField(key="Id") type: int = IntegerField(key="Type") separation: bool = BooleanField(key="Separation")
class Subject: """School subject :var int ~.id: Subject ID :var str ~.name: Subject full name :var str ~.short: Short name of the subject :var int ~.position: Position of the subject in subjects list """ id = IntegerField(key="Id") name = StringField(key="Nazwa") short = StringField(key="Kod") position = IntegerField(key="Pozycja")
class LessonTime: """Lesson time (start-end range) :var int ~.id: Lesson time ID :var int ~.number: Lesson number :var `datetime.time` ~.from_: Lesson start time :var `datetime.time` ~.to: Lesson end time """ id = IntegerField(key="Id") number = IntegerField(key="Numer") from_ = TimeField(key="PoczatekTekst", formatter=TIME_FORMAT_H_M) to = TimeField(key="KoniecTekst", formatter=TIME_FORMAT_H_M)
class Student: """Student :var int ~.id: Student ID :var int ~.login_id: ID of the logged user :var str ~.account_name: Student account name :var str ~.first_name: Student first name :var str ~.second_name: Student second name, optional :var str ~.last_name: Student last name (surname) :var `~vulcan._student.Gender` ~.gender: Student gender :var str ~.nickname: Student nickname :var `~vulcan._period.Period` ~.period: Current student class period :var `~vulcan._class.Class` ~.class_: Student class :var `~vulcan._school.School` ~.school: Student school """ id = IntegerField(key="Id") login_id = IntegerField(key="UzytkownikLoginId") account_name = StringField(key="UzytkownikNazwa") first_name = StringField(key="Imie") last_name = StringField(key="Nazwisko") gender = ChildField(Gender, key="UczenPlec") second_name = StringField(key="Imie2", required=False) nickname = StringField(key="Pseudonim", required=False) period = ChildField(Period, required=False) class_ = ChildField(Class, required=False) school = ChildField(School, required=False) @property def name(self): """Returns the student's full name as "Name SecondName Surname". :rtype: str """ first = "{} {}".format(self.first_name, self.second_name).rstrip() return "{} {}".format(first, self.last_name) @staticmethod def format_json(json): json["period"] = Period.only_keys(json) json["class_"] = Class.only_keys(json) json["school"] = School.only_keys(json) return json @classmethod def get(cls, api): j = api.post(api.base_url + "UczenStart/ListaUczniow") for student in j.get("Data", []): yield to_model(cls, cls.format_json(student))
class Subject(Serializable): """A school subject. :var int ~.id: subject ID :var str ~.key: subject's key (UUID) :var str ~.name: subject's name :var str ~.code: subject's code (e.g. short name or abbreviation) :var int ~.position: unknown, yet """ id: int = IntegerField(key="Id") key: str = StringField(key="Key") name: str = StringField(key="Name") code: str = StringField(key="Kod") position: int = IntegerField(key="Position")
class TimeSlot(Serializable): """Lesson time (start-end range) :var int ~.id: lesson time ID :var `datetime.time` ~.from_: lesson start time :var `datetime.time` ~.to: lesson end time :var str ~.displayed_time: lesson's displayed time :var int ~.position: lesson position """ id: int = IntegerField(key="Id") from_: TimeField = TimeField(key="Start", formatter=TIME_FORMAT_H_M) to: TimeField = TimeField(key="End", formatter=TIME_FORMAT_H_M) displayed_time: str = StringField(key="Display") position: int = IntegerField(key="Position")
class Notice: """Positive, negative or neutral student notice :var int ~.id: Notice ID :var str ~.content: Content of the notice :var `datetime.date` ~.date: Notice added date :var `~vulcan._notice.NoticeType` ~.type: Notice type class :var `~vulcan._teacher.Teacher` ~.teacher: Teacher, who added the notice """ id = IntegerField(key="Id") content = StringField(key="TrescUwagi") date = DateField(key="DataWpisuTekst") type = ChildField(NoticeType, required=False) teacher = ChildField(Teacher, required=False) @classmethod def get(cls, api): j = api.post("Uczen/UwagiUcznia") notices = sorted(j.get("Data", []), key=itemgetter("DataWpisu")) for notice in notices: notice["type"] = api.dict.get_notice_category_json( notice["IdKategoriaUwag"]) notice["teacher"] = api.dict.get_teacher_json( notice["IdPracownik"]) yield to_model(cls, notice)
class Lesson(Serializable): """A lesson. :var int ~.id: lesson's ID :var `~vulcan.hebe.model.DateTime` ~.date: lesson's date :var `~vulcan.hebe.model.TimeSlot` ~.time: lesson's time :var `~vulcan.hebe.data.LessonRoom` ~.room: classroom, in which is the lesson :var `~vulcan.hebe.model.Teacher` ~.teacher: teacher of the lesson :var `~vulcan.hebe.model.Teacher` ~.second_teacher: second teacher of the lesson :var `~vulcan.hebe.model.Subject` ~.subject: subject on the lesson :var str ~.event: an event happening during this lesson :var str ~.changes: lesson changes :var `~vulcan.hebe.model.TeamClass` ~.team_class: the class that has the lesson :var str ~.pupil_alias: pupil alias :var `~vulcan.hebe.model.TeamVirtual` ~.group: group, that has the lesson :var bool ~.visible: lesson visibility (whether the timetable applies to the given student) """ id: int = IntegerField(key="Id", required=False) date: DateTime = ChildField(DateTime, key="Date", required=False) time: TimeSlot = ChildField(TimeSlot, key="TimeSlot", required=False) room: LessonRoom = ChildField(LessonRoom, key="Room", required=False) teacher: Teacher = ChildField(Teacher, key="TeacherPrimary", required=False) second_teacher: Teacher = ChildField( Teacher, key="TeacherSecondary", required=False ) subject: Subject = ChildField(Subject, key="Subject", required=False) event: str = StringField(key="Event", required=False) changes: str = StringField(key="Change", required=False) team_class: TeamClass = ChildField(TeamClass, key="Clazz", required=False) pupil_alias: str = StringField(key="PupilAlias", required=False) group: TeamVirtual = ChildField(TeamVirtual, key="Distribution", required=False) visible = BooleanField(key="Visible", required=False) @classmethod async def get( cls, api, last_sync, deleted, date_from, date_to, **kwargs ) -> Union[AsyncIterator["Lesson"], List[int]]: """ :rtype: Union[AsyncIterator[:class:`~vulcan.hebe.data.Lesson`], List[int]] """ if date_from == None: date_from = datetime.date.today() if date_to == None: date_to = date_from date_to = date_to + datetime.timedelta( days=1 ) # Vulcan requires the date_to to be one greater the date it is supposed to be data = await api.helper.get_list( DATA_TIMETABLE, FilterType.BY_PUPIL, deleted=deleted, date_from=date_from, date_to=date_to, last_sync=last_sync, **kwargs ) for lesson in data: yield Lesson.load(lesson)
class Role(Serializable): """A role of addressee. :var str ~.role_name: role name :var int ~.role_order: role order :var str ~.address_name: address name :var str ~.address_hash: address hash :var str ~.first_name: recipient's first name :var str ~.last_name: recipient's last name :var str ~.initials: recipient's initials :var str ~.unit_symbol: recipient's unit_symbol :var str ~.constituent_unit_symbol: recipient's constituent unit symbol :var str ~.class_symbol: recipient's class symbol """ role_name: str = StringField(key="RoleName") role_order: int = IntegerField(key="RoleOrder") address_name: str = StringField(key="Address") address_hash: str = StringField(key="AddressHash") first_name: str = StringField(key="Name") last_name: str = StringField(key="Surname") initials: str = StringField(key="Initials") unit_symbol: str = StringField(key="UnitSymbol", required=False) constituent_unit_symbol: str = StringField(key="ConstituentUnitSymbol", required=False) class_symbol: str = StringField(key="ClassSymbol", required=False)
class DateTime(Serializable): """A date-time object used for representing points in time. :var int ~.timestamp: number of millis since the Unix epoch :var `datetime.date` ~.date: a date object :var `datetime.time` ~.time: a time object """ timestamp: int = IntegerField(key="Timestamp") date: date = DateField(key="Date") time: time = TimeField(key="Time") @property def date_time(self) -> datetime: """Combine the date and time of this object. :rtype: :class:`datetime.datetime` """ return datetime.combine(self.date, self.time) def __str__(self) -> str: return self.date_time.strftime("%Y-%m-%d %H:%m:%S") @classmethod async def get(cls, api, **kwargs) -> "DateTime": """ :rtype: :class:`~vulcan.hebe.model.DateTime` """ return await api.helper.get_object(DateTime, DATA_INTERNAL_TIME, *kwargs)
class School: """School :var int ~.id: School ID :var str ~.name: School full name :var str ~.short: Short name of the school :var str ~.symbol: School symbol """ id = IntegerField(key="IdJednostkaSprawozdawcza") name = StringField(key="JednostkaSprawozdawczaNazwa") short = StringField(key="JednostkaSprawozdawczaSkrot") symbol = StringField(key="JednostkaSprawozdawczaSymbol") @staticmethod def only_keys(json): return dict_only( json, { "IdJednostkaSprawozdawcza", "JednostkaSprawozdawczaNazwa", "JednostkaSprawozdawczaSkrot", "JednostkaSprawozdawczaSymbol", }, )
class Addressbook(Serializable): """An address book. :var str ~.id: recipient id :var str ~.login_id: recipient login id :var str ~.first_name: recipient's first name :var str ~.last_name: recipient's last name :var str ~.initials: recipient's initials :var list[Role] ~.roles: recipient's role (eg. Teacher) """ id: str = StringField(key="Id") login_id: int = IntegerField(key="LoginId") first_name: str = StringField(key="Name") last_name: str = StringField(key="Surname") initials: str = StringField(key="Initials") roles: List[Role] = SequenceField(Role, key="Roles", repr=True) @classmethod async def get(cls, api, **kwargs) -> Union[AsyncIterator["Addressbook"], List[int]]: """ :rtype: Union[AsyncIterator[:class:`~vulcan.data.Addressbook`], List[int]] """ data = await api.helper.get_list(DATA_ADDRESSBOOK, FilterType.BY_LOGIN_ID, **kwargs) for addressbook in data: yield Addressbook.load(addressbook)
class LessonRoom(Serializable): """Lesson room :var int ~.id: lesson room ID :var str ~.code: classroom code """ id: int = IntegerField(key="Id") code: str = StringField(key="Code")
class MessageRecipient: """Message recipient :var int ~.login_id: Recipient's login ID :var str ~.name: Recipient's name """ login_id = IntegerField(key="LoginId") name = StringField(key="Nazwa")
class NoticeType: """Notice type :var int ~.id: Notice type ID :var str ~.name: Name of the notice type """ id = IntegerField(key="Id") name = StringField(key="Nazwa")
class Class: """Class :var int ~.id: Class ID :var int ~.level: Class level (eg. `8`) :var str ~.name: Class name (eg. `"8A"`) :var str ~.symbol: Class symbol (eg. `"A"`) """ id = IntegerField(key="IdOddzial") level = IntegerField(key="OkresPoziom") name = StringField(key="OddzialKod", required=False) symbol = StringField(key="OddzialSymbol", required=False) @staticmethod def only_keys(json): return dict_only( json, {"IdOddzial", "OddzialKod", "OkresPoziom", "OddzialSymbol"})
class Pupil(Serializable): """A class containing the student's data. :var int ~.id: pupil's ID :var int ~.login_id: pupil's account login ID :var str ~.login_value: pupil's account login name (email/username) :var str ~.first_name: student's first name :var str ~.second_name: student's second name, optional :var str ~.last_name: student's last name / surname :var `~vulcan.model.Gender` ~.gender: student's gender """ id: int = IntegerField(key="Id") login_id: int = IntegerField(key="LoginId") first_name: str = StringField(key="FirstName") last_name: str = StringField(key="Surname") gender: Gender = ChildField(Gender, key="Sex") second_name: str = StringField(key="SecondName", required=False) login_value: str = StringField(key="LoginValue", required=False)
class Period(Serializable): """A school year period. :var int ~.id: the period ID :var int ~.level: a grade/level number :var int ~.number: number of the period in the school year :var bool ~.current: whether the period is currently ongoing :var bool ~.last: whether the period is last in the school year :var `~vulcan.model.DateTime` ~.start: the period start datetime :var `~vulcan.model.DateTime` ~.end: the period end datetime """ id: int = IntegerField(key="Id") level: int = IntegerField(key="Level") number: int = IntegerField(key="Number") current: bool = BooleanField(key="Current") last: bool = BooleanField(key="Last") start: DateTime = ChildField(DateTime, key="Start") end: DateTime = ChildField(DateTime, key="End")
class GradeCategory: """Grade category :var id ~.id: Category ID :var str ~.name: Full category name :var str ~.short: Short name of the category """ id = IntegerField(key="Id") name = StringField(key="Nazwa") short = StringField(key="Kod")
class GradeCategory(Serializable): """A base grade category. Represents a generic type, like an exam, a short test, a homework or other ("current") grades. :var int ~.id: grade category's ID :var str ~.name: grade category's name :var str ~.code: grade category's code (e.g. short name or abbreviation) """ id: int = IntegerField(key="Id") name: str = StringField(key="Name") code: str = StringField(key="Code")
class TeamClass(Serializable): """A school class. :var int ~.id: class ID :var str ~.key: class's key (UUID) :var str ~.display_name: class's display name :var str ~.symbol: class's symbol (e.g. a letter after the level, "C" in "6C") """ id: int = IntegerField(key="Id") key: str = StringField(key="Key") display_name: str = StringField(key="DisplayName") symbol: str = StringField(key="Symbol")
class School(Serializable): """A single school building. :var int ~.id: school ID :var str ~.name: school full name :var str ~.short_name: school short name :var str ~.address: school address (location) """ id: int = IntegerField(key="Id") name: str = StringField(key="Name") short_name: str = StringField(key="Short") address: str = StringField(key="Address")
class Teacher(Serializable): """A teacher or other school employee. :var int ~.id: teacher ID :var str ~.name: teacher's name :var str ~.surname: teacher's surname :var str ~.display_name: teacher's display name """ id: int = IntegerField(key="Id") name: str = StringField(key="Name") surname: str = StringField(key="Surname") display_name: str = StringField(key="DisplayName")
class Homework(Serializable): """A homework. :var int ~.id: homework's external ID :var str ~.key: homework's key (UUID) :var int ~.homework_id: homework's internal ID :var str ~.content: homework's content :var `~vulcan.hebe.model.DateTime` ~.date_created: homework's creation date :var `~vulcan.hebe.model.Teacher` ~.creator: the teacher who added the homework :var `~vulcan.hebe.model.Subject` ~.subject: the homework's subject :var List[Attachment] ~.attachments: attachments added to homework :var bool ~.is_answer_required: Is an answer required :var `~vulcan.hebe.model.DateTime` ~.deadline: homework's date and time :var `~vulcan.hebe.model.DateTime` ~.answer_deadline: homework's answer deadline :var `~vulcan.hebe.model.DateTime` ~.answer_date: homework's answer date and time """ id: int = IntegerField(key="Id") key: str = StringField(key="Key") homework_id: int = StringField(key="IdHomework") content: str = StringField(key="Content") date_created: DateTime = ChildField(DateTime, key="DateCreated") creator: Teacher = ChildField(Teacher, key="Creator") subject: Subject = ChildField(Subject, key="Subject") attachments: List[Attachment] = SequenceField(Attachment, key="Attachments", repr=True) is_answer_required: Subject = BooleanField(key="IsAnswerRequired") deadline: DateTime = ChildField(DateTime, key="Deadline") answer_deadline: DateTime = ChildField(DateTime, key="AnswerDeadline", required=False) answer_date: DateTime = ChildField(DateTime, key="AnswerDate", required=False) @classmethod async def get(cls, api, last_sync, deleted, **kwargs) -> Union[AsyncIterator["Homework"], List[int]]: """ :rtype: Union[AsyncIterator[:class:`~vulcan.hebe.data.Homework`], List[int]] """ data = await api.helper.get_list(DATA_HOMEWORK, FilterType.BY_PUPIL, deleted=deleted, last_sync=last_sync, **kwargs) for homework in data: yield Homework.load(homework)
class Exam(Serializable): """An exam or short quiz. :var int ~.id: exam's ID :var str ~.key: exam's key (UUID) :var str ~.type: exam's type :var str ~.topic: exam's topic :var `~vulcan.hebe.model.DateTime` ~.date_created: exam's creation date :var `~vulcan.hebe.model.DateTime` ~.date_modified: exam's modification date (may be the same as ``date_created`` if it was never modified) :var `~vulcan.hebe.model.DateTime` ~.deadline: exam's date and time :var `~vulcan.hebe.model.Teacher` ~.creator: the teacher who added the exam :var `~vulcan.hebe.model.Subject` ~.subject: the exam's subject :var `~vulcan.hebe.model.TeamClass` ~.team_class: the class taking the exam :var `~vulcan.hebe.model.TeamVirtual` ~.team_virtual: the class distribution taking the exam, optional """ id: int = IntegerField(key="Id") key: str = StringField(key="Key") type: str = StringField(key="Type") topic: str = StringField(key="Content") date_created: DateTime = ChildField(DateTime, key="DateCreated") date_modified: DateTime = ChildField(DateTime, key="DateModify") deadline: DateTime = ChildField(DateTime, key="Deadline") creator: Teacher = ChildField(Teacher, key="Creator") subject: Subject = ChildField(Subject, key="Subject") team_class: TeamClass = ChildField(TeamClass, key="Class") team_virtual: TeamVirtual = ChildField( TeamVirtual, key="Distribution", required=False ) @classmethod async def get( cls, api, last_sync, deleted, **kwargs ) -> Union[AsyncIterator["Exam"], List[int]]: """ :rtype: Union[AsyncIterator[:class:`~vulcan.hebe.data.Exam`], List[int]] """ data = await api.helper.get_list( DATA_EXAM, FilterType.BY_PUPIL, deleted=deleted, last_sync=last_sync, **kwargs ) for exam in data: yield Exam.load(exam)