Skip to content

Commit 8a3fd5f

Browse files
committed
Issue #1: Add ability to define custom content types
1 parent b052fd3 commit 8a3fd5f

20 files changed

+1347
-5
lines changed

.github/workflows/ci.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# .github/workflows/ci.yml
2+
name: ci
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
ci:
8+
uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main
9+
# secrets:
10+
# Required if you plan to publish (uncomment the below)
11+
# moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }}
12+
with:
13+
disable_behat: true
14+
disable_grunt: true

README.md

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
1-
# moodle-mod_cms
1+
<a href="https://github.com/catalyst/moodle-mod_cms/actions">
2+
<img src="https://github.com/catalyst/moodle-mod_cms/workflows/ci/badge.svg">
3+
</a>
24

3-
This is a placeholder for a planned module for managing custom defined content
4-
types which are 'first class' concepts in Moodle. This is to enable course
5-
author to think in proper concepts that matter to them and not worry about
6-
the rendering of each content type which will be defined centrally.
5+
# Custom activity content types for Moodle
6+
7+
An activity module for managing custom defined content types which are 'first class' concepts in Moodle. This is to enable course author to think in proper concepts that matter to them and not worry about the rendering of each content type which will be defined centrally.
8+
9+
## Installation
10+
11+
Step 1: Install the activity module
12+
-----------------------------------
13+
14+
Using git submodule:
15+
```
16+
git submodule add [email protected]:catalyst/moodle-mod_cms.git mod/cms
17+
```
18+
19+
OR you can download as a zip from github
20+
21+
https://github.com/catalyst/moodle-mod_cms/archive/refs/heads/main.zip
22+
23+
Extract this into /path/to/moodle/mod/cms
24+
25+
Then run the Moodle upgrade as normal.
26+
27+
https://docs.moodle.org/en/Installing_plugins
28+
29+
# Contributing and Support
30+
31+
Issues and pull requests using github are welcome and encouraged!
32+
33+
https:/github.com/catalyst/moodle-mod_cms/issues
34+
35+
If you would like commercial support or would like to sponsor additional improvements to this plugin please contact us:
36+
37+
https://www.catalyst-au.net/contact-us
38+
39+
# Crafted by Catalyst IT
40+
This plugin was developed by Catalyst IT Australia:
41+
42+
https://www.catalyst-au.net
43+
44+
<img alt="Catalyst IT" src="https://cdn.rawgit.com/CatalystIT-AU/moodle-auth_saml2/master/pix/catalyst-logo.svg" width="400">

classes/event/cms_type_created.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Event that gets triggered when a custom content type is created in the database
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
namespace mod_cms\event;
26+
27+
use stdClass;
28+
use core\event\base;
29+
30+
/**
31+
* Event that gets triggered when a custom content type is created in the database
32+
*
33+
* @package mod_cms
34+
* @author Marcus Boon<[email protected]>
35+
* @copyright Catalyst IT
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class cms_type_created extends base {
39+
40+
/**
41+
* Initialise the event data.
42+
*/
43+
protected function init() {
44+
$this->data['edulevel'] = self::LEVEL_OTHER;
45+
$this->data['crud'] = 'c';
46+
$this->data['objecttable'] = 'cms_types';
47+
}
48+
49+
/**
50+
* Return localised event name.
51+
*
52+
* @return string
53+
*/
54+
public static function get_name(): string {
55+
return get_string('event:cms_type_created', 'mod_cms');
56+
}
57+
58+
/**
59+
* Returns description of what happened.
60+
*
61+
* @return string
62+
*/
63+
public function get_description(): string {
64+
$a = new stdClass();
65+
$a->userid = $this->userid;
66+
$a->typeid = $this->objectid;
67+
68+
return get_string('event:cms_type_created_desc', 'mod_cms', $a);
69+
}
70+
}

classes/event/cms_type_deleted.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Event that gets triggered when a custom content type is deleted in the database
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
namespace mod_cms\event;
26+
27+
use stdClass;
28+
use core\event\base;
29+
30+
/**
31+
* Event that gets triggered when a custom content type is deleted in the database
32+
*
33+
* @package mod_cms
34+
* @author Marcus Boon<[email protected]>
35+
* @copyright Catalyst IT
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class cms_type_deleted extends base {
39+
40+
/**
41+
* Initialise the event data.
42+
*/
43+
protected function init() {
44+
$this->data['edulevel'] = self::LEVEL_OTHER;
45+
$this->data['crud'] = 'd';
46+
$this->data['objecttable'] = 'cms_types';
47+
}
48+
49+
/**
50+
* Return localised event name.
51+
*
52+
* @return string
53+
*/
54+
public static function get_name(): string {
55+
return get_string('event:cms_type_deleted', 'mod_cms');
56+
}
57+
58+
/**
59+
* Returns description of what happened.
60+
*
61+
* @return string
62+
*/
63+
public function get_description(): string {
64+
$a = new stdClass();
65+
$a->userid = $this->userid;
66+
$a->typeid = $this->objectid;
67+
68+
return get_string('event:cms_type_deleted_desc', 'mod_cms', $a);
69+
}
70+
}

classes/event/cms_type_updated.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* Event that gets triggered when a custom content type is updated in the database
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
namespace mod_cms\event;
26+
27+
use stdClass;
28+
use core\event\base;
29+
30+
/**
31+
* Event that gets triggered when a custom content type is updated in the database
32+
*
33+
* @package mod_cms
34+
* @author Marcus Boon<[email protected]>
35+
* @copyright Catalyst IT
36+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37+
*/
38+
class cms_type_updated extends base {
39+
40+
/**
41+
* Initialise the event data.
42+
*/
43+
protected function init() {
44+
$this->data['edulevel'] = self::LEVEL_OTHER;
45+
$this->data['crud'] = 'u';
46+
$this->data['objecttable'] = 'cms_types';
47+
}
48+
49+
/**
50+
* Return localised event name.
51+
*
52+
* @return string
53+
*/
54+
public static function get_name(): string {
55+
return get_string('event:cms_type_updated', 'mod_cms');
56+
}
57+
58+
/**
59+
* Returns description of what happened.
60+
*
61+
* @return string
62+
*/
63+
public function get_description(): string {
64+
$a = new stdClass();
65+
$a->userid = $this->userid;
66+
$a->typeid = $this->objectid;
67+
68+
return get_string('event:cms_type_updated_desc', 'mod_cms', $a);
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* The mod_cms instance list viewed event.
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
namespace mod_cms\event;
26+
27+
use core\event\course_module_instance_list_viewed as core_course_module_instance_list_viewed;
28+
29+
/**
30+
* The mod_cms instance list viewed event.
31+
*
32+
* @package mod_cms
33+
* @author Marcus Boon<[email protected]>
34+
* @copyright Catalyst IT
35+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36+
*/
37+
class course_module_instance_list_viewed extends core_course_module_instance_list_viewed {
38+
// Everything is handled by the parent class.
39+
}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
/**
18+
* The mod_cms course module viewed event.
19+
*
20+
* @package mod_cms
21+
* @author Marcus Boon<[email protected]>
22+
* @copyright Catalyst IT
23+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24+
*/
25+
namespace mod_cms\event;
26+
27+
use core\event\course_module_viewed as core_course_module_viewed;
28+
29+
/**
30+
* The mod_cms course module viewed event.
31+
*
32+
* @package mod_cms
33+
* @author Marcus Boon<[email protected]>
34+
* @copyright Catalyst IT
35+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36+
*/
37+
class course_module_viewed extends core_course_module_viewed {
38+
39+
/**
40+
* Init method.
41+
*/
42+
protected function init() {
43+
$this->data['objecttable'] = 'cms';
44+
$this->data['crud'] = 'r';
45+
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
46+
}
47+
48+
/**
49+
* Get objectid mapping.
50+
*/
51+
public static function get_objectid_mapping() {
52+
return [
53+
'db' => 'cms',
54+
'restore' => 'cms',
55+
];
56+
}
57+
}

0 commit comments

Comments
 (0)