From 489797d979e860a20f2efaa77126e579942d4c1f Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 25 Jun 2010 10:12:29 +0000 Subject: [PATCH] SCORM MDL-21492 don't skip view if user is able to view reports - thanks to valerian for report/patch --- mod/scorm/locallib.php | 28 +++++----------------------- mod/scorm/view.php | 3 ++- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index 62b17861492..7a4bf7f1993 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -824,7 +824,7 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') { } } -function scorm_simple_play($scorm,$user) { +function scorm_simple_play($scorm,$user, $context) { global $DB; $result = false; @@ -832,8 +832,11 @@ function scorm_simple_play($scorm,$user) { if ($scorm->updatefreq == UPDATE_EVERYTIME) { scorm_parse($scorm, false); } + if (has_capability('mod/scorm:viewreport', $context)) { //if this user can view reports, don't skipview so they can see links to reports. + return $result; + } - $scoes = $DB->get_records_select('scorm_scoes', 'scorm = ? AND launch <> ?', array($scorm->id, $DB->sql_empty())); + $scoes = $DB->get_records_select('scorm_scoes', 'scorm = ? AND launch <> ?', array($scorm->id, $DB->sql_empty()), 'id', 'id'); if ($scoes) { if ($scorm->skipview >= 1) { @@ -849,27 +852,6 @@ function scorm_simple_play($scorm,$user) { } return $result; } -/* -function scorm_simple_play($scorm,$user) { - global $DB; - $result = false; - if ($scoes = $DB->get_records_select('scorm_scoes','scorm=? AND launch<>""', array($scorm->id))) { - if (count($scoes) == 1) { - if ($scorm->skipview >= 1) { - $sco = current($scoes); - if (scorm_get_tracks($sco->id,$user->id) === false) { - header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id); - $result = true; - } else if ($scorm->skipview == 2) { - header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id); - $result = true; - } - } - } - } - return $result; -} -*/ function scorm_get_count_users($scormid, $groupingid=null) { global $CFG, $DB; diff --git a/mod/scorm/view.php b/mod/scorm/view.php index da1c78d19fa..5cb79245a86 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -40,6 +40,7 @@ require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_COURSE, $course->id); + $contextmodule = get_context_instance(CONTEXT_MODULE,$cm->id); if (isset($SESSION->scorm_scoid)) { unset($SESSION->scorm_scoid); @@ -52,7 +53,7 @@ add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id); - if ((has_capability('mod/scorm:skipview', get_context_instance(CONTEXT_MODULE,$cm->id))) && scorm_simple_play($scorm,$USER)) { + if ((has_capability('mod/scorm:skipview', $contextmodule)) && scorm_simple_play($scorm,$USER, $contextmodule)) { exit; }