]> git.mjollnir.org Git - moodle.git/commitdiff
adding capabilities
authortoyomoyo <toyomoyo>
Thu, 31 Aug 2006 08:51:09 +0000 (08:51 +0000)
committertoyomoyo <toyomoyo>
Thu, 31 Aug 2006 08:51:09 +0000 (08:51 +0000)
mod/assignment/type/online/file.php
mod/hotpot/db/access.php
mod/hotpot/version.php
mod/quiz/attempt.php
mod/quiz/lib.php
mod/quiz/quizfile.php
mod/quiz/restorelibpre15.php
mod/quiz/review.php

index cc106618aae80055e20f25c325f7e0f9cf51880c..2a613364eb05cdffc29004614bb179b432770aa6 100644 (file)
@@ -25,7 +25,7 @@
 
     require_login($course->id, false, $cm);
 
-    if (($USER->id != $user->id) && !isteacher($course->id)) {
+    if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
         error("You can not view this assignment");
     }
 
index 808cb5321d8933f5f11117e7b3dccec337292cfa..d1fdc12b49d040bd8cba0c8e2137f4c7ac9c03b8 100644 (file)
@@ -33,7 +33,7 @@
 
 $mod_hotpot_capabilities = array(
     
-    'mod/hotpot:view' => array(
+    'mod/hotpot:attempt' => array(
     
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
@@ -45,6 +45,48 @@ $mod_hotpot_capabilities = array(
             'coursecreator' => CAP_ALLOW,
             'admin' => CAP_ALLOW
         )
+    ),
+    
+    'mod/hotpot: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/hotpot:grade' => 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/hotpot:deleteattempt' => array(
+    
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'guest' => CAP_PREVENT,
+            'student' => CAP_PREVENT,
+            'teacher' => CAP_PREVENT,
+            'editingteacher' => CAP_ALLOW,
+            'coursecreator' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
     )
     
 );
index 6a3e843a6cc54e008a15d9b705b4e1acba399176..abb56c62712324ebe2b1e849520ea0483e759d5d 100644 (file)
@@ -3,7 +3,7 @@
 ///  Code fragment to define the version of hotpot
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
-$module->version  = 2006080900;   // release date of this version (see note below)
+$module->version  = 2006083100;   // release date of this version (see note below)
 $module->release  = 'v2.2.0';    // human-friendly version name (used in mod/hotpot/lib.php)
 $module->requires = 2006080900;  // Requires this Moodle version
 $module->cron     = 0;            // period for cron to check this module (secs)
index 46f29dbd26d5a826127d8411aec53829797ba90c..6fc2330fcb6b42f6e3c57b641f51b6fb918c16f1 100644 (file)
@@ -57,7 +57,7 @@
     }
 
     require_login($course->id, false, $cm);
-    $isteacher = isteacher($course->id);
+    $isteacher = has_capability('mod/quiz:grade', get_context_instance(CONTEXT_MODULE, $cm->id));
     
     $coursecontext = get_context_instance(CONTEXT_COURSE, $id); // course context
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
index 0b38d223bbcbc9cbb5b2c8b9792f60ff380bc6a4..0eb2dba5e39bcff63e918da90feab6790d4ccb20 100644 (file)
@@ -435,7 +435,7 @@ function quiz_print_recent_mod_activity($activity, $course, $detail=false) {
 
     }
 
-    if (isteacher($course)) {
+    if has_capability('mod/quiz:grade', get_context_instance(CONTEXT_MODULE, $course)) {
         $grades = "(" .  $activity->content->sumgrades . " / " . $activity->content->maxgrade . ") ";
         echo "<a href=\"$CFG->wwwroot/mod/quiz/review.php?q="
              . $activity->instance . "&amp;attempt="
index 0f5cb70d5a3e5fa6dc1a1dbac45f6b6c44b4943b..5ba5477078cd0da174a011718cc3d11c5576de67 100644 (file)
@@ -49,9 +49,8 @@
             }
         } else {
             require_login($questioncategory->course);
-            if (!isteacher($questioncategory->course)) {
-                error('Access not allowed');
-            }
+            $cm = get_coursemodule_from_instance('quiz', $quizid);
+            require_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id));
         }        
     } else {
         if (!($quiz = get_record('quiz', 'id', $quizid))) {
index 5c33d76c57244cc9d565114810bc66bdfc9adb67..823d1d216546d9f9bc17f5017c816bd997bb3a61 100644 (file)
             $attempt->layout = $quizquestions;
 
             //Set the preview field (code from upgrade)
-            if (isteacher($restore->course_id,$attempt->userid)) {
+            $cm = get_coursemodule_from_instance('quiz', $quiz_id);
+            if (has_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id))) {
                 $attempt->preview = 1;
             }
 
index d4dcb460ff8bdf5bfceddedd9e34796206c3ff72..9230a361163b80b99d0e7276e38f09c594738df0 100644 (file)
@@ -42,7 +42,7 @@
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     $coursecontext = get_context_instance(CONTEXT_COURSE, $cm->course);
-    $isteacher = isteacher($course->id);
+    $isteacher = has_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id));
     $options = quiz_get_reviewoptions($quiz, $attempt, $context);
     $popup = $isteacher ? 0 : $quiz->popup; // Controls whether this is shown in a javascript-protected window.