feat: add basic structure for exp360 module
Introduced the foundational elements for the exp360 module, including: - Added access control capabilities - Implemented index page for course instances - Created add, update, and delete functions for instances - Updated plugin version These changes establish the module's core functionality and prepare it for further development and integration.
This commit is contained in:
parent
3e5b36bc14
commit
87e610d313
4 changed files with 97 additions and 1 deletions
27
db/access.php
Normal file
27
db/access.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
'mod/exp360:addinstance' => array(
|
||||
'riskbitmask' => RISK_XSS,
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
),
|
||||
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||
),
|
||||
'mod/exp360:view' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => array(
|
||||
'guest' => CAP_ALLOW,
|
||||
'student' => CAP_ALLOW,
|
||||
'teacher' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
);
|
33
index.php
Normal file
33
index.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once(dirname(__FILE__) . '/lib.php');
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT);
|
||||
|
||||
if ($id) {
|
||||
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
|
||||
} else {
|
||||
print_error('You must specify a course ID');
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
$PAGE->set_url('/mod/exp360/index.php', array('id' => $id));
|
||||
$PAGE->set_title($course->shortname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_context(context_course::instance($course->id));
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('modulenameplural', 'exp360'));
|
||||
|
||||
if (!$exp360s = get_all_instances_in_course('exp360', $course)) {
|
||||
notice(get_string('noexp360s', 'exp360'), new moodle_url('/course/view.php', array('id' => $course->id)));
|
||||
}
|
||||
|
||||
foreach ($exp360s as $exp360) {
|
||||
$url = new moodle_url('/mod/exp360/view.php', array('id' => $exp360->coursemodule));
|
||||
echo html_writer::link($url, format_string($exp360->name));
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
36
lib.php
Normal file
36
lib.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function exp360_add_instance($exp360)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$exp360->timemodified = time();
|
||||
$exp360->timecreated = time();
|
||||
|
||||
return $DB->insert_record('exp360', $exp360);
|
||||
}
|
||||
|
||||
function exp360_update_instance($exp360)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$exp360->timemodified = time();
|
||||
$exp360->id = $exp360->instance;
|
||||
|
||||
return $DB->update_record('exp360', $exp360);
|
||||
}
|
||||
|
||||
function exp360_delete_instance($id)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
if (!$exp360 = $DB->get_record('exp360', array('id' => $id))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$DB->delete_records('exp360', array('id' => $exp360->id));
|
||||
|
||||
return true;
|
||||
}
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2024070500; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2024070501; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2021051700; // Requires this Moodle version
|
||||
$plugin->component = 'mod_exp360'; // Full name of the plugin (used for diagnostics)
|
Loading…
Reference in a new issue