Skip to content

Assign

py_moodle.assign

Assignment management module for py-moodle.

Classes:

Name Description
MoodleAssignError

Exception raised for errors in assign operations.

Functions:

Name Description
add_assign

Creates a new assign with sensible defaults, similar to add_label.

Attributes

MODULE_NAME module-attribute

MODULE_NAME = 'assign'

Classes

MoodleAssignError

Bases: Exception

Exception raised for errors in assign operations.

Functions

add_assign

add_assign(
    session: Session,
    base_url: str,
    sesskey: str,
    course_id: int,
    section_id: int,
    name: str,
    intro: str = "",
    **kwargs: Any
) -> int

Creates a new assign with sensible defaults, similar to add_label.

Parameters:

Name Type Description Default
session Session

Authenticated requests.Session object.

required
base_url str

Base URL of the Moodle instance.

required
sesskey str

Session key for form submissions.

required
course_id int

The ID of the course to add the assign to.

required
section_id int

The ID of the section to add the assign to.

required
name str

The name of the assignment.

required
intro str

The introduction/description displayed on the course page.

''
**kwargs Any

Optional overrides for advanced assign settings. Examples: max_grade=50, due_date=datetime(...), etc.

{}

Returns:

Type Description
int

The new course module ID (cmid) of the created assign.