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:
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 AbsenceDay objects.

async get_agenda(begin, end, event_code=None, *, separate_days=True)

Get the agenda in a range of dates.

Parameters:
  • begin (Union[date, datetime]) – The start date.

  • end (Union[date, datetime]) – The end date.

  • event_code (Optional[EventCode]) – The event code to filter by.

  • separate_days (bool) – Whether to separate the events by day.

Return type:

AgendaDay

Returns:

A list of AgendaDay objects.

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 Day objects.

async get_lessons(begin, end=None, *, subject=None)

Get the lessons in a range of dates.

Parameters:
  • begin (Union[date, datetime]) – The start date.

  • end (Union[date, datetime, None]) – The end date.

  • subject (Optional[int]) – The subject to filter by.

Return type:

List[Lesson]

Returns:

A list of Lesson objects.

async get_periods()

Get the periods of the student’s school.

Returns:

A list of Period objects.

async get_school_days(begin=None, end=None)

Get the school days 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[SchoolDay]

Returns:

A list of SchoolDay objects.

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 AbsenceDay objects.

async get_grades(subject=None)

Get the grades that were given during the period.

Return type:

List[Grade]

Returns:

A list of Grade objects.

Parameters:

subject (Subject | None)

async get_notes(type=None)

Get the notes assigned during the period.

Return type:

List[Note]

Returns:

A list of Note objects.

Parameters:

type (NoteType | None)

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:
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:
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:

Union[PartialNoticeboardItem, NoticeboardItem]

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:

NoticeboardItem

Returns:

The noticeboard full item.

class aiocvv.helpers.noticeboard.NoticeboardItem(nb, payload, content)

Represents a item in the noticeboard. See also PartialNoticeboardItem.

Parameters:
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.

async read()

This function doesn’t do anything, but exists for compatibility with partial items and to avoid useless requests.

See also read(). :return: This item.

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:
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.