From: bobopinna Date: Thu, 31 Aug 2006 10:29:16 +0000 (+0000) Subject: Fixed context selection X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0d699c2449606b39cbba269388e2db1105a624b1;p=moodle.git Fixed context selection --- diff --git a/mod/scorm/aicc.php b/mod/scorm/aicc.php index de03f5e489..595f4a051e 100755 --- a/mod/scorm/aicc.php +++ b/mod/scorm/aicc.php @@ -135,7 +135,10 @@ break; case 'putparam': if ($status == 'Running') { - if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', $context)) { + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $scorm->course)) { + echo "error = 1\nerror_text = Unknown\n"; // No one must see this error message if not hacked + } + if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) { $initlessonstatus = 'not attempted'; $lessonstatus = 'not attempted'; if (isset($SESSION->scorm_lessonstatus)) { diff --git a/mod/scorm/datamodel.php b/mod/scorm/datamodel.php index c3086701b0..7a646b5eeb 100755 --- a/mod/scorm/datamodel.php +++ b/mod/scorm/datamodel.php @@ -37,7 +37,7 @@ if (confirm_sesskey() && (!empty($scoid))) { $result = true; - if (has_capability('mod/scorm:savetrack', $context)) { + if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) { foreach ($_POST as $element => $value) { if (substr($element,0,3) == 'cmi') { $element = str_replace('__','.',$element); diff --git a/mod/scorm/db/access.php b/mod/scorm/db/access.php index 5bba04ecce..b481a11231 100644 --- a/mod/scorm/db/access.php +++ b/mod/scorm/db/access.php @@ -47,6 +47,20 @@ $mod_scorm_capabilities = array( ) ), + 'mod/scorm:viewreport' => array( + + 'captype' => 'read', + 'contextlevel' => CONTEXT_MODULE, + 'legacy' => array( + 'guest' => CAP_PREVENT, + 'student' => CAP_PREVENT, + 'teacher' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + 'coursecreator' => CAP_ALLOW, + 'admin' => CAP_ALLOW + ) + ), + 'mod/scorm:savetrack' => array( 'captype' => 'write', @@ -75,7 +89,6 @@ $mod_scorm_capabilities = array( ) ) - ); ?> diff --git a/mod/scorm/index.php b/mod/scorm/index.php index becdcd2bc6..0fbb5aabd4 100755 --- a/mod/scorm/index.php +++ b/mod/scorm/index.php @@ -52,6 +52,7 @@ foreach ($scorms as $scorm) { + $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule); $tt = ""; if ($course->format == "weeks" or $course->format == "topics") { if ($scorm->section) { @@ -61,7 +62,7 @@ $tt = userdate($scorm->timemodified); } $report = ' '; - if (has_capability('moodle/user:viewuseractivitiesreport', $context)) { + if (has_capability('mod/scorm:viewreport', $context)) { $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c'); if ($trackedusers->c > 0) { $reportshow = ''.get_string('viewallreports','scorm',$trackedusers->c).''; diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index d34f398e7a..badbef9854 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -376,6 +376,7 @@ function scorm_course_format_display($user,$course) { $strupdate = get_string('update'); $strmodule = get_string('modulename','scorm'); + $context get_context_instance(CONTEXT_COURSE,$course->id); echo '
'; if ($scorms = get_all_instances_in_course('scorm', $course)) { @@ -410,7 +411,7 @@ function scorm_course_format_display($user,$course) { print_simple_box($headertext,'','100%'); scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%'); } else { - if (has_capability('moodle/course:', $context)) { + if (has_capability('moodle/course:update', $context)) { // Create a new activity redirect($CFG->wwwroot.'/course/mod.php?id='.$course->id.'&section=0&sesskey='.sesskey().'&add=scorm'); } else { diff --git a/mod/scorm/player.php b/mod/scorm/player.php index ec9cce6345..15879a80db 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -60,7 +60,7 @@ $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name)); - if (!$cm->visible and !has_capability('moodle/user:viewhiddenactivities',$context)) { + if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE,$course->id))) { print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name,true)."", '', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false); diff --git a/mod/scorm/report.php b/mod/scorm/report.php index 12724d56aa..a9267fba94 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -42,7 +42,7 @@ require_login($course->id, false, $cm); - if (!has_capability('moodle/user:viewuseractivitiesreport',$context)) { + if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id)) { error("You are not allowed to use this script"); } diff --git a/mod/scorm/view.php b/mod/scorm/view.php index 626e1b22f4..113c57b038 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -5,10 +5,10 @@ $id = optional_param('id', '', PARAM_INT); // Course Module ID, or $a = optional_param('a', '', PARAM_INT); // scorm ID - //$organization = optional_param('organization', '', PARAM_INT); // organization ID + $organization = optional_param('organization', '', PARAM_INT); // organization ID if (!empty($id)) { - if (! $cm = $cm = get_coursemodule_from_id('scorm', $id)) { + if (! $cm = get_coursemodule_from_id('scorm', $id)) { error("Course Module ID was incorrect"); } if (! $course = get_record("course", "id", $cm->course)) { @@ -33,6 +33,8 @@ require_login($course->id, false, $cm); + $context = get_context_instance(CONTEXT_COURSE, $course->id) + if (isset($SESSION->scorm_scoid)) { unset($SESSION->scorm_scoid); } @@ -69,25 +71,14 @@ } if (has_capability('moodle/course:manageactivities', $context)) { - // Added by Pham Minh Duc - $examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount'); - if ($examNumber->examCount > 0){ - echo "'; - } - // End Add - $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c'); if ($trackedusers->c > 0) { - echo "'; + echo "'; } else { echo ''; } } - // Added by Pham Minh Duc - $USER->setAttempt = 'notset'; - // End Add - // Print the main part of the page print_heading(format_string($scorm->name)); print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');