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.
This commit is contained in:
@@ -430,16 +430,17 @@ class workshop_rubric_strategy implements workshop_strategy {
|
||||
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;
|
||||
@@ -456,6 +457,8 @@ class workshop_rubric_strategy implements workshop_strategy {
|
||||
$fields[$record->rid]->levels[$record->lid]->definitionformat = $record->definitionformat;
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user