Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vithusha Kethiri committed Oct 22, 2024
1 parent cfb35d5 commit 3abaf1b
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 40 deletions.
48 changes: 28 additions & 20 deletions classes/lifecycle/log_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Course backup logs table.
*
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace tool_lcbackupcourselogstep\lifecycle;

defined('MOODLE_INTERNAL') || die;

require_once($CFG->libdir . '/tablelib.php');

class log_table extends \table_sql
{
/**
* Backup log table.
*
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class log_table extends \table_sql {

/**
* @var array "cached" lang strings
Expand All @@ -32,14 +46,14 @@ class log_table extends \table_sql
* Constructor for delayed_courses_table.
*
* @throws \coding_exception
* @param array $filterdata Filter data.
*/
public function __construct($filterdata = [])
{
public function __construct($filterdata = []) {
global $DB;

parent::__construct('tool_lcbackupcourselogstep-log');

// Action buttons string
// Action buttons string.
$this->strings = [
'download' => get_string('download')
];
Expand Down Expand Up @@ -77,7 +91,6 @@ public function __construct($filterdata = [])

$this->set_sql($fields, $from, $where, $params);


// Columns.
$this->define_columns([
'courseid',
Expand Down Expand Up @@ -108,15 +121,12 @@ public function __construct($filterdata = [])
}

/**
* Define download action.
* Download action column.
*
* @param $row
* @return bool|string
* @throws \coding_exception
* @throws \moodle_exception
* @param object $row
* @return string
*/
public function col_actions($row)
{
public function col_actions($row) {
global $OUTPUT;

$actionmenu = new \action_menu();
Expand All @@ -132,21 +142,19 @@ public function col_actions($row)
}

/**
* Time when the file is created, displayed in user-friendly format.
* Display time when the file was created.
*
* @param $row
* @param object $row
* @return string
* @throws \coding_exception
*/
public function col_createdat($row)
{
public function col_createdat($row) {
return userdate($row->createdat);
}

/**
* Display size in a user-friendly format.
* Display size in user friendly format.
*
* @param $row
* @param object $row
* @return string
*/
public function col_filesize($row) {
Expand Down
56 changes: 50 additions & 6 deletions classes/lifecycle/step.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Step for backing up a course logs in the lifecycle process.
*
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace tool_lcbackupcourselogstep\lifecycle;

global $CFG;
Expand All @@ -30,18 +38,41 @@

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

/**
* Step class for the Backup Course Log Step plugin.
*
* @package tool_lcbackupcourselogstep
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class step extends libbase {
/**
* Returns the subplugin name.
*
* @return string
*/
public function get_subpluginname()
{
return 'tool_lcbackupcourselogstep';
}

/**
* Get the plugin description.
*
* @return string
*/
public function get_plugin_description() {
return "Backup course log step plugin";
}

public function process_course($processid, $instanceid, $course)
{
/**
* Processes the course.
*
* @param int $processid the process id.
* @param int $instanceid step instance id.
* @param object $course the course object.
* @return step_response
*/
public function process_course($processid, $instanceid, $course) {
global $DB;

// Get all logs for the course with related courses and user details.
Expand Down Expand Up @@ -113,12 +144,23 @@ public function process_course($processid, $instanceid, $course)
return step_response::proceed();
}

/**
* Returns instance settings for the plugin.
*
* @return array The instance settings for this step.
*/
public function instance_settings() {
return [
new instance_setting('fileformat', PARAM_TEXT, true),
];
}

/**
* Extend the instance form to add file format options.
*
* @param \MoodleQuickForm $mform The form object.
* @return void
*/
public function extend_add_instance_form_definition($mform) {
$fileformatoptions = [
'csv' => 'CSV',
Expand All @@ -139,17 +181,19 @@ public function extend_add_instance_form_definition($mform) {
);
$mform->setType('fileformat', PARAM_TEXT);
$mform->setDefault('fileformat', 'csv');

}

public function get_plugin_settings()
{
/**
* Returns the instance settings.
*
* @return void
*/
public function get_plugin_settings() {
global $ADMIN;
// Page to show the logs.
$ADMIN->add('lifecycle_category', new admin_externalpage('tool_lcbackupcourselogstep_logs',
get_string('courselogs', 'tool_lcbackupcourselogstep'),
new moodle_url('/admin/tool/lcbackupcourselogstep/logs.php')));

}

}
5 changes: 3 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
use core_privacy\local\metadata\null_provider;

/**
* Privacy subsystem implementation for tool_samplestep.
* Privacy subsystem implementation for tool_lcbackupcourselogstep.
*
* @package tool_samplestep
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements null_provider {
Expand Down
8 changes: 7 additions & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
* This file handles database upgrades for tool_lcbackupcourselogstep.
*
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Handles database upgrades for tool_lcbackupcourselogstep.
*
* @param int $oldversion The version of the plugin being upgraded from.
* @return bool True on success, false on failure.
*/
function xmldb_tool_lcbackupcourselogstep_upgrade($oldversion) {
global $DB;

Expand Down
8 changes: 8 additions & 0 deletions lang/en/tool_lcbackupcourselogstep.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* String definitions for the tool_lcbackupcourselogstep plugin.
*
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Backup course log step';
$string['privacy:metadata'] = 'The plugin does not store any personal data.';
$string['fileformat'] = 'Log file format.';
Expand Down
5 changes: 3 additions & 2 deletions logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Displays backed up logs
* Displays backed up logs.
*
* @package tool_lcbackupcourselogstep
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
37 changes: 31 additions & 6 deletions tests/step_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Trigger test for end date delay trigger.
*
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lcbackupcourselogstep\tests;
Expand All @@ -40,21 +41,42 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class step_test extends \advanced_testcase {
/** Icon of the manual trigger. */

/**
* Icon of the manual trigger.
* @var string
*/
const MANUAL_TRIGGER1_ICON = 't/up';

/** Display name of the manual trigger. */
/**
* Display name of the manual trigger.
* @var string
*/
const MANUAL_TRIGGER1_DISPLAYNAME = 'Up';

/** Capability of the manual trigger. */
/**
* Capability of the manual trigger.
* @var string
*/
const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities';

/** @var trigger_subplugin $trigger Instances of the triggers under test. */
/**
* Instances of the triggers under test.
* @var trigger_subplugin
*/
private $trigger;

/** @var \stdClass $course Instance of the course under test. */
/**
* Instance of the course under test.
* @var \stdClass
*/
private $course;

/**
* Set up the test case.
*
* @return void
*/
public function setUp() : void {
global $USER, $DB;

Expand Down Expand Up @@ -86,7 +108,9 @@ public function setUp() : void {
}

/**
* Test course is hidden.
* Test that the notification step creates a log file.
*
* @return void
*/
public function test_notification_step() {
global $DB;
Expand Down Expand Up @@ -127,3 +151,4 @@ public function test_notification_step() {
}

}

7 changes: 4 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Backup course log
* Version details.
*
* @package tool_lcbackupcourselogstep
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package tool_lcbackupcourselogstep
* @copyright 2024 Catalyst IT
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

0 comments on commit 3abaf1b

Please sign in to comment.