Skip to content

Commit 18eea0b

Browse files
committed
Merge branch 'main' into EDUPL-26-sentry-api
2 parents 9fb9987 + abdbf0e commit 18eea0b

5 files changed

Lines changed: 29 additions & 12 deletions

File tree

lbplanner/classes/helpers/kanban_helper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,7 @@ public static function set_entry(kanbanentry $entry): void {
8181
throw $e;
8282
}
8383
if ($entry->column !== KANBANCOL_TYPE_NUMERIC::BACKLOG) {
84-
$table = $CFG->prefix . self::TABLE;
85-
try {
86-
// Moodle is too stupid to compensate for 'column' being a keyword so I need to shit my own ass manually.
87-
$newid = $DB->execute("INSERT INTO {$table} VALUES (null,?,?,?)", [$entry->userid, $entry->cmid, $entry->column]);
88-
} catch (\dml_exception $e) {
89-
// Needed for low-reporting contexts such as a prod server.
90-
echo 'error while trying to insert new kanban entry: '.$e->getMessage()."\nFurther info:\n".$e->debuginfo;
91-
var_dump($entry);
92-
throw $e;
93-
}
84+
$newid = $DB->insert_record(self::TABLE, $entry->prepare_for_db(), true);
9485
$entry->set_fresh($newid);
9586
}
9687
}

lbplanner/classes/model/kanbanentry.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,25 @@ public function set_fresh(int $id) {
8383
$this->id = $id;
8484
}
8585

86+
/**
87+
* Prepares data for the DB endpoint.
88+
* doesn't set ID if it's 0
89+
*
90+
* @return object a representation of this kanban entry and its data
91+
*/
92+
public function prepare_for_db(): object {
93+
$obj = new \stdClass();
94+
95+
$obj->selectedcolumn = $this->column;
96+
$obj->cmid = $this->cmid;
97+
$obj->userid = $this->userid;
98+
99+
if ($this->id !== 0) {
100+
$obj->id = $this->id;
101+
}
102+
return $obj;
103+
}
104+
86105
/**
87106
* Prepares data for the API endpoint.
88107
*

lbplanner/db/install.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
156156
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
157157
<FIELD NAME="cmid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="the course module ID"/>
158-
<FIELD NAME="column" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false"/>
158+
<FIELD NAME="selectedcolumn" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false"/>
159159
</FIELDS>
160160
<KEYS>
161161
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>

lbplanner/db/upgrade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,12 @@ function xmldb_local_lbplanner_upgrade($oldversion): bool {
9898

9999
upgrade_plugin_savepoint(true, 202509060001, 'local', 'lbplanner');
100100
}
101+
if ($oldversion < 202510090000) {
102+
$table = new xmldb_table('local_lbplanner_kanbanentries');
103+
$field = new xmldb_field('column', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, 'cmid');
104+
$dbman->rename_field($table, $field, 'selectedcolumn');
105+
106+
upgrade_plugin_savepoint(true, 202510090000, 'local', 'lbplanner');
107+
}
101108
return true;
102109
}

lbplanner/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
$plugin->maturity = MATURITY_BETA;
2929
$plugin->component = 'local_lbplanner';
3030
$plugin->release = '1.1.8';
31-
$plugin->version = 202510040000;
31+
$plugin->version = 202510090000;
3232
$plugin->dependencies = [
3333
// Depend upon version 2023110600 of local_modcustomfields.
3434
'local_modcustomfields' => 2023110600,

0 commit comments

Comments
 (0)