Folder¶
py_moodle.folder ¶
Folder module management for Moodle CLI.
Provides functions to create, update, and delete 'folder' modules, as well as manage their contents (add, remove, rename files) using Moodle's web forms and AJAX endpoints.
All code and comments are in English.
Classes:
Name | Description |
---|---|
MoodleFolderError |
Exception raised for errors in folder operations. |
Functions:
Name | Description |
---|---|
add_folder |
Creates a new folder module by calling the generic module creation function. |
delete_folder |
Deletes a folder module by calling the generic module deletion function. |
add_file_to_folder |
Adds a file to an existing folder and saves. |
delete_file_from_folder |
Deletes a file from an existing folder and saves. |
rename_file_in_folder |
Renames a file in an existing folder and saves. |
list_folder_content |
Lists the files inside a folder module by parsing its view page. |
Classes¶
MoodleFolderError ¶
Bases: Exception
Exception raised for errors in folder operations.
Functions¶
add_folder ¶
add_folder(
session: Session,
base_url: str,
sesskey: str,
course_id: int,
section_id: int,
name: str,
files_itemid: int,
intro_html: str = "",
visible: int = 1,
) -> int
Creates a new folder module by calling the generic module creation function.
delete_folder ¶
Deletes a folder module by calling the generic module deletion function.
add_file_to_folder ¶
add_file_to_folder(
session: Session,
base_url: str,
sesskey: str,
cmid: int,
file_path: str,
subfolder: str = "/",
progress_callback: Optional[
Callable[[int], None]
] = None,
) -> Tuple[bool, Optional[str]]
Adds a file to an existing folder and saves. Returns a tuple: (success_status, final_filename_on_moodle).
delete_file_from_folder ¶
delete_file_from_folder(
session: Session,
base_url: str,
sesskey: str,
cmid: int,
filename: str,
) -> bool
Deletes a file from an existing folder and saves.
rename_file_in_folder ¶
rename_file_in_folder(
session: Session,
base_url: str,
sesskey: str,
cmid: int,
old_filename: str,
new_filename: str,
) -> bool
Renames a file in an existing folder and saves.
list_folder_content ¶
Lists the files inside a folder module by parsing its view page.