Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ff7b228
clc plugin
ccaewan Oct 30, 2025
a67a721
Merge branch 'learnweb:main' into 45-extend
ccaewan Dec 4, 2025
150c9de
Add coursefreeze trigger subplugin with last access + creation thresh…
Dec 4, 2025
1b72e40
Refine course freeze trigger language strings
ccaewan Dec 4, 2025
fc733cd
Update lib.php
ccaewan Dec 4, 2025
498fb37
Remove coursefreeze trigger from lifecycle plugin for 45-extend preview
Dec 4, 2025
2713941
Remove unused German language file
Dec 5, 2025
87d86f2
Add course archive and deletion triggers (coursefreeze & coursedelete)
Dec 5, 2025
6d6a7d6
Add UCL context freeze lifecycle step
Dec 17, 2025
b3b6fad
Adjusted wording in version.php
Dec 17, 2025
f98dd67
Updated deletion logic to include status, age and inactivity
Dec 18, 2025
421711a
update course del logic
Dec 18, 2025
d673e5f
Clean up comments in lib.php
ccaewan Dec 19, 2025
aa77f9a
Fix PHP opening tag in lib.php
ccaewan Dec 19, 2025
3de9c5c
Refactor logic to no longer scan all users
ccaewan Dec 22, 2025
4d96851
Increment plugin version to 2025121802
ccaewan Dec 22, 2025
85ce38a
Create uclcontextdelete
ccaewan Jan 28, 2026
dc6607c
context delete code added
ccaewan Jan 28, 2026
f1c96ba
Change class to extend libbase
ccaewan Jan 29, 2026
642c56a
remove unextepcted error
ccaewan Jan 29, 2026
1faca47
double quote string to remove error
ccaewan Feb 2, 2026
ab5c7c7
refactor deletion selection
ccaewan Feb 2, 2026
bb7d7af
refactor to ensure correct workflow without dependency crash or dupli…
ccaewan Feb 3, 2026
ac3b2fc
fix typo to clear non-install message
ccaewan Feb 3, 2026
521bd04
refactor cat reference code in deletion
ccaewan Feb 5, 2026
3328054
Fix typo and refactor
ccaewan Feb 5, 2026
d45e63d
Change to only trigger non-archived courses
ccaewan Mar 4, 2026
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
332 changes: 0 additions & 332 deletions lang/de/tool_lifecycle.php

This file was deleted.

28 changes: 28 additions & 0 deletions step/uclcontextdelete/lang/en/lifecyclestep_uclcontextdelete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Lang strings for delete course step
*
* @package lifecyclestep_uclcontextdelete
* @copyright 2025 UCL
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['stepname'] = 'Course deletion step';
$string['plugindescription'] = "Delegates deletion by calling the Catalyst batch deletion tool to delete courses that have already been archived by UCL's contextfreeze trigger";
$string['pluginname'] = 'UCL contextdelete (Deletion of archived courses)';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';
52 changes: 52 additions & 0 deletions step/uclcontextdelete/lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace tool_lifecycle\step;

use tool_lifecycle\local\response\step_response;
use core\task\manager;

defined('MOODLE_INTERNAL') || die();

require_once(__DIR__ . '/../lib.php');

class uclcontextdelete extends libbase {

/**
* Ensure task only queued once per workflow execution.
*
* @var bool
*/
protected static $taskqueued = false;

public function process_course($processid, $instanceid, $course) {

// Only queue once per workflow run
if (!self::$taskqueued) {

if (class_exists('\tool_catmaintenance\task\batch_course_deletion')) {

$task = new \tool_catmaintenance\task\batch_course_deletion();
manager::queue_adhoc_task($task);

self::$taskqueued = true;

debugging(
'Lifecycle queued Catalyst batch_course_deletion task.',
DEBUG_DEVELOPER
);

} else {

debugging(
'Catalyst batch_course_deletion task not available — skipping queue.',
DEBUG_DEVELOPER
);
}
}

return step_response::proceed();
}

public function get_subpluginname() {
return 'uclcontextdelete';
}
}
8 changes: 8 additions & 0 deletions step/uclcontextdelete/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'lifecyclestep_uclcontextdelete';
$plugin->version = 2025102300;
$plugin->requires = 2022112800; // Requires Moodle 4.1+.
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '0.1';
29 changes: 29 additions & 0 deletions step/uclcontextfreeze/lang/en/lifecyclestep_uclcontextfreeze.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Lang strings for delete course step
*
* @package lifecyclestep_uclcontextfreeze
* @copyright 2025 UCL
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['stepname'] = 'Archive/Freeze course step';
$string['plugindescription'] = 'Calls UCLs contextfreeze (block) to archive courses';
$string['pluginname'] = 'UCL contextfreeze';
$string['privacy:metadata'] = 'This subplugin does not store any personal data.';

83 changes: 83 additions & 0 deletions step/uclcontextfreeze/lib.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Step subplugin to freeze a course context using UCL block_lifecycle manager.
*
* @package lifecyclestep_uclcontextfreeze
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace tool_lifecycle\step;

use stdClass;
use tool_lifecycle\local\response\step_response;

defined('MOODLE_INTERNAL') || die();

require_once(__DIR__ . '/../lib.php');

/**
* Step subplugin to freeze a course context using UCL block_lifecycle.
*
* @package lifecyclestep_uclcontextfreeze
*/
class uclcontextfreeze extends libbase {

/**
* Processes the course and returns a response.
*
* @param int $processid of the respective process.
* @param int $instanceid of the step instance.
* @param stdClass $course to be processed.
* @return step_response
*/
public function process_course($processid, $instanceid, $course) {

if (!class_exists('\block_lifecycle\manager')) {
return step_response::rollback();
}

try {
\block_lifecycle\manager::freeze_course((int)$course->id);
} catch (\Exception $e) {
return step_response::rollback();
}

return step_response::proceed();
}

/**
* Processes the course in status waiting and returns a response.
*
* @param int $processid
* @param int $instanceid
* @param stdClass $course
* @return step_response
*/
public function process_waiting_course($processid, $instanceid, $course) {
return $this->process_course($processid, $instanceid, $course);
}

/**
* The return value should be equivalent with the name of the subplugin folder.
*
* @return string
*/
public function get_subpluginname() {
return 'uclcontextfreeze';
}
}
14 changes: 14 additions & 0 deletions step/uclcontextfreeze/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'lifecyclestep_uclcontextfreeze';
$plugin->version = 2025102300;
$plugin->requires = 2022112800; // Requires Moodle 4.1+.
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '0.1';

// Requires UCL's lifecycle bloxk (so the manager class exists)
$plugin->dependencies = [
'block_lifecycle' => ANY_VERSION,
];

39 changes: 39 additions & 0 deletions trigger/coursedelete/classes/privacy/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace lifecycletrigger_coursedelete\privacy;

use core_privacy\local\metadata\null_provider;

/**
* Privacy subsystem implementation for lifecycletrigger_coursefreeze.
*
* @package lifecycletrigger_coursefreeze
* @copyright 2025 Gifty Wanzola (ccaewan)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {

/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
45 changes: 45 additions & 0 deletions trigger/coursedelete/lang/en/lifecycletrigger_coursedelete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Lang strings for course freeze trigger
*
* @package lifecycletrigger_coursedelete
* @copyright 2025 Gifty (ccaewan)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Select long-term archived courses for deletion';
// Description shown on the workflow configuration page.

$string['plugindescription'] =
'Selects courses that have been archived (frozen), have not been accessed for a prolonged period, '
. 'and were created sufficiently long ago. These courses are considered end-of-life and may be '
. 'safely removed using a delete step in the workflow.';

$string['inactivitydelay'] = 'Last access threshold';
$string['inactivitydelay_help'] =
'Only delete courses where the most recent user activity is older than this period. '
. 'Set to 48 months by default to target courses with no access for at least 4 years.';

$string['creationdelay'] = 'Minimum course age';

$string['creationdelay_help'] =
'The minimum age of a course based on its creation date. '
. 'Courses created more recently than this threshold will not be selected for deletion.'
. 'Set to 60 months by default to target courses with older than at least 5 years.';

$string['privacy:metadata'] = 'The Course deletion trigger does not store or process personal data.';
Loading