Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Capability definitions for the quiz module.
  19   *
  20   * @package    mod_quiz
  21   * @copyright  2006 The Open University
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  $capabilities = array(
  28  
  29      // Ability to see that the quiz exists, and the basic information
  30      // about it, for example the start date and time limit.
  31      'mod/quiz:view' => array(
  32          'captype' => 'read',
  33          'contextlevel' => CONTEXT_MODULE,
  34          'archetypes' => array(
  35              'guest' => CAP_ALLOW,
  36              'student' => CAP_ALLOW,
  37              'teacher' => CAP_ALLOW,
  38              'editingteacher' => CAP_ALLOW,
  39              'manager' => CAP_ALLOW
  40          )
  41      ),
  42  
  43      // Ability to add a new quiz to the course.
  44      'mod/quiz:addinstance' => array(
  45          'riskbitmask' => RISK_XSS,
  46  
  47          'captype' => 'write',
  48          'contextlevel' => CONTEXT_COURSE,
  49          'archetypes' => array(
  50              'editingteacher' => CAP_ALLOW,
  51              'manager' => CAP_ALLOW
  52          ),
  53          'clonepermissionsfrom' => 'moodle/course:manageactivities'
  54      ),
  55  
  56      // Ability to do the quiz as a 'student'.
  57      'mod/quiz:attempt' => array(
  58          'riskbitmask' => RISK_SPAM,
  59          'captype' => 'write',
  60          'contextlevel' => CONTEXT_MODULE,
  61          'archetypes' => array(
  62              'student' => CAP_ALLOW
  63          )
  64      ),
  65  
  66      // Ability for a 'Student' to review their previous attempts. Review by
  67      // 'Teachers' is controlled by mod/quiz:viewreports.
  68      'mod/quiz:reviewmyattempts' => array(
  69          'captype' => 'read',
  70          'contextlevel' => CONTEXT_MODULE,
  71          'archetypes' => array(
  72              'student' => CAP_ALLOW
  73          ),
  74          'clonepermissionsfrom' => 'moodle/quiz:attempt'
  75      ),
  76  
  77      // Edit the quiz settings, add and remove questions.
  78      'mod/quiz:manage' => array(
  79          'riskbitmask' => RISK_SPAM,
  80          'captype' => 'write',
  81          'contextlevel' => CONTEXT_MODULE,
  82          'archetypes' => array(
  83              'editingteacher' => CAP_ALLOW,
  84              'manager' => CAP_ALLOW
  85          )
  86      ),
  87  
  88      // Edit the quiz overrides.
  89      'mod/quiz:manageoverrides' => array(
  90          'captype' => 'write',
  91          'contextlevel' => CONTEXT_MODULE,
  92          'archetypes' => array(
  93              'editingteacher' => CAP_ALLOW,
  94              'manager' => CAP_ALLOW
  95          )
  96      ),
  97  
  98      // Preview the quiz.
  99      'mod/quiz:preview' => array(
 100          'captype' => 'write', // Only just a write.
 101          'contextlevel' => CONTEXT_MODULE,
 102          'archetypes' => array(
 103              'teacher' => CAP_ALLOW,
 104              'editingteacher' => CAP_ALLOW,
 105              'manager' => CAP_ALLOW
 106          )
 107      ),
 108  
 109      // Manually grade and comment on student attempts at a question.
 110      'mod/quiz:grade' => array(
 111          'riskbitmask' => RISK_SPAM | RISK_XSS,
 112          'captype' => 'write',
 113          'contextlevel' => CONTEXT_MODULE,
 114          'archetypes' => array(
 115              'teacher' => CAP_ALLOW,
 116              'editingteacher' => CAP_ALLOW,
 117              'manager' => CAP_ALLOW
 118          )
 119      ),
 120  
 121      // Regrade quizzes.
 122      'mod/quiz:regrade' => array(
 123          'riskbitmask' => RISK_SPAM,
 124          'captype' => 'write',
 125          'contextlevel' => CONTEXT_MODULE,
 126          'archetypes' => array(
 127              'teacher' => CAP_ALLOW,
 128              'editingteacher' => CAP_ALLOW,
 129              'manager' => CAP_ALLOW
 130          ),
 131          'clonepermissionsfrom' =>  'mod/quiz:grade'
 132      ),
 133  
 134      // View the quiz reports.
 135      'mod/quiz:viewreports' => array(
 136          'riskbitmask' => RISK_PERSONAL,
 137          'captype' => 'read',
 138          'contextlevel' => CONTEXT_MODULE,
 139          'archetypes' => array(
 140              'teacher' => CAP_ALLOW,
 141              'editingteacher' => CAP_ALLOW,
 142              'manager' => CAP_ALLOW
 143          )
 144      ),
 145  
 146      // Delete attempts using the overview report.
 147      'mod/quiz:deleteattempts' => array(
 148          'riskbitmask' => RISK_DATALOSS,
 149          'captype' => 'write',
 150          'contextlevel' => CONTEXT_MODULE,
 151          'archetypes' => array(
 152              'editingteacher' => CAP_ALLOW,
 153              'manager' => CAP_ALLOW
 154          )
 155      ),
 156  
 157      // Do not have the time limit imposed. Used for accessibility legislation compliance.
 158      'mod/quiz:ignoretimelimits' => array(
 159          'captype' => 'read',
 160          'contextlevel' => CONTEXT_MODULE,
 161          'archetypes' => array()
 162      ),
 163  
 164      // Receive a confirmation message of own quiz submission.
 165      'mod/quiz:emailconfirmsubmission' => array(
 166          'captype' => 'read',
 167          'contextlevel' => CONTEXT_MODULE,
 168          'archetypes' => array()
 169      ),
 170  
 171      // Receive a notification message of other peoples' quiz submissions.
 172      'mod/quiz:emailnotifysubmission' => array(
 173          'captype' => 'read',
 174          'contextlevel' => CONTEXT_MODULE,
 175          'archetypes' => array()
 176      ),
 177  
 178      // Receive a notification message when a quiz attempt becomes overdue.
 179      'mod/quiz:emailwarnoverdue' => array(
 180          'captype' => 'read',
 181          'contextlevel' => CONTEXT_MODULE,
 182          'archetypes' => array()
 183      ),
 184  );
 185