From 87e610d3137b0b69d680f024e7e52a3f49783014 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 5 Jul 2024 11:30:55 +0200 Subject: [PATCH] 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. --- db/access.php | 27 +++++++++++++++++++++++++++ index.php | 33 +++++++++++++++++++++++++++++++++ lib.php | 36 ++++++++++++++++++++++++++++++++++++ version.php | 2 +- 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 db/access.php create mode 100644 index.php create mode 100644 lib.php diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..8d628c5 --- /dev/null +++ b/db/access.php @@ -0,0 +1,27 @@ + 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 + ) + ), +); diff --git a/index.php b/index.php new file mode 100644 index 0000000..36835df --- /dev/null +++ b/index.php @@ -0,0 +1,33 @@ +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(); diff --git a/lib.php b/lib.php new file mode 100644 index 0000000..036183a --- /dev/null +++ b/lib.php @@ -0,0 +1,36 @@ +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; +} diff --git a/version.php b/version.php index 5266642..a963dec 100644 --- a/version.php +++ b/version.php @@ -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) \ No newline at end of file