Helper Classes¶
Helpers are useful classes that help you interact with the API more easily.
Warning
Unless noted, helpers are not made to be manually constructed, but
to be used through me.
Calendar¶
This helper contains the Calendar and Period classes, which are used to interact with the calendar endpoint of the Classeviva API.
The Calendar class is used to get information about the user’s calendar, such as school days, absences, events, grades, notes, and more.
The Period class is used to get information about the school periods (e.g. first quarter, second quarter, etc.) and everything that happened during them.
- class aiocvv.helpers.calendar.Calendar(module, id)¶
Represents the whole calendar of a student.
- Parameters:
module (StudentsModule)
id (int)
- async get_absences(begin=None, end=None)¶
Get the absences in a range of dates.
- Parameters:
begin (
Union[date,datetime,None]) – The start date.end (
Union[date,datetime,None]) – The end date.
- Return type:
List[AbsenceDay]- Returns:
A list of
AbsenceDayobjects.
- async get_agenda(begin, end, event_code=None, *, separate_days=True)¶
Get the agenda in a range of dates.
- async get_day(start, end=None)¶
Get all of the information available for a specific day, merging calendar, absences, agenda, grades, notes, and school days all together here.
- Parameters:
start (
Union[date,datetime]) – The date of the day.end (
Union[date,datetime,None]) – The end date.
- Returns:
A list of
Dayobjects.
- async get_lessons(begin, end=None, *, subject=None)¶
Get the lessons in a range of dates.
- async get_periods()¶
Get the periods of the student’s school.
- Returns:
A list of
Periodobjects.
- class aiocvv.helpers.calendar.Period(calendar, **data)¶
Represents a school period (e.g. first quarter, second quarter, etc.).
- property code: str¶
The code of the period.
- property description: str¶
The description of the period.
- property end: date¶
The date of when the period ends.
- property final: bool¶
Whether the period is final or not.
- async get_absences()¶
Get the days the student has been absent during this period.
- Return type:
List[AbsenceDay]- Returns:
A list of
AbsenceDayobjects.
- async get_grades(subject=None)¶
Get the grades that were given during the period.
- async get_notes(type=None)¶
Get the notes assigned during the period.
- property miur_division_code: str | None¶
The division code provided by MIUR, if any.
- property position: int¶
The period’s position.
- property start: date¶
The date of when the period starts.
Noticeboard¶
This helper contains the classes that represent the noticeboard and its items. The noticeboard can be used both by students and teachers.
- class aiocvv.helpers.noticeboard.Attachment(item, data)¶
Represents an attachment of an uploaded noticeboard item.
- Parameters:
item (NoticeboardItem)
data (dict)
- async download()¶
Download the attachment.
- class aiocvv.helpers.noticeboard.File(data, filename)¶
Represents a file to upload to the noticeboard when joining an item.
This class is used as an argument for
join().- Parameters:
data (IO[Any])
filename (str)
- property data: IO[Any]¶
The file’s data.
- class aiocvv.helpers.noticeboard.MyNoticeboard(noticeboard, id)¶
Represents the noticeboard of a user.
- Parameters:
noticeboard (Noticeboard)
id (int)
- async all()¶
Get all the items in the noticeboard.
- Return type:
List[Union[PartialNoticeboardItem,NoticeboardItem]]
- async get(code, id)¶
Get a noticeboard item.
Note
The returned item may be partial, meaning that it doesn’t contain some data. This is because you have to read the item to get the rest of the data, and that would change the read status of the item.
- Parameters:
code (
str) – The event code of the item.id (
int) – The publication ID of the item.
- Return type:
- Returns:
The partial noticeboard item.
- async read(event_code, publication_id)¶
Read a noticeboard item.
Note
This will automatically mark the item as read from the Classeviva backend.
- Parameters:
event_code (
str) – The event code of the item.publication_id (
int) – The publication ID of the item.
- Return type:
- Returns:
The noticeboard full item.
- class aiocvv.helpers.noticeboard.NoticeboardItem(nb, payload, content)¶
Represents a item in the noticeboard. See also
PartialNoticeboardItem.- Parameters:
nb (MyNoticeboard)
payload (dict)
content (str)
- property content¶
The item’s content.
- async join(text=None, sign=None, file=None, *, raise_exc=True)¶
Join this item.
- Parameters:
text (
Optional[str]) – The text to send.sign (
Optional[bool]) – Whether to sign the text.file (
Optional[File]) – The file to upload.raise_exc (
bool) – Whether to raise an exception if an error occurs.
- Return type:
bool- Returns:
Whether the operation was successful.
- class aiocvv.helpers.noticeboard.PartialAttachment(data)¶
Represents an attachment of an uploaded noticeboard item.
Note
This comes from a partial item, so the attachment is not downloadable. To download the attachment, you must
read()the item first.- Parameters:
data (dict)
- class aiocvv.helpers.noticeboard.PartialNoticeboardItem(nb, payload)¶
Represents a item in the noticeboard partially.
Note
This class is partial, which means it must be
read()to get its content. This is because reading the item would change its read status.- Parameters:
nb (MyNoticeboard)
payload (dict)
- property attachments¶
The item’s attachments.
- property category: str¶
The item’s category.
- property code: str¶
The item’s event code.
- property has_changed: bool¶
Whether the item has changed.
- property id: int¶
The item’s publication ID.
- property is_read¶
Whether the item has been read.
- property noticeboard¶
The noticeboard this item belongs to.
- async read()¶
Read the item.
- Return type:
Union[OKResponse,ErrorResponse]- Returns:
The noticeboard full item.
- property title: str¶
The item’s title.