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 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2  
   3  // This file defines settingpages and externalpages under the "grades" section
   4  
   5  if (has_capability('moodle/grade:manage', $systemcontext)
   6   or has_capability('moodle/grade:manageletters', $systemcontext)) { // speedup for non-admins, add all caps used on this page
   7  
   8      require_once $CFG->libdir.'/grade/constants.php';
   9      $display_types = array(GRADE_DISPLAY_TYPE_REAL => new lang_string('real', 'grades'),
  10                             GRADE_DISPLAY_TYPE_PERCENTAGE => new lang_string('percentage', 'grades'),
  11                             GRADE_DISPLAY_TYPE_LETTER => new lang_string('letter', 'grades'),
  12                             GRADE_DISPLAY_TYPE_REAL_PERCENTAGE => new lang_string('realpercentage', 'grades'),
  13                             GRADE_DISPLAY_TYPE_REAL_LETTER => new lang_string('realletter', 'grades'),
  14                             GRADE_DISPLAY_TYPE_LETTER_REAL => new lang_string('letterreal', 'grades'),
  15                             GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE => new lang_string('letterpercentage', 'grades'),
  16                             GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER => new lang_string('percentageletter', 'grades'),
  17                             GRADE_DISPLAY_TYPE_PERCENTAGE_REAL => new lang_string('percentagereal', 'grades')
  18                             );
  19      asort($display_types);
  20  
  21      // General settings
  22  
  23      $temp = new admin_settingpage('gradessettings', new lang_string('generalsettings', 'grades'), 'moodle/grade:manage');
  24      if ($ADMIN->fulltree) {
  25  
  26          // new CFG variable for gradebook (what roles to display)
  27          $temp->add(new admin_setting_special_gradebookroles());
  28  
  29          // enable outcomes checkbox now in subsystems area
  30  
  31          $temp->add(new admin_setting_grade_profilereport());
  32  
  33          $temp->add(new admin_setting_configselect('grade_aggregationposition', new lang_string('aggregationposition', 'grades'),
  34                                                    new lang_string('aggregationposition_help', 'grades'), GRADE_REPORT_AGGREGATION_POSITION_LAST,
  35                                                    array(GRADE_REPORT_AGGREGATION_POSITION_FIRST => new lang_string('positionfirst', 'grades'),
  36                                                          GRADE_REPORT_AGGREGATION_POSITION_LAST => new lang_string('positionlast', 'grades'))));
  37  
  38          $temp->add(new admin_setting_regradingcheckbox('grade_includescalesinaggregation', new lang_string('includescalesinaggregation', 'grades'), new lang_string('includescalesinaggregation_help', 'grades'), 1));
  39  
  40          $temp->add(new admin_setting_configcheckbox('grade_hiddenasdate', new lang_string('hiddenasdate', 'grades'), new lang_string('hiddenasdate_help', 'grades'), 0));
  41  
  42          // enable publishing in exports/imports
  43          $temp->add(new admin_setting_configcheckbox('gradepublishing', new lang_string('gradepublishing', 'grades'), new lang_string('gradepublishing_help', 'grades'), 0));
  44  
  45          $temp->add(new admin_setting_configcheckbox('grade_export_exportfeedback', new lang_string('exportfeedback', 'grades'),
  46                                                    new lang_string('exportfeedback_desc', 'grades'), 0));
  47  
  48          $temp->add(new admin_setting_configselect('grade_export_displaytype', new lang_string('gradeexportdisplaytype', 'grades'),
  49                                                    new lang_string('gradeexportdisplaytype_desc', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
  50  
  51          $temp->add(new admin_setting_configselect('grade_export_decimalpoints', new lang_string('gradeexportdecimalpoints', 'grades'),
  52                                                    new lang_string('gradeexportdecimalpoints_desc', 'grades'), 2,
  53                                                    array( '0' => '0',
  54                                                           '1' => '1',
  55                                                           '2' => '2',
  56                                                           '3' => '3',
  57                                                           '4' => '4',
  58                                                           '5' => '5')));
  59          $temp->add(new admin_setting_configselect('grade_navmethod', new lang_string('navmethod', 'grades'), null,
  60                                                    GRADE_NAVMETHOD_TABS,
  61                                                    array(GRADE_NAVMETHOD_DROPDOWN => new lang_string('dropdown', 'grades'),
  62                                                          GRADE_NAVMETHOD_TABS => new lang_string('tabs', 'grades'),
  63                                                          GRADE_NAVMETHOD_COMBO => new lang_string('combo', 'grades'))));
  64  
  65          $setting = new admin_setting_configtext('grade_export_userprofilefields',
  66              new lang_string('gradeexportuserprofilefields', 'grades'),
  67              new lang_string('gradeexportuserprofilefields_desc', 'grades'),
  68              'firstname,lastname,idnumber,institution,department,email', PARAM_TEXT);
  69          $setting->set_force_ltr(true);
  70          $temp->add($setting);
  71  
  72          $setting = new admin_setting_configtext('grade_export_customprofilefields',
  73              new lang_string('gradeexportcustomprofilefields', 'grades'),
  74              new lang_string('gradeexportcustomprofilefields_desc', 'grades'), '', PARAM_TEXT);
  75          $setting->set_force_ltr(true);
  76          $temp->add($setting);
  77  
  78          $temp->add(new admin_setting_configcheckbox('recovergradesdefault', new lang_string('recovergradesdefault', 'grades'), new lang_string('recovergradesdefault_help', 'grades'), 0));
  79  
  80          $temp->add(new admin_setting_special_gradeexport());
  81  
  82          $temp->add(new admin_setting_special_gradelimiting());
  83  
  84          $temp->add(new admin_setting_configcheckbox('grade_report_showmin',
  85                                                      get_string('minimum_show', 'grades'),
  86                                                      get_string('minimum_show_help', 'grades'), '1'));
  87  
  88          $temp->add(new admin_setting_special_gradepointmax());
  89  
  90          $temp->add(new admin_setting_special_gradepointdefault());
  91  
  92          $temp->add(new admin_setting_special_grademinmaxtouse());
  93  
  94          $temp->add(new admin_setting_my_grades_report());
  95  
  96          $temp->add(new admin_setting_configtext('gradereport_mygradeurl', new lang_string('externalurl', 'grades'),
  97                  new lang_string('externalurl_desc', 'grades'), ''));
  98      }
  99      $ADMIN->add('grades', $temp);
 100  
 101      /// Grade category settings
 102      $temp = new admin_settingpage('gradecategorysettings', new lang_string('gradecategorysettings', 'grades'), 'moodle/grade:manage');
 103      if ($ADMIN->fulltree) {
 104          $temp->add(new admin_setting_configcheckbox('grade_hideforcedsettings', new lang_string('hideforcedsettings', 'grades'), new lang_string('hideforcedsettings_help', 'grades'), '1'));
 105  
 106          $strnoforce = new lang_string('noforce', 'grades');
 107  
 108          // Aggregation type
 109          $options = array(GRADE_AGGREGATE_MEAN            =>new lang_string('aggregatemean', 'grades'),
 110                           GRADE_AGGREGATE_WEIGHTED_MEAN   =>new lang_string('aggregateweightedmean', 'grades'),
 111                           GRADE_AGGREGATE_WEIGHTED_MEAN2  =>new lang_string('aggregateweightedmean2', 'grades'),
 112                           GRADE_AGGREGATE_EXTRACREDIT_MEAN=>new lang_string('aggregateextracreditmean', 'grades'),
 113                           GRADE_AGGREGATE_MEDIAN          =>new lang_string('aggregatemedian', 'grades'),
 114                           GRADE_AGGREGATE_MIN             =>new lang_string('aggregatemin', 'grades'),
 115                           GRADE_AGGREGATE_MAX             =>new lang_string('aggregatemax', 'grades'),
 116                           GRADE_AGGREGATE_MODE            =>new lang_string('aggregatemode', 'grades'),
 117                           GRADE_AGGREGATE_SUM             =>new lang_string('aggregatesum', 'grades'));
 118  
 119          $defaultvisible = array(GRADE_AGGREGATE_SUM);
 120  
 121          $defaults = array('value' => GRADE_AGGREGATE_SUM, 'forced' => false, 'adv' => false);
 122          $temp->add(new admin_setting_gradecat_combo('grade_aggregation', new lang_string('aggregation', 'grades'), new lang_string('aggregation_help', 'grades'), $defaults, $options));
 123  
 124          $temp->add(new admin_setting_configmultiselect('grade_aggregations_visible', new lang_string('aggregationsvisible', 'grades'),
 125                                                         new lang_string('aggregationsvisiblehelp', 'grades'), $defaultvisible, $options));
 126  
 127          $options = array(0 => new lang_string('no'), 1 => new lang_string('yes'));
 128  
 129          $defaults = array('value'=>1, 'forced'=>false, 'adv'=>true);
 130          $temp->add(new admin_setting_gradecat_combo('grade_aggregateonlygraded', new lang_string('aggregateonlygraded', 'grades'),
 131                      new lang_string('aggregateonlygraded_help', 'grades'), $defaults, $options));
 132          $defaults = array('value'=>0, 'forced'=>false, 'adv'=>true);
 133          $temp->add(new admin_setting_gradecat_combo('grade_aggregateoutcomes', new lang_string('aggregateoutcomes', 'grades'),
 134                      new lang_string('aggregateoutcomes_help', 'grades'), $defaults, $options));
 135  
 136          $options = array(0 => new lang_string('none'));
 137          for ($i=1; $i<=20; $i++) {
 138              $options[$i] = $i;
 139          }
 140  
 141          $defaults['value'] = 0;
 142          $defaults['forced'] = true;
 143          $temp->add(new admin_setting_gradecat_combo('grade_keephigh', new lang_string('keephigh', 'grades'),
 144                      new lang_string('keephigh_help', 'grades'), $defaults, $options));
 145          $defaults['forced'] = false;
 146          $temp->add(new admin_setting_gradecat_combo('grade_droplow', new lang_string('droplow', 'grades'),
 147                      new lang_string('droplow_help', 'grades'), $defaults, $options));
 148  
 149          $temp->add(new admin_setting_configcheckbox('grade_overridecat', new lang_string('overridecat', 'grades'),
 150                     new lang_string('overridecat_help', 'grades'), 1));
 151      }
 152      $ADMIN->add('grades', $temp);
 153  
 154  
 155      /// Grade item settings
 156      $temp = new admin_settingpage('gradeitemsettings', new lang_string('gradeitemsettings', 'grades'), 'moodle/grade:manage');
 157      if ($ADMIN->fulltree) {
 158          $temp->add(new admin_setting_configselect('grade_displaytype', new lang_string('gradedisplaytype', 'grades'),
 159                                                    new lang_string('gradedisplaytype_help', 'grades'), GRADE_DISPLAY_TYPE_REAL, $display_types));
 160  
 161          $temp->add(new admin_setting_configselect('grade_decimalpoints', new lang_string('decimalpoints', 'grades'),
 162                                                    new lang_string('decimalpoints_help', 'grades'), 2,
 163                                                    array( '0' => '0',
 164                                                           '1' => '1',
 165                                                           '2' => '2',
 166                                                           '3' => '3',
 167                                                           '4' => '4',
 168                                                           '5' => '5')));
 169  
 170          $temp->add(new admin_setting_configmultiselect('grade_item_advanced', new lang_string('gradeitemadvanced', 'grades'), new lang_string('gradeitemadvanced_help', 'grades'),
 171                                                         array('iteminfo', 'idnumber', 'gradepass', 'plusfactor', 'multfactor', 'display', 'decimals', 'hiddenuntil', 'locktime'),
 172                                                         array('iteminfo' => new lang_string('iteminfo', 'grades'),
 173                                                               'idnumber' => new lang_string('idnumbermod'),
 174                                                               'gradetype' => new lang_string('gradetype', 'grades'),
 175                                                               'scaleid' => new lang_string('scale'),
 176                                                               'grademin' => new lang_string('grademin', 'grades'),
 177                                                               'grademax' => new lang_string('grademax', 'grades'),
 178                                                               'gradepass' => new lang_string('gradepass', 'grades'),
 179                                                               'plusfactor' => new lang_string('plusfactor', 'grades'),
 180                                                               'multfactor' => new lang_string('multfactor', 'grades'),
 181                                                               'display' => new lang_string('gradedisplaytype', 'grades'),
 182                                                               'decimals' => new lang_string('decimalpoints', 'grades'),
 183                                                               'hidden' => new lang_string('hidden', 'grades'),
 184                                                               'hiddenuntil' => new lang_string('hiddenuntil', 'grades'),
 185                                                               'locked' => new lang_string('locked', 'grades'),
 186                                                               'locktime' => new lang_string('locktime', 'grades'),
 187                                                               'aggregationcoef' => new lang_string('aggregationcoef', 'grades'),
 188                                                               'parentcategory' => new lang_string('parentcategory', 'grades'))));
 189      }
 190      $ADMIN->add('grades', $temp);
 191  
 192  
 193      /// Scales and outcomes
 194  
 195      $scales = new admin_externalpage('scales', new lang_string('scales'), $CFG->wwwroot.'/grade/edit/scale/index.php', 'moodle/grade:manage');
 196      $ADMIN->add('grades', $scales);
 197      if (!empty($CFG->enableoutcomes)) {
 198          $outcomes = new admin_externalpage('outcomes', new lang_string('outcomes', 'grades'), $CFG->wwwroot.'/grade/edit/outcome/index.php', 'moodle/grade:manage');
 199          $ADMIN->add('grades', $outcomes);
 200      }
 201      $letters = new admin_externalpage('letters', new lang_string('letters', 'grades'), $CFG->wwwroot.'/grade/edit/letter/index.php', 'moodle/grade:manageletters');
 202      $ADMIN->add('grades', $letters);
 203  
 204      // The plugins must implement a settings.php file that adds their admin settings to the $settings object
 205  
 206      // Reports
 207      $ADMIN->add('grades', new admin_category('gradereports', new lang_string('reportsettings', 'grades')));
 208      foreach (core_component::get_plugin_list('gradereport') as $plugin => $plugindir) {
 209       // Include all the settings commands for this plugin if there are any
 210          if (file_exists($plugindir.'/settings.php')) {
 211              $settings = new admin_settingpage('gradereport'.$plugin, new lang_string('pluginname', 'gradereport_'.$plugin), 'moodle/grade:manage');
 212              include($plugindir.'/settings.php');
 213              if ($settings) {
 214                  $ADMIN->add('gradereports', $settings);
 215              }
 216          }
 217      }
 218  
 219      // Imports
 220      $ADMIN->add('grades', new admin_category('gradeimports', new lang_string('importsettings', 'grades')));
 221      foreach (core_component::get_plugin_list('gradeimport') as $plugin => $plugindir) {
 222  
 223       // Include all the settings commands for this plugin if there are any
 224          if (file_exists($plugindir.'/settings.php')) {
 225              $settings = new admin_settingpage('gradeimport'.$plugin, new lang_string('pluginname', 'gradeimport_'.$plugin), 'moodle/grade:manage');
 226              include($plugindir.'/settings.php');
 227              if ($settings) {
 228                  $ADMIN->add('gradeimports', $settings);
 229              }
 230          }
 231      }
 232  
 233  
 234      // Exports
 235      $ADMIN->add('grades', new admin_category('gradeexports', new lang_string('exportsettings', 'grades')));
 236      foreach (core_component::get_plugin_list('gradeexport') as $plugin => $plugindir) {
 237       // Include all the settings commands for this plugin if there are any
 238          if (file_exists($plugindir.'/settings.php')) {
 239              $settings = new admin_settingpage('gradeexport'.$plugin, new lang_string('pluginname', 'gradeexport_'.$plugin), 'moodle/grade:manage');
 240              include($plugindir.'/settings.php');
 241              if ($settings) {
 242                  $ADMIN->add('gradeexports', $settings);
 243              }
 244          }
 245      }
 246  
 247  } // end of speedup
 248