-
Bug
-
Resolution: Fixed
-
Minor
-
2.6.4, 2.7.1, 3.0.6
-
MOODLE_26_STABLE, MOODLE_27_STABLE, MOODLE_30_STABLE
-
MOODLE_30_STABLE, MOODLE_31_STABLE
-
master_
MDL-46903 -
Replication steps:
- Log in as teacher/admin
- Navigate to a course
- Create a new SCORM activity (any package, default settings) or use an existing one
- View the SCORM activity
- Go to Reports
- Go to Objectives
Using Oracle, I came across the following database error.
Error reading from database
|
|
More information about this error
|
Debug info: ORA-00932: inconsistent datatypes: expected - got CLOB
|
SELECT DISTINCT value, scoid FROM a_scorm_scoes_track WHERE scormid = :o_param1 AND LOWER(element) LIKE LOWER(:o_param2) ESCAPE '\' ORDER BY value
|
[array (
|
'o_param1' => '1',
|
'o_param2' => 'cmi.objectives_%.id',
|
)]
|
Error code: dmlreadexception
|
Stack trace:
|
|
line 443 of \lib\dml\moodle_database.php: dml_read_exception thrown
|
line 271 of \lib\dml\oci_native_moodle_database.php: call to moodle_database->query_end()
|
line 1092 of \lib\dml\oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
|
line 1199 of \lib\dml\moodle_database.php: call to oci_native_moodle_database->get_recordset_sql()
|
line 652 of \mod\scorm\report\objectives\classes\report.php: call to moodle_database->get_recordset_select()
|
line 193 of \mod\scorm\report\objectives\classes\report.php: call to scormreport_objectives\get_scorm_objectives()
|
line 97 of \mod\scorm\report.php: call to scormreport_objectives\report->display()
|
The problem comes about because the "value" field is a long text field (a CLOB in Oracle terms) and this cannot be used for ordering or for testing if a result is distinct. The offending query is...
mod/scorm/report/objectives/classes/report.php, line 652 |
$rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, 'value', 'DISTINCT value, scoid');
|
This line has been as it is since the inception of the report in 2.6. The function goes on to form the record set into an array, which removes the need for distinct results, and it also resorts the values on the scoid value, so ordering by value is not necessary.
The statement can therefore be changed to the following to gain the same results.
$rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, 'scoid', 'value, scoid');
|
However, if there is a large amount of duplication, shifting the filtering for distinct results from the DB to code may be unwise.