diff --git a/db/install.xml b/db/install.xml index 5a686ff..68fd481 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,11 +1,13 @@ - + - +
+ + diff --git a/db/upgrade.php b/db/upgrade.php new file mode 100644 index 0000000..2217f52 --- /dev/null +++ b/db/upgrade.php @@ -0,0 +1,33 @@ +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; +} \ No newline at end of file diff --git a/lib.php b/lib.php index 036183a..5463d01 100644 --- a/lib.php +++ b/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); } diff --git a/mod_form.php b/mod_form.php index 49e7b85..edc10e6 100644 --- a/mod_form.php +++ b/mod_form.php @@ -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(); } -} \ No newline at end of file +} diff --git a/version.php b/version.php index 273d0e3..1acdb34 100644 --- a/version.php +++ b/version.php @@ -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) \ No newline at end of file