Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 41 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
# Moodle Plugin "sync_service"

This plugin for Moodle (type: local) adds serveral functions to the Moodle Web Service API.
Those fuctions allow users and external services to remotely create and move new course modules.
Furthermore an external service (called "Course Sync Extension Service") containing the newly added functions and other core web service functions, which are helpful to use the added functions, is added.

The plugin is developed to work with the desktop application [MoodleSync](https://github.com/MoodleSync/sync-app), used for file synchronization between a local directory and the learning platform Moodle.

Following functions are added:
Function | Description | Note
-------- | -------- | --------
local_course_add_new_course_module_url |Add course module URL |
local_course_add_new_course_module_resource | Add course module Resource | File needs to be uploaded with "/webservice/upload.php" web service call.
local_course_add_new_course_module_directory | Add course modul Folder | Files need to be uploaded with "/webservice/upload.php" web service call.
local_course_add_files_to_directory | Add files to existing folders | Files need to be uploaded with "/webservice/upload.php" web service call; since version 3.0.0
local_course_move_module_to_specific_position | Move a module to a dedicated position |
local_course_add_new_section | Create and position a new course section | Since version 2.0.0

Usage:
* Tested on Moodle versions 3.11.4, 4.0.2, 4.1.2. and 4.2.2.
* Usage of the "REST (returning JSON)"- web service protocol.
* To install the plugin, you may use the in-build plugin installation interface. Or you can unzip the archive and copy the folder "sync_service" into the directory "\server\moodle\local". Afterwards restart Moodle, log-in as an admin and follow the installation process.
* To use the added fuctions, either enable and use the added external service (file upload and file download must be allowed) or create a new external service.
* **Be aware: the plugins setting "restrictedusers" is disabled.**
This plugin for Moodle (type: local) adds several functions to the Moodle Web Service API.
These functions allow users and external services to remotely create, move, and manage course modules with a focus on autonomous course design.

Originally developed for [MoodleSync](https://github.com/MoodleSync/sync-app), this fork adds advanced authoring capabilities for pages and labels to support AI-driven course generation.

## Added Functions

The following functions are available via the Moodle Web Service API:

| Function | Description | Note |
| -------- | ----------- | ---- |
| `local_course_add_new_course_module_url` | Add course module URL | |
| `local_course_add_new_course_module_resource` | Add course module Resource | File needs to be uploaded with "/webservice/upload.php". |
| `local_course_add_new_course_module_directory` | Add course module Folder | Files need to be uploaded with "/webservice/upload.php". |
| `local_course_add_new_course_module_page` | **Add course module Page** | Supports HTML content (PARAM_RAW). Uses CMID-First logic for stability. |
| `local_course_add_new_course_module_label` | **Add course module Label** | Supports HTML/Text labels for course structuring. |
| `local_course_add_files_to_directory` | Add files to existing folders | Since version 3.0.0. |
| `local_course_move_module_to_specific_position` | Move a module to a dedicated position | |
| `local_course_add_new_section` | Create and position a new course section | Since version 2.0.0. |

## New in this Fork (v2024061803+)

* **Authoring Support:** Added support for `mod_page` and `mod_label` which were previously missing from the API.
* **HTML Support:** Text parameters now use `PARAM_RAW` to allow for CSS-styled content, H5P embeds, and complex layouts.
* **CMID-First Strategy:** Internal refactoring ensures that complex modules (like Pages) are correctly linked to a Course Module ID (CMID) before instance creation, preventing "Invalid Module ID" errors.

## Usage & Installation

* **Compatibility:** Tested on Moodle versions 3.11.x, 4.x, and **5.2.x**.
* **Protocol:** Uses the "REST (returning JSON)" web service protocol.
* **Installation:**
1. Unzip the archive into the directory `local/sync_service`.
2. Log in as an admin and follow the installation process via the Notifications page.
3. Ensure the external service "Gemini MCP" or "Course Sync Extension Service" is enabled.
* **Requirements:** File upload and download must be allowed in the web service settings.
* **Security:** The setting `restrictedusers` is disabled by default to allow flexible agent interaction.

## License

This plugin is licensed under the same terms as the original Moodle sync_service plugin.

22 changes: 20 additions & 2 deletions db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,25 @@
'type' => 'write',
'ajax' => true,
'capabilities' => 'mod/folder:managefiles'
),
'local_course_add_new_course_module_page' => array(
'classname' => 'local_sync_service_external',
'methodname' => 'local_sync_service_add_new_course_module_page',
'classpath' => 'local/sync_service/externallib.php',
'description' => 'Add course module Page',
'type' => 'write',
'ajax' => true,
'capabilities' => 'mod/page:addinstance',
),
'local_course_add_new_course_module_label' => array(
'classname' => 'local_sync_service_external',
'methodname' => 'local_sync_service_add_new_course_module_label',
'classpath' => 'local/sync_service/externallib.php',
'description' => 'Add course module Label',
'type' => 'write',
'ajax' => true,
'capabilities' => 'mod/label:addinstance',
)


);

$services = array(
Expand All @@ -91,6 +107,8 @@
'local_course_move_module_to_specific_position',
'local_course_add_new_course_module_directory',
'local_course_add_files_to_directory',
'local_course_add_new_course_module_page',
'local_course_add_new_course_module_label',
'core_course_get_contents',
'core_enrol_get_users_courses',
'core_webservice_get_site_info',
Expand Down
Loading