]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed context selection
authorbobopinna <bobopinna>
Thu, 31 Aug 2006 10:29:16 +0000 (10:29 +0000)
committerbobopinna <bobopinna>
Thu, 31 Aug 2006 10:29:16 +0000 (10:29 +0000)
mod/scorm/aicc.php
mod/scorm/datamodel.php
mod/scorm/db/access.php
mod/scorm/index.php
mod/scorm/locallib.php
mod/scorm/player.php
mod/scorm/report.php
mod/scorm/view.php

index de03f5e4897d5e0f5d78a1896c7584e4babb4656..595f4a051e4ab7859daba6f0aa7087284a6d5df1 100755 (executable)
                 break;\r
                 case 'putparam':\r
                     if ($status == 'Running') {\r
-                        if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', $context)) {\r
+                        if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $scorm->course)) {\r
+                            echo "error = 1\nerror_text = Unknown\n"; // No one must see this error message if not hacked\r
+                        }\r
+                        if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {\r
                             $initlessonstatus = 'not attempted';\r
                             $lessonstatus = 'not attempted';\r
                             if (isset($SESSION->scorm_lessonstatus)) {\r
index c3086701b03620d104dd20a7e1f3d1345895db78..7a646b5eeb187d99201d8a1462a1b960d0f8102c 100755 (executable)
@@ -37,7 +37,7 @@
 \r
     if (confirm_sesskey() && (!empty($scoid))) {\r
         $result = true;\r
-        if (has_capability('mod/scorm:savetrack', $context)) {\r
+        if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {\r
             foreach ($_POST as $element => $value) {\r
                 if (substr($element,0,3) == 'cmi') {\r
                     $element = str_replace('__','.',$element);\r
index 5bba04eccebdd2da540bc64150cac590ce9d961b..b481a112318521afd7225759b8b2494874ef3607 100644 (file)
@@ -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(
         )
     )
     
-    
 );
 
 ?>
index becdcd2bc664ad15ec4f9b48841035cf2276d3eb..0fbb5aabd48a34cba2f0d43b92efa6b86994369c 100755 (executable)
@@ -52,6 +52,7 @@
 \r
     foreach ($scorms as $scorm) {\r
 \r
+        $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);\r
         $tt = "";\r
         if ($course->format == "weeks" or $course->format == "topics") {\r
             if ($scorm->section) {\r
@@ -61,7 +62,7 @@
             $tt = userdate($scorm->timemodified);\r
         }\r
         $report = '&nbsp;';\r
-        if (has_capability('moodle/user:viewuseractivitiesreport', $context)) {\r
+        if (has_capability('mod/scorm:viewreport', $context)) {\r
             $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');\r
             if ($trackedusers->c > 0) {\r
                 $reportshow = '<a href="report.php?a='.$scorm->id.'">'.get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';\r
index d34f398e7ac9b3c4bb74801297603c4be35ba2ec..badbef98544e15029bf80fac852eeba5a22f651e 100755 (executable)
@@ -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 '<div class="mod-scorm">';
     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.'&amp;section=0&sesskey='.sesskey().'&amp;add=scorm');
         } else {
index ec9cce6345ce9c0f295c99af62494497a573c4b3..15879a80db7ad0785dd6ef3a344504aff4da2729 100755 (executable)
@@ -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 <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
                  '', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);
index 12724d56aa2d8db9b0ac2e2a199a95e6535e2d14..a9267fba9437a17a886d7961794b2f1d0dec0f38 100755 (executable)
@@ -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");
     }
 
index 626e1b22f42132a43fd4f987d2c31ae86dbf50ed..113c57b03889c75ec897ea2ebbbb441a3d82780a 100755 (executable)
@@ -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);
     }
     }
 
     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 "<div class=\"reportlink\"><img src='pix/SuaHeSoDiem.png' /><a target=\"{$CFG->framename}\" href=\"coefficientSetting.php?id=$cm->id\"> ".get_string('scorecoefficientsetting','scorm',$examNumber->examCount).'</a></div>';
-        }
-        // End Add
-
         $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
         if ($trackedusers->c > 0) {
-            echo "<div class=\"reportlink\"><img src='pix/ThongKe.png' /><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
+            echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
         } else {
             echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
         }
     }
 
-    // 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');