diff --git a/db/install.xml b/db/install.xml index 4671f8c..42bde86 100755 --- a/db/install.xml +++ b/db/install.xml @@ -4,6 +4,20 @@ xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd" > + + + + + + + + + + + + + +
diff --git a/db/upgrade.php b/db/upgrade.php index 8eca7ea..c780461 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -30,5 +30,35 @@ * @return bool */ function xmldb_edflex_upgrade(int $oldversion): bool { + global $DB; + + $dbman = $DB->get_manager(); + + if ($oldversion < 2026062400) { + // Define table edflex to be created. + $table = new xmldb_table('edflex'); + + // Adding fields to table edflex. + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('course', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); + $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null); + $table->add_field('intro', XMLDB_TYPE_TEXT, null, null, null, null, null); + $table->add_field('introformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0'); + $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); + + // Adding keys to table edflex. + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + $table->add_key('fk_course', XMLDB_KEY_FOREIGN, ['course'], 'course', ['id']); + + // Conditionally launch create table for edflex. + // A client may have created the table manually as an emergency workaround. + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + // Edflex savepoint reached. + upgrade_mod_savepoint(true, 2026062400, 'edflex'); + } + return true; } diff --git a/lib.php b/lib.php index e156939..e75e225 100755 --- a/lib.php +++ b/lib.php @@ -71,7 +71,15 @@ function edflex_update_instance($moduleinstance, $mform = null) { * @return bool */ function edflex_delete_instance($id) { - return false; + global $DB; + + if (!$DB->get_record('edflex', ['id' => $id])) { + return false; + } + + $DB->delete_records('edflex', ['id' => $id]); + + return true; } diff --git a/version.php b/version.php index b6ab0d4..a646671 100755 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_edflex'; -$plugin->release = 'v1.0.0'; -$plugin->version = 2025120118; +$plugin->release = 'v1.0.1'; +$plugin->version = 2026062400; $plugin->requires = 2022041900; $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = [