MDL-83469 core_courseformat: alternative new_module actions

The previous create_module actions uses section number instead of
section id. This produces several bugs when sections are moved around
the course in edit mode. This issue implements a new_module action with
all related mutations and webservices. The new one uses section id
instead of section number.
This commit is contained in:
ferran
2025-03-20 18:23:00 +01:00
parent 8f89677192
commit 9428131e56
20 changed files with 673 additions and 30 deletions
+13
View File
@@ -30,12 +30,15 @@ use core_courseformat\base as course_format;
* @package core_courseformat
* @copyright 2024 Mikel Martín <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 5.0
* @todo Remove this class in Moodle 6.0 MDL-83851
*/
class create_module extends external_api {
/**
* Webservice parameters.
*
* @deprecated since Moodle 5.0
* @return external_function_parameters
*/
public static function execute_parameters(): external_function_parameters {
@@ -60,6 +63,7 @@ class create_module extends external_api {
* on cms, sections and the general course data. However, if some plugin needs adhoc messages for
* its own mutation module, extend this class in format_XXX\course.
*
* @deprecated since Moodle 5.0
* @param int $courseid the course id
* @param string $modname the module name
* @param int $targetsectionnum the target section number
@@ -139,9 +143,18 @@ class create_module extends external_api {
/**
* Webservice returns.
*
* @deprecated since Moodle 5.0
* @return external_value
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW, 'Encoded course update JSON');
}
/**
* Mark the function as deprecated.
* @return bool
*/
public static function execute_is_deprecated() {
return true;
}
}