Skip to content

Commit

Permalink
MDL-46903 scorm: Fix db error in objectives report for oracle.
Browse files Browse the repository at this point in the history
also improve 2004 report handling to help with testing.
  • Loading branch information
danmarsden committed Oct 31, 2016
1 parent f4f89d4 commit 086bc88
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions mod/scorm/report/objectives/classes/report.php
Expand Up @@ -491,25 +491,33 @@ public function display($scorm, $cm, $course, $download) {
$row[] = $score;
}
// Iterate over tracks and match objective id against values.
$keywords = array("cmi.objectives_", ".id");
$scorm2004 = false;
if (scorm_version_check($scorm->version, SCORM_13)) {
$scorm2004 = true;
$objectiveprefix = "cmi.objectives.";
} else {
$objectiveprefix = "cmi.objectives_";
}

$keywords = array(".id", $objectiveprefix);
$objectivestatus = array();
$objectivescore = array();
foreach ($trackdata as $name => $value) {
if (strpos($name, 'cmi.objectives_') === 0 && strrpos($name, '.id') !== false) {
if (strpos($name, $objectiveprefix) === 0 && strrpos($name, '.id') !== false) {
$num = trim(str_ireplace($keywords, '', $name));
if (is_numeric($num)) {
if (scorm_version_check($scorm->version, SCORM_13)) {
$element = 'cmi.objectives_'.$num.'.completion_status';
if ($scorm2004) {
$element = $objectiveprefix.$num.'.completion_status';
} else {
$element = 'cmi.objectives_'.$num.'.status';
$element = $objectiveprefix.$num.'.status';
}
if (isset($trackdata->$element)) {
$objectivestatus[$value] = $trackdata->$element;
} else {
$objectivestatus[$value] = '';
}
if ($displayoptions['objectivescore']) {
$element = 'cmi.objectives_'.$num.'.score.raw';
$element = $objectiveprefix.$num.'.score.raw';
if (isset($trackdata->$element)) {
$objectivescore[$value] = $trackdata->$element;
} else {
Expand Down Expand Up @@ -648,8 +656,9 @@ function get_scorm_objectives($scormid) {
$select = "scormid = ? AND ";
$select .= $DB->sql_like("element", "?", false);
$params[] = $scormid;
$params[] = "cmi.objectives_%.id";
$rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, 'value', 'DISTINCT value, scoid');
$params[] = "cmi.objectives%.id";
$value = $DB->sql_compare_text('value');
$rs = $DB->get_recordset_select("scorm_scoes_track", $select, $params, $value, "DISTINCT $value, scoid");
if ($rs->valid()) {
foreach ($rs as $record) {
$objectives[$record->scoid][] = $record->value;
Expand Down

0 comments on commit 086bc88

Please sign in to comment.