Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

   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 = [
  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' => [
  32          'captype' => 'read',
  33          'contextlevel' => CONTEXT_MODULE,
  34          'archetypes' => [
  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' => [
  45          'riskbitmask' => RISK_XSS,
  46  
  47          'captype' => 'write',
  48          'contextlevel' => CONTEXT_COURSE,
  49          'archetypes' => [
  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' => [
  58          'riskbitmask' => RISK_SPAM,
  59          'captype' => 'write',
  60          'contextlevel' => CONTEXT_MODULE,
  61          'archetypes' => [
  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' => [
  69          'captype' => 'read',
  70          'contextlevel' => CONTEXT_MODULE,
  71          'archetypes' => [
  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' => [
  79          'riskbitmask' => RISK_SPAM,
  80          'captype' => 'write',
  81          'contextlevel' => CONTEXT_MODULE,
  82          'archetypes' => [
  83              'editingteacher' => CAP_ALLOW,
  84              'manager' => CAP_ALLOW
  85          ]
  86      ],
  87  
  88      // Edit the quiz overrides.
  89      'mod/quiz:manageoverrides' => [
  90          'captype' => 'write',
  91          'contextlevel' => CONTEXT_MODULE,
  92          'archetypes' => [
  93              'editingteacher' => CAP_ALLOW,
  94              'manager' => CAP_ALLOW
  95          ]
  96      ],
  97  
  98      // View the quiz overrides (only checked for users who don't have mod/quiz:manageoverrides.
  99      'mod/quiz:viewoverrides' => [
 100          'captype' => 'read',
 101          'contextlevel' => CONTEXT_MODULE,
 102          'archetypes' => [
 103              'teacher' => CAP_ALLOW,
 104              'editingteacher' => CAP_ALLOW,
 105              'manager' => CAP_ALLOW
 106          ]
 107      ],
 108  
 109      // Preview the quiz.
 110      'mod/quiz:preview' => [
 111          'captype' => 'write', // Only just a write.
 112          'contextlevel' => CONTEXT_MODULE,
 113          'archetypes' => [
 114              'teacher' => CAP_ALLOW,
 115              'editingteacher' => CAP_ALLOW,
 116              'manager' => CAP_ALLOW
 117          ]
 118      ],
 119  
 120      // Manually grade and comment on student attempts at a question.
 121      'mod/quiz:grade' => [
 122          'riskbitmask' => RISK_SPAM | RISK_XSS,
 123          'captype' => 'write',
 124          'contextlevel' => CONTEXT_MODULE,
 125          'archetypes' => [
 126              'teacher' => CAP_ALLOW,
 127              'editingteacher' => CAP_ALLOW,
 128              'manager' => CAP_ALLOW
 129          ]
 130      ],
 131  
 132      // Regrade quizzes.
 133      'mod/quiz:regrade' => [
 134          'riskbitmask' => RISK_SPAM,
 135          'captype' => 'write',
 136          'contextlevel' => CONTEXT_MODULE,
 137          'archetypes' => [
 138              'teacher' => CAP_ALLOW,
 139              'editingteacher' => CAP_ALLOW,
 140              'manager' => CAP_ALLOW
 141          ],
 142          'clonepermissionsfrom' =>  'mod/quiz:grade'
 143      ],
 144  
 145      // View the quiz reports.
 146      'mod/quiz:viewreports' => [
 147          'riskbitmask' => RISK_PERSONAL,
 148          'captype' => 'read',
 149          'contextlevel' => CONTEXT_MODULE,
 150          'archetypes' => [
 151              'teacher' => CAP_ALLOW,
 152              'editingteacher' => CAP_ALLOW,
 153              'manager' => CAP_ALLOW
 154          ]
 155      ],
 156  
 157      // Delete attempts using the overview report.
 158      'mod/quiz:deleteattempts' => [
 159          'riskbitmask' => RISK_DATALOSS,
 160          'captype' => 'write',
 161          'contextlevel' => CONTEXT_MODULE,
 162          'archetypes' => [
 163              'editingteacher' => CAP_ALLOW,
 164              'manager' => CAP_ALLOW
 165          ]
 166      ],
 167  
 168      // Do not have the time limit imposed. Used for accessibility legislation compliance.
 169      'mod/quiz:ignoretimelimits' => [
 170          'captype' => 'read',
 171          'contextlevel' => CONTEXT_MODULE,
 172          'archetypes' => []
 173      ],
 174  
 175      // Receive a confirmation message of own quiz submission.
 176      'mod/quiz:emailconfirmsubmission' => [
 177          'captype' => 'read',
 178          'contextlevel' => CONTEXT_MODULE,
 179          'archetypes' => []
 180      ],
 181  
 182      // Receive a notification message of other peoples' quiz submissions.
 183      'mod/quiz:emailnotifysubmission' => [
 184          'captype' => 'read',
 185          'contextlevel' => CONTEXT_MODULE,
 186          'archetypes' => []
 187      ],
 188  
 189      // Receive a notification message when a quiz attempt becomes overdue.
 190      'mod/quiz:emailwarnoverdue' => [
 191          'captype' => 'read',
 192          'contextlevel' => CONTEXT_MODULE,
 193          'archetypes' => []
 194      ],
 195  ];
 196