Skip to content

Commit 34e4c1c

Browse files
author
Vithusha Kethiri
committed
Update documentation
1 parent cfb35d5 commit 34e4c1c

File tree

8 files changed

+121
-40
lines changed

8 files changed

+121
-40
lines changed

classes/lifecycle/log_table.php

+21-20
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,21 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17+
/**
18+
* Course backup logs table.
19+
*
20+
* @package tool_lcbackupcourselogstep
21+
* @copyright 2024 Catalyst IT
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
1725
namespace tool_lcbackupcourselogstep\lifecycle;
1826

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

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

23-
class log_table extends \table_sql
24-
{
31+
class log_table extends \table_sql {
2532

2633
/**
2734
* @var array "cached" lang strings
@@ -32,14 +39,14 @@ class log_table extends \table_sql
3239
* Constructor for delayed_courses_table.
3340
*
3441
* @throws \coding_exception
42+
* @param array $filterdata Filter data.
3543
*/
36-
public function __construct($filterdata = [])
37-
{
44+
public function __construct($filterdata = []) {
3845
global $DB;
3946

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

42-
// Action buttons string
49+
// Action buttons string.
4350
$this->strings = [
4451
'download' => get_string('download')
4552
];
@@ -77,7 +84,6 @@ public function __construct($filterdata = [])
7784

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

80-
8187
// Columns.
8288
$this->define_columns([
8389
'courseid',
@@ -108,15 +114,12 @@ public function __construct($filterdata = [])
108114
}
109115

110116
/**
111-
* Define download action.
117+
* Download action column.
112118
*
113-
* @param $row
114-
* @return bool|string
115-
* @throws \coding_exception
116-
* @throws \moodle_exception
119+
* @param object $row
120+
* @return string
117121
*/
118-
public function col_actions($row)
119-
{
122+
public function col_actions($row) {
120123
global $OUTPUT;
121124

122125
$actionmenu = new \action_menu();
@@ -132,21 +135,19 @@ public function col_actions($row)
132135
}
133136

134137
/**
135-
* Time when the file is created, displayed in user-friendly format.
138+
* Display time when the file was created.
136139
*
137-
* @param $row
140+
* @param object $row
138141
* @return string
139-
* @throws \coding_exception
140142
*/
141-
public function col_createdat($row)
142-
{
143+
public function col_createdat($row) {
143144
return userdate($row->createdat);
144145
}
145146

146147
/**
147-
* Display size in a user-friendly format.
148+
* Display size in user friendly format.
148149
*
149-
* @param $row
150+
* @param object $row
150151
* @return string
151152
*/
152153
public function col_filesize($row) {

classes/lifecycle/step.php

+44-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17+
/**
18+
* Step for backing up a course logs in the lifecycle process.
19+
*
20+
* @package tool_lcbackupcourselogstep
21+
* @copyright 2024 Catalyst
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
1725
namespace tool_lcbackupcourselogstep\lifecycle;
1826

1927
global $CFG;
@@ -31,17 +39,34 @@
3139
defined('MOODLE_INTERNAL') || die();
3240

3341
class step extends libbase {
42+
/**
43+
* Returns the subplugin name.
44+
*
45+
* @return string
46+
*/
3447
public function get_subpluginname()
3548
{
3649
return 'tool_lcbackupcourselogstep';
3750
}
3851

52+
/**
53+
* Get the plugin description.
54+
*
55+
* @return string
56+
*/
3957
public function get_plugin_description() {
4058
return "Backup course log step plugin";
4159
}
4260

43-
public function process_course($processid, $instanceid, $course)
44-
{
61+
/**
62+
* Processes the course.
63+
*
64+
* @param int $processid the process id.
65+
* @param int $instanceid step instance id.
66+
* @param object $course the course object.
67+
* @return step_response
68+
*/
69+
public function process_course($processid, $instanceid, $course) {
4570
global $DB;
4671

4772
// Get all logs for the course with related courses and user details.
@@ -113,12 +138,23 @@ public function process_course($processid, $instanceid, $course)
113138
return step_response::proceed();
114139
}
115140

141+
/**
142+
* Adds the instance form definition.
143+
*
144+
* @param \moodleform $mform the form.
145+
*/
116146
public function instance_settings() {
117147
return [
118148
new instance_setting('fileformat', PARAM_TEXT, true),
119149
];
120150
}
121151

152+
/**
153+
* Extend the instance form to add file format options.
154+
*
155+
* @param \MoodleQuickForm $mform The form object.
156+
* @return void
157+
*/
122158
public function extend_add_instance_form_definition($mform) {
123159
$fileformatoptions = [
124160
'csv' => 'CSV',
@@ -139,17 +175,19 @@ public function extend_add_instance_form_definition($mform) {
139175
);
140176
$mform->setType('fileformat', PARAM_TEXT);
141177
$mform->setDefault('fileformat', 'csv');
142-
143178
}
144179

145-
public function get_plugin_settings()
146-
{
180+
/**
181+
* Returns the instance settings.
182+
*
183+
* @return void
184+
*/
185+
public function get_plugin_settings() {
147186
global $ADMIN;
148187
// Page to show the logs.
149188
$ADMIN->add('lifecycle_category', new admin_externalpage('tool_lcbackupcourselogstep_logs',
150189
get_string('courselogs', 'tool_lcbackupcourselogstep'),
151190
new moodle_url('/admin/tool/lcbackupcourselogstep/logs.php')));
152-
153191
}
154192

155193
}

classes/privacy/provider.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
use core_privacy\local\metadata\null_provider;
2020

2121
/**
22-
* Privacy subsystem implementation for tool_samplestep.
22+
* Privacy subsystem implementation for tool_lcbackupcourselogstep.
2323
*
24-
* @package tool_samplestep
24+
* @package tool_lcbackupcourselogstep
25+
* @copyright 2024 Catalyst IT
2526
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2627
*/
2728
class provider implements null_provider {

db/upgrade.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@
1818
* This file handles database upgrades for tool_lcbackupcourselogstep.
1919
*
2020
* @package tool_lcbackupcourselogstep
21-
* @copyright 2024 Catalyst
21+
* @copyright 2024 Catalyst IT
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424

25+
/**
26+
* Handles database upgrades for tool_lcbackupcourselogstep.
27+
*
28+
* @param int $oldversion The version of the plugin being upgraded from.
29+
* @return bool True on success, false on failure.
30+
*/
2531
function xmldb_tool_lcbackupcourselogstep_upgrade($oldversion) {
2632
global $DB;
2733

lang/en/tool_lcbackupcourselogstep.php

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17+
/**
18+
* String definitions for the tool_lcbackupcourselogstep plugin.
19+
*
20+
* @package tool_lcbackupcourselogstep
21+
* @copyright 2024 Catalyst IT
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
1725
$string['pluginname'] = 'Backup course log step';
1826
$string['privacy:metadata'] = 'The plugin does not store any personal data.';
1927
$string['fileformat'] = 'Log file format.';

logs.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

1717
/**
18-
* Displays backed up logs
18+
* Displays backed up logs.
1919
*
20-
* @package tool_lcbackupcourselogstep
20+
* @package tool_lcbackupcourselogstep
21+
* @copyright 2024 Catalyst IT
2122
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2223
*/
2324

tests/step_test.php

+31-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Trigger test for end date delay trigger.
1919
*
2020
* @package tool_lcbackupcourselogstep
21+
* @copyright 2024 Catalyst IT
2122
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2223
*/
2324
namespace tool_lcbackupcourselogstep\tests;
@@ -40,21 +41,42 @@
4041
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4142
*/
4243
class step_test extends \advanced_testcase {
43-
/** Icon of the manual trigger. */
44+
45+
/**
46+
* Icon of the manual trigger.
47+
* @var string
48+
*/
4449
const MANUAL_TRIGGER1_ICON = 't/up';
4550

46-
/** Display name of the manual trigger. */
51+
/**
52+
* Display name of the manual trigger.
53+
* @var string
54+
*/
4755
const MANUAL_TRIGGER1_DISPLAYNAME = 'Up';
4856

49-
/** Capability of the manual trigger. */
57+
/**
58+
* Capability of the manual trigger.
59+
* @var string
60+
*/
5061
const MANUAL_TRIGGER1_CAPABILITY = 'moodle/course:manageactivities';
5162

52-
/** @var trigger_subplugin $trigger Instances of the triggers under test. */
63+
/**
64+
* Instances of the triggers under test.
65+
* @var trigger_subplugin
66+
*/
5367
private $trigger;
5468

55-
/** @var \stdClass $course Instance of the course under test. */
69+
/**
70+
* Instance of the course under test.
71+
* @var \stdClass
72+
*/
5673
private $course;
5774

75+
/**
76+
* Set up the test case.
77+
*
78+
* @return void
79+
*/
5880
public function setUp() : void {
5981
global $USER, $DB;
6082

@@ -86,7 +108,9 @@ public function setUp() : void {
86108
}
87109

88110
/**
89-
* Test course is hidden.
111+
* Test that the notification step creates a log file.
112+
*
113+
* @return void
90114
*/
91115
public function test_notification_step() {
92116
global $DB;
@@ -127,3 +151,4 @@ public function test_notification_step() {
127151
}
128152

129153
}
154+

version.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

1717
/**
18-
* Backup course log
18+
* Version details.
1919
*
20-
* @package tool_lcbackupcourselogstep
21-
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
20+
* @package tool_lcbackupcourselogstep
21+
* @copyright 2024 Catalyst IT
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2223
*/
2324

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

0 commit comments

Comments
 (0)