Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="edflex" COMMENT="Main table for the edflex activity module instances.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="ID of the course this activity belongs to."/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="Name of the activity instance."/>
<FIELD NAME="intro" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description of the activity instance."/>
<FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Format of the intro field."/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Unix timestamp of the last modification."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="fk_course" TYPE="foreign" FIELDS="course" REFTABLE="course" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="edflex_scorm" COMMENT="Stores the extra data for edflex scorm activities.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
Expand Down
30 changes: 30 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 9 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Loading