Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 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   * Definitions of constants for gradebook
  19   *
  20   * @package   core_grades
  21   * @category  grade
  22   * @copyright 2007 Nicolas Connault
  23   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  // Category aggregation types
  29  
  30  /**
  31   * GRADE_AGGREGATE_MEAN - Use the category mean for grade aggregation.
  32   */
  33  define('GRADE_AGGREGATE_MEAN', 0);
  34  
  35  /**
  36   * GRADE_AGGREGATE_MEDIAN - Use the category median for grade aggregation.
  37   */
  38  define('GRADE_AGGREGATE_MEDIAN', 2);
  39  
  40  /**
  41   * GRADE_AGGREGATE_MIN - Use the category minimum grade for grade aggregation.
  42   */
  43  define('GRADE_AGGREGATE_MIN', 4);
  44  
  45  /**
  46   * GRADE_AGGREGATE_MAX - Use the category maximum grade for grade aggregation.
  47   */
  48  define('GRADE_AGGREGATE_MAX', 6);
  49  
  50  /**
  51   * GRADE_AGGREGATE_MEDIAN - Use the category mode for grade aggregation.
  52   */
  53  define('GRADE_AGGREGATE_MODE', 8);
  54  
  55  /**
  56   * GRADE_AGGREGATE_WEIGHTED_MEAN - Use a weighted mean of grades in the category for grade aggregation. Weights can be manually set.
  57   */
  58  define('GRADE_AGGREGATE_WEIGHTED_MEAN', 10);
  59  
  60  /**
  61   * GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use a simple weighted mean of grades in the category for grade aggregation.
  62   */
  63  define('GRADE_AGGREGATE_WEIGHTED_MEAN2', 11);
  64  
  65  /**
  66   * GRADE_AGGREGATE_EXTRACREDIT_MEAN - Use the category mean for grade aggregation and include support for extra credit.
  67   */
  68  define('GRADE_AGGREGATE_EXTRACREDIT_MEAN', 12);
  69  
  70  /**
  71   * GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use Natural in the category for grade aggregation.
  72   */
  73  define('GRADE_AGGREGATE_SUM', 13);
  74  
  75  // Grade types
  76  
  77  /**
  78   * GRADE_TYPE_NONE - Ungraded.
  79   */
  80  define('GRADE_TYPE_NONE', 0);
  81  
  82  /**
  83   * GRADE_TYPE_NONE - The grade is a numeric value
  84   */
  85  define('GRADE_TYPE_VALUE', 1);
  86  
  87  /**
  88   * GRADE_TYPE_NONE - The grade is a value from the set of values available in a grade scale.
  89   */
  90  define('GRADE_TYPE_SCALE', 2);
  91  
  92  /**
  93   * GRADE_TYPE_NONE - Feedback only.
  94   */
  95  define('GRADE_TYPE_TEXT', 3);
  96  
  97  
  98  // grade_update() return status
  99  
 100  /**
 101   * GRADE_UPDATE_OK - Grade updated completed successfully.
 102   */
 103  define('GRADE_UPDATE_OK', 0);
 104  
 105  /**
 106   * GRADE_UPDATE_FAILED - Grade updated failed.
 107   */
 108  define('GRADE_UPDATE_FAILED', 1);
 109  
 110  /**
 111   * GRADE_UPDATE_MULTIPLE - Grade update failed because there are multiple grade items with the same itemnumber for this activity.
 112   */
 113  define('GRADE_UPDATE_MULTIPLE', 2);
 114  
 115  /**
 116   * GRADE_UPDATE_DELETED - Grade item cannot be updated as it is locked
 117   */
 118  define('GRADE_UPDATE_ITEM_LOCKED', 4);
 119  
 120  
 121  // Grade tables history tracking actions
 122  
 123  /**
 124   * GRADE_HISTORY_INSERT - A grade item was inserted
 125   */
 126  define('GRADE_HISTORY_INSERT', 1);
 127  
 128  /**
 129   * GRADE_HISTORY_UPDATE - A grade item was updated
 130   */
 131  define('GRADE_HISTORY_UPDATE', 2);
 132  
 133  /**
 134   * GRADE_HISTORY_INSERT - A grade item was deleted
 135   */
 136  define('GRADE_HISTORY_DELETE', 3);
 137  
 138  // Display style constants
 139  
 140  /**
 141   * GRADE_DISPLAY_TYPE_DEFAULT - Grade display type can be set at 3 levels: grade_item, course setting and site. Use the display type from the higher level.
 142   */
 143  define('GRADE_DISPLAY_TYPE_DEFAULT', 0);
 144  
 145  /**
 146   * GRADE_DISPLAY_TYPE_REAL - Display the grade as a decimal number.
 147   */
 148  define('GRADE_DISPLAY_TYPE_REAL', 1);
 149  
 150  /**
 151   * GRADE_DISPLAY_TYPE_PERCENTAGE - Display the grade as a percentage.
 152   */
 153  define('GRADE_DISPLAY_TYPE_PERCENTAGE', 2);
 154  
 155  /**
 156   * GRADE_DISPLAY_TYPE_LETTER - Display the grade as a letter grade. For example, A, B, C, D or F.
 157   */
 158  define('GRADE_DISPLAY_TYPE_LETTER', 3);
 159  
 160  /**
 161   * GRADE_DISPLAY_TYPE_REAL_PERCENTAGE - Display the grade as a decimal number and a percentage.
 162   */
 163  define('GRADE_DISPLAY_TYPE_REAL_PERCENTAGE', 12);
 164  
 165  /**
 166   * GRADE_DISPLAY_TYPE_REAL_LETTER - Display the grade as a decimal number and a letter grade.
 167   */
 168  define('GRADE_DISPLAY_TYPE_REAL_LETTER', 13);
 169  
 170  /**
 171   * GRADE_DISPLAY_TYPE_LETTER_REAL - Display the grade as a letter grade and a decimal number.
 172   */
 173  define('GRADE_DISPLAY_TYPE_LETTER_REAL', 31);
 174  
 175  /**
 176   * GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE - Display the grade as a letter grade and a percentage.
 177   */
 178  define('GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE', 32);
 179  
 180  /**
 181   * GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER - Display the grade as a percentage and a letter grade.
 182   */
 183  define('GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER', 23);
 184  
 185  /**
 186   * GRADE_DISPLAY_TYPE_PERCENTAGE_REAL - Display the grade as a percentage and a decimal number.
 187   */
 188  define('GRADE_DISPLAY_TYPE_PERCENTAGE_REAL', 21);
 189  
 190  /**
 191   * GRADE_REPORT_AGGREGATION_POSITION_FIRST - Display the course totals before the individual activity grades
 192   */
 193  define('GRADE_REPORT_AGGREGATION_POSITION_FIRST', 0);
 194  
 195  /**
 196   * GRADE_REPORT_AGGREGATION_POSITION_LAST - Display the course totals after the individual activity grades
 197   */
 198  define('GRADE_REPORT_AGGREGATION_POSITION_LAST', 1);
 199  
 200  // What to do if category or course total contains a hidden item
 201  
 202  /**
 203   * GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item hide the total from students.
 204   */
 205  define('GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN', 0);
 206  
 207  /**
 208   * GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item show the total to students minus grades from the hidden items.
 209   */
 210  define('GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN', 1);
 211  
 212  /**
 213   * GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item show students the real total including marks from hidden items.
 214   */
 215  define('GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN', 2);
 216  
 217  /**
 218   * GRADE_REPORT_PREFERENCE_DEFAULT - Use the setting from site preferences.
 219   */
 220  define('GRADE_REPORT_PREFERENCE_DEFAULT', 'default');
 221  
 222  /**
 223   * GRADE_REPORT_PREFERENCE_INHERIT - Inherit the setting value from the parent.
 224   */
 225  define('GRADE_REPORT_PREFERENCE_INHERIT', 'inherit'); // means inherit from parent
 226  
 227  /**
 228   * GRADE_REPORT_PREFERENCE_UNUSED - Unused constant.
 229   */
 230  define('GRADE_REPORT_PREFERENCE_UNUSED', -1);
 231  
 232  /**
 233   * GRADE_REPORT_MEAN_ALL - Include all grade items including those where the student hasn't received a grade when calculating the mean.
 234   */
 235  define('GRADE_REPORT_MEAN_ALL', 0);
 236  
 237  /**
 238   * GRADE_REPORT_MEAN_GRADED - Only include grade items where the student has a grade when calculating the mean.
 239   */
 240  define('GRADE_REPORT_MEAN_GRADED', 1);
 241  
 242  /**
 243   * GRADE_MIN_MAX_FROM_GRADE_ITEM - Get the grade min/max from the grade item.
 244   */
 245  define('GRADE_MIN_MAX_FROM_GRADE_ITEM', 1);
 246  
 247  /**
 248   * GRADE_MIN_MAX_FROM_GRADE_GRADE - Get the grade min/max from the grade grade.
 249   */
 250  define('GRADE_MIN_MAX_FROM_GRADE_GRADE', 2);
 251  
 252  /**
 253   * The component to store grade files.
 254   */
 255  define('GRADE_FILE_COMPONENT', 'grade');
 256  
 257  /**
 258   * The file area to store the associated grade_grades feedback files.
 259   */
 260  define('GRADE_FEEDBACK_FILEAREA', 'feedback');
 261  
 262  /**
 263   * The file area to store the associated grade_grades_history feedback files.
 264   */
 265  define('GRADE_HISTORY_FEEDBACK_FILEAREA', 'historyfeedback');