diff --git a/.upgradenotes/MDL-87280-2025121211100178.yml b/.upgradenotes/MDL-87280-2025121211100178.yml deleted file mode 100644 index 2b4a417d750..00000000000 --- a/.upgradenotes/MDL-87280-2025121211100178.yml +++ /dev/null @@ -1,8 +0,0 @@ -issueNumber: MDL-87280 -notes: - mod_subsection: - - message: >- - A new scheduled task, `remove_existing_descriptions`, has been added. - Once enabled, this task will remove the descriptions for all existing - subsection instances. - type: improved diff --git a/public/mod/subsection/classes/task/remove_existing_descriptions_task.php b/public/mod/subsection/classes/task/remove_existing_descriptions_task.php deleted file mode 100644 index c4515cc5b11..00000000000 --- a/public/mod/subsection/classes/task/remove_existing_descriptions_task.php +++ /dev/null @@ -1,46 +0,0 @@ -. - -namespace mod_subsection\task; - -use core\task\scheduled_task; - -/** - * A scheduled task to remove existing descriptions from subsection instances. - * - * @package mod_subsection - * @copyright 2025 Sara Arjona - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class remove_existing_descriptions_task extends scheduled_task { - /** - * Return the task name. - * - * @return string The name of the task. - */ - public function get_name(): string { - return get_string('removeexistingdescriptions', 'mod_subsection'); - } - - /** - * Execute the task. - */ - public function execute(): void { - global $DB; - - $DB->set_field('course_sections', 'summary', '', ['component' => 'mod_subsection']); - } -} diff --git a/public/mod/subsection/db/tasks.php b/public/mod/subsection/db/tasks.php deleted file mode 100644 index 7a78fbc02a5..00000000000 --- a/public/mod/subsection/db/tasks.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Definition of Subsection scheduled tasks. - * - * @package mod_subsection - * @category task - * @copyright 2025 Sara Arjona - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$tasks = [ - [ - 'classname' => '\mod_subsection\task\remove_existing_descriptions_task', - 'blocking' => 0, - 'minute' => 'R', - 'hour' => '0', - 'day' => '*', - 'dayofweek' => '*', - 'month' => '*', - 'disabled' => true, - ], -]; diff --git a/public/mod/subsection/lang/en/subsection.php b/public/mod/subsection/lang/en/subsection.php index 4989639fcb5..3893fbe662a 100644 --- a/public/mod/subsection/lang/en/subsection.php +++ b/public/mod/subsection/lang/en/subsection.php @@ -29,7 +29,6 @@ $string['pluginadministration'] = 'Subsection administration'; $string['pluginname'] = 'Subsection'; $string['privacy:metadata'] = 'Subsection does not store any personal data'; $string['quickcreatename'] = 'New subsection'; -$string['removeexistingdescriptions'] = 'Remove existing descriptions from subsection instances'; $string['subsection:addinstance'] = 'Add subsection'; $string['subsection:view'] = 'View subsection'; $string['subsectionname'] = 'Name'; diff --git a/public/mod/subsection/tests/task/remove_existing_descriptions_task_test.php b/public/mod/subsection/tests/task/remove_existing_descriptions_task_test.php deleted file mode 100644 index f1ea59fc1bc..00000000000 --- a/public/mod/subsection/tests/task/remove_existing_descriptions_task_test.php +++ /dev/null @@ -1,99 +0,0 @@ -. - -namespace mod_subsection\task; - -/** - * Class containing unit tests for the remove existing descriptions task. - * - * @package mod_subsection - * @copyright 2025 Sara Arjona - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -#[\PHPUnit\Framework\Attributes\CoversClass(remove_existing_descriptions_task::class)] -final class remove_existing_descriptions_task_test extends \advanced_testcase { - /** - * Test remove_existing_descriptions task. - */ - public function test_remove_existing_descriptions(): void { - global $DB; - - $this->resetAfterTest(); - - $course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 1]); - $this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]); - // Add description to course sections and the subsection. - $DB->set_field( - 'course_sections', - 'summary', - 'Section with description', - ['course' => $course->id], - ); - // Add another subsection without description. - $this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]); - - // Check only 2 sections and 1 subsection have description. - $this->assertEquals( - 3, - $DB->count_records_select( - 'course_sections', - 'course = :courseid AND summary != \'\'', - ['courseid' => $course->id], - ), - ); - $this->assertEquals( - 2, - $DB->count_records_select( - 'course_sections', - 'course = :courseid AND component = \'mod_subsection\'', - ['courseid' => $course->id], - ), - ); - $this->assertEquals( - 1, - $DB->count_records_select( - 'course_sections', - 'course = :courseid AND component = \'mod_subsection\' AND summary != \'\'', - ['courseid' => $course->id], - ), - ); - - // Run the task. - ob_start(); - $task = new remove_existing_descriptions_task(); - $task->execute(); - ob_end_clean(); - - // Check only 2 sections keep having description after running the task. - $this->assertEquals( - 2, - $DB->count_records_select( - 'course_sections', - 'course = :courseid AND summary != \'\'', - ['courseid' => $course->id], - ), - ); - // Check no subsection has description after running the task. - $this->assertEquals( - 0, - $DB->count_records_select( - 'course_sections', - 'course = :courseid AND component = \'mod_subsection\' AND summary != \'\'', - ['courseid' => $course->id], - ), - ); - } -} diff --git a/public/mod/subsection/version.php b/public/mod/subsection/version.php index e1592e53f6d..31062af637f 100644 --- a/public/mod/subsection/version.php +++ b/public/mod/subsection/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_subsection'; -$plugin->version = 2025100601; +$plugin->version = 2025100602; $plugin->requires = 2025092600; $plugin->maturity = MATURITY_STABLE;