Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
David Mudrák mudrd8mz authored

Showing 1 changed file with 7 additions and 4 deletions. Show diff stats Hide diff stats

  1. +7 4 mod/workshop/form/rubric/lib.php
11 mod/workshop/form/rubric/lib.php
@@ -418,16 +418,17 @@ public static function delete_instance($workshopid) {
418 418 protected function load_fields() {
419 419 global $DB;
420 420
421   - $sql = 'SELECT l.id AS lid, r.id AS rid, r.*, l.*
  421 + $sql = "SELECT r.id AS rid, r.sort, r.description, r.descriptionformat,
  422 + l.id AS lid, l.grade, l.definition, l.definitionformat
422 423 FROM {workshopform_rubric} r
423 424 LEFT JOIN {workshopform_rubric_levels} l ON (l.dimensionid = r.id)
424 425 WHERE r.workshopid = :workshopid
425   - ORDER BY r.sort, l.grade';
  426 + ORDER BY r.sort, l.grade";
426 427 $params = array('workshopid' => $this->workshop->id);
427 428
428   - $records = $DB->get_records_sql($sql, $params);
  429 + $rs = $DB->get_recordset_sql($sql, $params);
429 430 $fields = array();
430   - foreach ($records as $record) {
  431 + foreach ($rs as $record) {
431 432 if (!isset($fields[$record->rid])) {
432 433 $fields[$record->rid] = new stdclass();
433 434 $fields[$record->rid]->id = $record->rid;
@@ -444,6 +445,8 @@ protected function load_fields() {
444 445 $fields[$record->rid]->levels[$record->lid]->definitionformat = $record->definitionformat;
445 446 }
446 447 }
  448 + $rs->close();
  449 +
447 450 return $fields;
448 451 }
449 452

0 comments on commit 6e7e184

Please sign in to comment.
Something went wrong with that request. Please try again.