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
11 changes: 1 addition & 10 deletions lbplanner/classes/helpers/kanban_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,7 @@ public static function set_entry(kanbanentry $entry): void {
throw $e;
}
if ($entry->column !== KANBANCOL_TYPE_NUMERIC::BACKLOG) {
$table = $CFG->prefix . self::TABLE;
try {
// Moodle is too stupid to compensate for 'column' being a keyword so I need to shit my own ass manually.
$newid = $DB->execute("INSERT INTO {$table} VALUES (null,?,?,?)", [$entry->userid, $entry->cmid, $entry->column]);
} catch (\dml_exception $e) {
// Needed for low-reporting contexts such as a prod server.
echo 'error while trying to insert new kanban entry: '.$e->getMessage()."\nFurther info:\n".$e->debuginfo;
var_dump($entry);
throw $e;
}
$newid = $DB->insert_record(self::TABLE, $entry->prepare_for_db(), true);
$entry->set_fresh($newid);
}
}
Expand Down
19 changes: 19 additions & 0 deletions lbplanner/classes/model/kanbanentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ public function set_fresh(int $id) {
$this->id = $id;
}

/**
* Prepares data for the DB endpoint.
* doesn't set ID if it's 0
*
* @return object a representation of this kanban entry and its data
*/
public function prepare_for_db(): object {
$obj = new \stdClass();

$obj->selectedcolumn = $this->column;
$obj->cmid = $this->cmid;
$obj->userid = $this->userid;

if ($this->id !== 0) {
$obj->id = $this->id;
}
return $obj;
}

/**
* Prepares data for the API endpoint.
*
Expand Down
2 changes: 1 addition & 1 deletion lbplanner/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="the course module ID"/>
<FIELD NAME="column" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="selectedcolumn" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Expand Down
7 changes: 7 additions & 0 deletions lbplanner/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,12 @@ function xmldb_local_lbplanner_upgrade($oldversion): bool {

upgrade_plugin_savepoint(true, 202509060001, 'local', 'lbplanner');
}
if ($oldversion < 202510090000) {
$table = new xmldb_table('local_lbplanner_kanbanentries');
$field = new xmldb_field('column', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, 'cmid');
$dbman->rename_field($table, $field, 'selectedcolumn');

upgrade_plugin_savepoint(true, 202510090000, 'local', 'lbplanner');
}
return true;
}
2 changes: 1 addition & 1 deletion lbplanner/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$plugin->maturity = MATURITY_BETA;
$plugin->component = 'local_lbplanner';
$plugin->release = '1.1.8';
$plugin->version = 202510040000;
$plugin->version = 202510090000;
$plugin->dependencies = [
// Depend upon version 2023110600 of local_modcustomfields.
'local_modcustomfields' => 2023110600,
Expand Down
Loading