Skip to content

Commit 7755983

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

File tree

8 files changed

+134
-40
lines changed

8 files changed

+134
-40
lines changed

classes/lifecycle/log_table.php

+28-20
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,28 @@
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+
/**
32+
* Backup log table.
33+
*
34+
* @package tool_lcbackupcourselogstep
35+
* @copyright 2024 Catalyst IT
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class log_table extends \table_sql {
2539

2640
/**
2741
* @var array "cached" lang strings
@@ -32,14 +46,14 @@ class log_table extends \table_sql
3246
* Constructor for delayed_courses_table.
3347
*
3448
* @throws \coding_exception
49+
* @param array $filterdata Filter data.
3550
*/
36-
public function __construct($filterdata = [])
37-
{
51+
public function __construct($filterdata = []) {
3852
global $DB;
3953

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

42-
// Action buttons string
56+
// Action buttons string.
4357
$this->strings = [
4458
'download' => get_string('download')
4559
];
@@ -77,7 +91,6 @@ public function __construct($filterdata = [])
7791

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

80-
8194
// Columns.
8295
$this->define_columns([
8396
'courseid',
@@ -108,15 +121,12 @@ public function __construct($filterdata = [])
108121
}
109122

110123
/**
111-
* Define download action.
124+
* Download action column.
112125
*
113-
* @param $row
114-
* @return bool|string
115-
* @throws \coding_exception
116-
* @throws \moodle_exception
126+
* @param object $row
127+
* @return string
117128
*/
118-
public function col_actions($row)
119-
{
129+
public function col_actions($row) {
120130
global $OUTPUT;
121131

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

134144
/**
135-
* Time when the file is created, displayed in user-friendly format.
145+
* Display time when the file was created.
136146
*
137-
* @param $row
147+
* @param object $row
138148
* @return string
139-
* @throws \coding_exception
140149
*/
141-
public function col_createdat($row)
142-
{
150+
public function col_createdat($row) {
143151
return userdate($row->createdat);
144152
}
145153

146154
/**
147-
* Display size in a user-friendly format.
155+
* Display size in user friendly format.
148156
*
149-
* @param $row
157+
* @param object $row
150158
* @return string
151159
*/
152160
public function col_filesize($row) {

classes/lifecycle/step.php

+50-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;
@@ -30,18 +38,41 @@
3038

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

41+
/**
42+
* Step class for the Backup Course Log Step plugin.
43+
*
44+
* @package tool_lcbackupcourselogstep
45+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
46+
*/
3347
class step extends libbase {
48+
/**
49+
* Returns the subplugin name.
50+
*
51+
* @return string
52+
*/
3453
public function get_subpluginname()
3554
{
3655
return 'tool_lcbackupcourselogstep';
3756
}
3857

58+
/**
59+
* Get the plugin description.
60+
*
61+
* @return string
62+
*/
3963
public function get_plugin_description() {
4064
return "Backup course log step plugin";
4165
}
4266

43-
public function process_course($processid, $instanceid, $course)
44-
{
67+
/**
68+
* Processes the course.
69+
*
70+
* @param int $processid the process id.
71+
* @param int $instanceid step instance id.
72+
* @param object $course the course object.
73+
* @return step_response
74+
*/
75+
public function process_course($processid, $instanceid, $course) {
4576
global $DB;
4677

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

147+
/**
148+
* Adds the instance form definition.
149+
*
150+
* @param \moodleform $mform the form.
151+
*/
116152
public function instance_settings() {
117153
return [
118154
new instance_setting('fileformat', PARAM_TEXT, true),
119155
];
120156
}
121157

158+
/**
159+
* Extend the instance form to add file format options.
160+
*
161+
* @param \MoodleQuickForm $mform The form object.
162+
* @return void
163+
*/
122164
public function extend_add_instance_form_definition($mform) {
123165
$fileformatoptions = [
124166
'csv' => 'CSV',
@@ -139,17 +181,19 @@ public function extend_add_instance_form_definition($mform) {
139181
);
140182
$mform->setType('fileformat', PARAM_TEXT);
141183
$mform->setDefault('fileformat', 'csv');
142-
143184
}
144185

145-
public function get_plugin_settings()
146-
{
186+
/**
187+
* Returns the instance settings.
188+
*
189+
* @return void
190+
*/
191+
public function get_plugin_settings() {
147192
global $ADMIN;
148193
// Page to show the logs.
149194
$ADMIN->add('lifecycle_category', new admin_externalpage('tool_lcbackupcourselogstep_logs',
150195
get_string('courselogs', 'tool_lcbackupcourselogstep'),
151196
new moodle_url('/admin/tool/lcbackupcourselogstep/logs.php')));
152-
153197
}
154198

155199
}

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)