Skip to content

Scorm

py_moodle.scorm

SCORM module management for py-moodle.

Classes:

Name Description
MoodleScormError

Exception raised for errors in SCORM operations.

Functions:

Name Description
add_scorm

Creates a new SCORM module using the webservice for file upload.

add_scorm_ajax

Creates a new SCORM package module by uploading the file and using the generic module creation function.

Attributes

MODULE_NAME module-attribute

MODULE_NAME = 'scorm'

Classes

MoodleScormError

Bases: Exception

Exception raised for errors in SCORM operations.

Functions

add_scorm

add_scorm(
    session: Session,
    base_url: str,
    sesskey: str,
    course_id: int,
    section_id: int,
    name: str,
    file_path: str,
    intro: str = "",
    visible: int = 1,
    progress_callback: Optional[
        Callable[[int], None]
    ] = None,
    **kwargs: Any
) -> int

Creates a new SCORM module using the webservice for file upload.

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

ID of the course where the SCORM will be added.

required
section_id int

ID of the section where the SCORM will be added.

required
name str

Name of the SCORM activity.

required
file_path str

Local path to the SCORM package (.zip).

required
intro str

Introduction or description for the SCORM activity.

''
visible int

Visibility of the activity (1 for visible, 0 for hidden).

1
progress_callback Optional[Callable[[int], None]]

Optional callback to report upload progress.

None
**kwargs Any

Additional SCORM-specific settings.

{}

Returns:

Type Description
int

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

add_scorm_ajax

add_scorm_ajax(
    session: Session,
    base_url: str,
    sesskey: str,
    course_id: int,
    section_id: int,
    name: str,
    file_path: str,
    intro: str = "",
    visible: int = 1,
    progress_callback: Optional[
        Callable[[int], None]
    ] = None,
    **kwargs: Any
) -> int

Creates a new SCORM package module by uploading the file and using the generic module creation function.

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 SCORM to.

required
section_id int

The ID of the section to add the SCORM to.

required
name str

The name of the SCORM activity.

required
file_path str

The local path to the SCORM .zip file.

required
intro str

The introduction or description for the SCORM activity.

''
visible int

Whether the activity is visible (1) or hidden (0).

1
**kwargs Any

Optional overrides for advanced SCORM settings.

{}

Returns:

Type Description
int

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