feat: add intro fields to exp360 module
Added 'intro' and 'introformat' fields to the exp360 module for enhanced activity descriptions. Updated database schema and upgrade script to accommodate new fields. Modified add and update instance functions and the form to manage intro fields. Bumped module version to 2024070503.
This commit is contained in:
parent
688e44ef2b
commit
3247092e59
5 changed files with 52 additions and 6 deletions
|
@ -1,11 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/exp360/db" VERSION="2024070500" COMMENT="exp360 module">
|
||||
<XMLDB PATH="mod/exp360/db" VERSION="2024070503" COMMENT="exp360 module description">
|
||||
<TABLES>
|
||||
<TABLE NAME="exp360" COMMENT="Table containing data on exp360 activities">
|
||||
<TABLE NAME="exp360" COMMENT="Table for storing exp360 activity instances">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" COMMENT="Primary key"/>
|
||||
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" COMMENT="Course ID"/>
|
||||
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" COMMENT="Activity name"/>
|
||||
<FIELD NAME="intro" TYPE="text" NOTNULL="false" COMMENT="Introduction text"/>
|
||||
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" COMMENT="Format of the intro field (e.g., HTML)"/>
|
||||
<FIELD NAME="content_id" TYPE="char" LENGTH="255" NOTNULL="true" COMMENT="Content ID"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" COMMENT="Last modified time"/>
|
||||
</FIELDS>
|
||||
|
|
33
db/upgrade.php
Normal file
33
db/upgrade.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
function xmldb_exp360_upgrade($oldversion) {
|
||||
global $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
if ($oldversion < 2024070503) {
|
||||
// Define field intro to be added to exp360.
|
||||
$table = new xmldb_table('exp360');
|
||||
$field = new xmldb_field('intro', XMLDB_TYPE_TEXT, null, null, null, null, null, 'name');
|
||||
|
||||
// Conditionally launch add field intro.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Define field introformat to be added to exp360.
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
// Conditionally launch add field introformat.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Exp360 savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2024070503, 'exp360');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
8
lib.php
8
lib.php
|
@ -9,6 +9,10 @@ function exp360_add_instance($exp360)
|
|||
$exp360->timemodified = time();
|
||||
$exp360->timecreated = time();
|
||||
|
||||
// Process standard intro fields.
|
||||
$exp360->introformat = FORMAT_HTML;
|
||||
$exp360->intro = '';
|
||||
|
||||
return $DB->insert_record('exp360', $exp360);
|
||||
}
|
||||
|
||||
|
@ -19,6 +23,10 @@ function exp360_update_instance($exp360)
|
|||
$exp360->timemodified = time();
|
||||
$exp360->id = $exp360->instance;
|
||||
|
||||
// Process standard intro fields.
|
||||
$exp360->introformat = FORMAT_HTML;
|
||||
$exp360->intro = '';
|
||||
|
||||
return $DB->update_record('exp360', $exp360);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
require_once("$CFG->dirroot/course/moodleform_mod.php");
|
||||
|
||||
class mod_exp360_mod_form extends moodleform_mod {
|
||||
public function definition() {
|
||||
class mod_exp360_mod_form extends moodleform_mod
|
||||
{
|
||||
public function definition()
|
||||
{
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
|
@ -13,6 +15,7 @@ class mod_exp360_mod_form extends moodleform_mod {
|
|||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
$mform->addRule('name', null, 'maxlength', 255, 'client');
|
||||
|
||||
// Add the standard intro elements.
|
||||
$this->standard_intro_elements();
|
||||
|
||||
$mform->addElement('text', 'content_id', get_string('contentid', 'exp360'), array('size' => '64'));
|
||||
|
@ -23,4 +26,4 @@ class mod_exp360_mod_form extends moodleform_mod {
|
|||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2024070502; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2024070503; // 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