SCORM MDL-21492 don't skip view if user is able to view reports - thanks to valerian for report/patch

This commit is contained in:
Dan Marsden
2010-06-25 10:12:29 +00:00
parent 477912aec1
commit 489797d979
2 changed files with 7 additions and 24 deletions
+5 -23
View File
@@ -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;
+2 -1
View File
@@ -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;
}