Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-32714 workshop: fixed SQL to load assessment form fields

Obvious problems emerged once there were some records in the
workshopform_rubric table with no workshopform_rubric_levels. As l.id
(empty in that case) was used as the key of the returned array, they all
were collapsed into a single one.
  • Loading branch information...
commit 6e7e184571906544f3865d3e8c2145a6d763af0d 1 parent efac2d2
@mudrd8mz mudrd8mz authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 mod/workshop/form/rubric/lib.php
View
11 mod/workshop/form/rubric/lib.php
@@ -418,16 +418,17 @@ public static function delete_instance($workshopid) {
protected function load_fields() {
global $DB;
- $sql = 'SELECT l.id AS lid, r.id AS rid, r.*, l.*
+ $sql = "SELECT r.id AS rid, r.sort, r.description, r.descriptionformat,
+ l.id AS lid, l.grade, l.definition, l.definitionformat
FROM {workshopform_rubric} r
LEFT JOIN {workshopform_rubric_levels} l ON (l.dimensionid = r.id)
WHERE r.workshopid = :workshopid
- ORDER BY r.sort, l.grade';
+ ORDER BY r.sort, l.grade";
$params = array('workshopid' => $this->workshop->id);
- $records = $DB->get_records_sql($sql, $params);
+ $rs = $DB->get_recordset_sql($sql, $params);
$fields = array();
- foreach ($records as $record) {
+ foreach ($rs as $record) {
if (!isset($fields[$record->rid])) {
$fields[$record->rid] = new stdclass();
$fields[$record->rid]->id = $record->rid;
@@ -444,6 +445,8 @@ protected function load_fields() {
$fields[$record->rid]->levels[$record->lid]->definitionformat = $record->definitionformat;
}
}
+ $rs->close();
+
return $fields;
}
Please sign in to comment.
Something went wrong with that request. Please try again.