Merge branch 'MDL-74925-master' of https://github.com/lameze/moodle
This commit is contained in:
@@ -247,11 +247,11 @@ class stateactions {
|
||||
if (!empty($modinfo->sections[$section->section])) {
|
||||
foreach ($modinfo->sections[$section->section] as $modnumber) {
|
||||
$cm = $modinfo->cms[$modnumber];
|
||||
$updates->add_cm_delete($cm->id);
|
||||
$updates->add_cm_remove($cm->id);
|
||||
}
|
||||
}
|
||||
course_delete_section($course, $section, true, true);
|
||||
$updates->add_section_delete($sectionid);
|
||||
$updates->add_section_remove($sectionid);
|
||||
}
|
||||
|
||||
// Removing a section affects the full course structure.
|
||||
|
||||
@@ -128,9 +128,21 @@ class stateupdates implements JsonSerializable {
|
||||
/**
|
||||
* Add track about a section deleted.
|
||||
*
|
||||
* @deprecated since Moodle 4.1 MDL-74925 - please call add_section_remove() instead.
|
||||
* @param int $sectionid The affected section id.
|
||||
*/
|
||||
public function add_section_delete(int $sectionid): void {
|
||||
debugging('add_section_delete() is deprecated. Please use add_section_remove() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$this->add_update('section', 'remove', (object)['id' => $sectionid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add track about a section removed.
|
||||
*
|
||||
* @param int $sectionid The affected section id.
|
||||
*/
|
||||
public function add_section_remove(int $sectionid): void {
|
||||
$this->add_update('section', 'remove', (object)['id' => $sectionid]);
|
||||
}
|
||||
|
||||
@@ -178,9 +190,21 @@ class stateupdates implements JsonSerializable {
|
||||
/**
|
||||
* Add track about a course module deleted.
|
||||
*
|
||||
* @deprecated since Moodle 4.1 MDL-74925 - please call add_cm_remove() instead.
|
||||
* @param int $cmid the affected course module id
|
||||
*/
|
||||
public function add_cm_delete(int $cmid): void {
|
||||
debugging('add_cm_delete() is deprecated. Please use add_cm_remove() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$this->add_update('cm', 'remove', (object)['id' => $cmid]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add track about a course module removed.
|
||||
*
|
||||
* @param int $cmid the affected course module id
|
||||
*/
|
||||
public function add_cm_remove(int $cmid): void {
|
||||
$this->add_update('cm', 'remove', (object)['id' => $cmid]);
|
||||
}
|
||||
|
||||
@@ -188,7 +212,7 @@ class stateupdates implements JsonSerializable {
|
||||
* Add a valid update message to the update list.
|
||||
*
|
||||
* @param string $name the update name
|
||||
* @param string $action the update action (usually update, create, delete)
|
||||
* @param string $action the update action (usually update, create, remove)
|
||||
* @param stdClass $fields the object fields
|
||||
*/
|
||||
protected function add_update(string $name, string $action, stdClass $fields): void {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ class update_course_test extends \externallib_advanced_testcase {
|
||||
'action' => 'format_do_something',
|
||||
'expected' => [
|
||||
'count' => 1,
|
||||
'action' => 'delete',
|
||||
'action' => 'remove',
|
||||
'visible' => null,
|
||||
],
|
||||
'expectexception' => false,
|
||||
|
||||
@@ -65,7 +65,7 @@ class stateactions extends core_actions {
|
||||
?int $targetcmid = null
|
||||
): void {
|
||||
|
||||
$updates->add_cm_delete(array_pop($ids));
|
||||
$updates->add_cm_remove(array_pop($ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -143,7 +143,7 @@ class stateactions_test extends \advanced_testcase {
|
||||
'cm' => [],
|
||||
'count' => 0,
|
||||
],
|
||||
'delete' => [
|
||||
'remove' => [
|
||||
'course' => [],
|
||||
'section' => [],
|
||||
'cm' => [],
|
||||
@@ -236,10 +236,10 @@ class stateactions_test extends \advanced_testcase {
|
||||
// Format results in a way we can compare easily.
|
||||
$results = $this->summarize_updates($updates);
|
||||
|
||||
// The state actions does not use create or delete actions because they are designed
|
||||
// The state actions does not use create or remove actions because they are designed
|
||||
// to refresh parts of the state.
|
||||
$this->assertEquals(0, $results['create']['count']);
|
||||
$this->assertEquals(0, $results['delete']['count']);
|
||||
$this->assertEquals(0, $results['remove']['count']);
|
||||
|
||||
// Validate we have all the expected entries.
|
||||
$expectedtotal = count($expectedresults['course']) + count($expectedresults['section']) + count($expectedresults['cm']);
|
||||
|
||||
@@ -186,7 +186,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
$this->assertEquals($action, $update->action);
|
||||
$this->assertEquals('section', $update->name);
|
||||
// Delete does not provide all fields.
|
||||
if ($action == 'delete') {
|
||||
if ($action == 'remove') {
|
||||
$this->assertEquals($section->id, $update->fields->id);
|
||||
} else {
|
||||
$this->assertEquals($expected, $update->fields);
|
||||
@@ -203,7 +203,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
return array_merge(
|
||||
$this->add_section_provider_helper('put'),
|
||||
$this->add_section_provider_helper('create'),
|
||||
$this->add_section_provider_helper('delete'),
|
||||
$this->add_section_provider_helper('remove'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
*/
|
||||
private function add_section_provider_helper(string $action): array {
|
||||
// Delete does not depends on user permissions.
|
||||
if ($action == 'delete') {
|
||||
if ($action == 'remove') {
|
||||
$studentsections = [0, 1, 2];
|
||||
} else {
|
||||
$studentsections = [0, 1];
|
||||
@@ -247,7 +247,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
* @dataProvider add_cm_provider
|
||||
* @covers ::add_cm_update
|
||||
* @covers ::add_cm_create
|
||||
* @covers ::add_cm_delete
|
||||
* @covers ::add_cm_remove
|
||||
*
|
||||
* @param string $action the action name
|
||||
* @param string $role the user role name
|
||||
@@ -330,7 +330,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
$this->assertEquals($action, $update->action);
|
||||
$this->assertEquals('cm', $update->name);
|
||||
// Delete does not provide all fields.
|
||||
if ($action == 'delete') {
|
||||
if ($action == 'remove') {
|
||||
$this->assertEquals($cm->id, $update->fields->id);
|
||||
} else {
|
||||
$this->assertEquals($expected, $update->fields);
|
||||
@@ -347,7 +347,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
return array_merge(
|
||||
$this->add_cm_provider_helper('put'),
|
||||
$this->add_cm_provider_helper('create'),
|
||||
$this->add_cm_provider_helper('delete'),
|
||||
$this->add_cm_provider_helper('remove'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ class stateupdates_test extends \advanced_testcase {
|
||||
*/
|
||||
private function add_cm_provider_helper(string $action): array {
|
||||
// Delete does not depends on user permissions.
|
||||
if ($action == 'delete') {
|
||||
if ($action == 'remove') {
|
||||
$studentcms = [0, 1, 2, 3];
|
||||
} else {
|
||||
$studentcms = [0];
|
||||
|
||||
@@ -2,6 +2,10 @@ This files describes API changes for course formats
|
||||
|
||||
Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
|
||||
|
||||
=== 4.1 ===
|
||||
* New \core_courseformat\stateupdates methods add_section_remove() and add_cm_remove() have been added to replace
|
||||
the deprecated methods add_section_delete() and add_cm_delete().
|
||||
|
||||
=== 4.0 ===
|
||||
* New core_courseformat\base::uses_course_index() to define whether the course format uses course index or not.
|
||||
* New core_courseformat\base::supports_components() to specify if the format is compatible with reactive components.
|
||||
|
||||
@@ -103,6 +103,9 @@
|
||||
<testsuite name="core_course_testsuite">
|
||||
<directory suffix="_test.php">course/tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="core_courseformat_testsuite">
|
||||
<directory suffix="_test.php">course/format/tests</directory>
|
||||
</testsuite>
|
||||
<testsuite name="core_privacy_testsuite">
|
||||
<directory suffix="_test.php">privacy/tests</directory>
|
||||
</testsuite>
|
||||
|
||||
Reference in New Issue
Block a user