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]

   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   * This file adds the settings pages to the navigation menu
  19   *
  20   * @package   mod_assign
  21   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die;
  26  
  27  require_once($CFG->dirroot . '/mod/assign/adminlib.php');
  28  
  29  $ADMIN->add('modsettings', new admin_category('modassignfolder', new lang_string('pluginname', 'mod_assign'), $module->is_enabled() === false));
  30  
  31  $settings = new admin_settingpage($section, get_string('settings', 'mod_assign'), 'moodle/site:config', $module->is_enabled() === false);
  32  
  33  if ($ADMIN->fulltree) {
  34      $menu = array();
  35      foreach (core_component::get_plugin_list('assignfeedback') as $type => $notused) {
  36          $visible = !get_config('assignfeedback_' . $type, 'disabled');
  37          if ($visible) {
  38              $menu['assignfeedback_' . $type] = new lang_string('pluginname', 'assignfeedback_' . $type);
  39          }
  40      }
  41  
  42      // The default here is feedback_comments (if it exists).
  43      $name = new lang_string('feedbackplugin', 'mod_assign');
  44      $description = new lang_string('feedbackpluginforgradebook', 'mod_assign');
  45      $settings->add(new admin_setting_configselect('assign/feedback_plugin_for_gradebook',
  46                                                    $name,
  47                                                    $description,
  48                                                    'assignfeedback_comments',
  49                                                    $menu));
  50  
  51      $name = new lang_string('showrecentsubmissions', 'mod_assign');
  52      $description = new lang_string('configshowrecentsubmissions', 'mod_assign');
  53      $settings->add(new admin_setting_configcheckbox('assign/showrecentsubmissions',
  54                                                      $name,
  55                                                      $description,
  56                                                      0));
  57  
  58      $name = new lang_string('sendsubmissionreceipts', 'mod_assign');
  59      $description = new lang_string('sendsubmissionreceipts_help', 'mod_assign');
  60      $settings->add(new admin_setting_configcheckbox('assign/submissionreceipts',
  61                                                      $name,
  62                                                      $description,
  63                                                      1));
  64  
  65      $name = new lang_string('submissionstatement', 'mod_assign');
  66      $description = new lang_string('submissionstatement_help', 'mod_assign');
  67      $default = get_string('submissionstatementdefault', 'mod_assign');
  68      $setting = new admin_setting_configtextarea('assign/submissionstatement',
  69                                                      $name,
  70                                                      $description,
  71                                                      $default);
  72      $setting->set_force_ltr(false);
  73      $settings->add($setting);
  74  
  75      $name = new lang_string('submissionstatementteamsubmission', 'mod_assign');
  76      $description = new lang_string('submissionstatement_help', 'mod_assign');
  77      $default = get_string('submissionstatementteamsubmissiondefault', 'mod_assign');
  78      $setting = new admin_setting_configtextarea('assign/submissionstatementteamsubmission',
  79          $name,
  80          $description,
  81          $default);
  82      $setting->set_force_ltr(false);
  83      $settings->add($setting);
  84  
  85      $name = new lang_string('submissionstatementteamsubmissionallsubmit', 'mod_assign');
  86      $description = new lang_string('submissionstatement_help', 'mod_assign');
  87      $default = get_string('submissionstatementteamsubmissionallsubmitdefault', 'mod_assign');
  88      $setting = new admin_setting_configtextarea('assign/submissionstatementteamsubmissionallsubmit',
  89          $name,
  90          $description,
  91          $default);
  92      $setting->set_force_ltr(false);
  93      $settings->add($setting);
  94  
  95      $name = new lang_string('maxperpage', 'mod_assign');
  96      $options = array(
  97          -1 => get_string('unlimitedpages', 'mod_assign'),
  98          10 => 10,
  99          20 => 20,
 100          50 => 50,
 101          100 => 100,
 102      );
 103      $description = new lang_string('maxperpage_help', 'mod_assign');
 104      $settings->add(new admin_setting_configselect('assign/maxperpage',
 105                                                      $name,
 106                                                      $description,
 107                                                      -1,
 108                                                      $options));
 109  
 110      $name = new lang_string('defaultsettings', 'mod_assign');
 111      $description = new lang_string('defaultsettings_help', 'mod_assign');
 112      $settings->add(new admin_setting_heading('defaultsettings', $name, $description));
 113  
 114      $name = new lang_string('alwaysshowdescription', 'mod_assign');
 115      $description = new lang_string('alwaysshowdescription_help', 'mod_assign');
 116      $setting = new admin_setting_configcheckbox('assign/alwaysshowdescription',
 117                                                      $name,
 118                                                      $description,
 119                                                      1);
 120      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 121      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 122      $settings->add($setting);
 123  
 124      $name = new lang_string('allowsubmissionsfromdate', 'mod_assign');
 125      $description = new lang_string('allowsubmissionsfromdate_help', 'mod_assign');
 126      $setting = new admin_setting_configduration('assign/allowsubmissionsfromdate',
 127                                                      $name,
 128                                                      $description,
 129                                                      0);
 130      $setting->set_enabled_flag_options(admin_setting_flag::ENABLED, true);
 131      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 132      $settings->add($setting);
 133  
 134      $name = new lang_string('duedate', 'mod_assign');
 135      $description = new lang_string('duedate_help', 'mod_assign');
 136      $setting = new admin_setting_configduration('assign/duedate',
 137                                                      $name,
 138                                                      $description,
 139                                                      604800);
 140      $setting->set_enabled_flag_options(admin_setting_flag::ENABLED, true);
 141      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 142      $settings->add($setting);
 143  
 144      $name = new lang_string('cutoffdate', 'mod_assign');
 145      $description = new lang_string('cutoffdate_help', 'mod_assign');
 146      $setting = new admin_setting_configduration('assign/cutoffdate',
 147                                                      $name,
 148                                                      $description,
 149                                                      1209600);
 150      $setting->set_enabled_flag_options(admin_setting_flag::ENABLED, false);
 151      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 152      $settings->add($setting);
 153  
 154      $name = new lang_string('enabletimelimit', 'mod_assign');
 155      $description = new lang_string('enabletimelimit_help', 'mod_assign');
 156      $setting = new admin_setting_configcheckbox(
 157          'assign/enabletimelimit',
 158          $name,
 159          $description,
 160          0
 161      );
 162      $settings->add($setting);
 163  
 164      $name = new lang_string('gradingduedate', 'mod_assign');
 165      $description = new lang_string('gradingduedate_help', 'mod_assign');
 166      $setting = new admin_setting_configduration('assign/gradingduedate',
 167                                                      $name,
 168                                                      $description,
 169                                                      1209600);
 170      $setting->set_enabled_flag_options(admin_setting_flag::ENABLED, true);
 171      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 172      $settings->add($setting);
 173  
 174      $name = new lang_string('submissiondrafts', 'mod_assign');
 175      $description = new lang_string('submissiondrafts_help', 'mod_assign');
 176      $setting = new admin_setting_configcheckbox('assign/submissiondrafts',
 177                                                      $name,
 178                                                      $description,
 179                                                      0);
 180      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 181      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 182      $settings->add($setting);
 183  
 184      $name = new lang_string('requiresubmissionstatement', 'mod_assign');
 185      $description = new lang_string('requiresubmissionstatement_help', 'mod_assign');
 186      $setting = new admin_setting_configcheckbox('assign/requiresubmissionstatement',
 187                                                      $name,
 188                                                      $description,
 189                                                      0);
 190      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 191      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 192      $settings->add($setting);
 193  
 194      // Constants from "locallib.php".
 195      $options = array(
 196          'none' => get_string('attemptreopenmethod_none', 'mod_assign'),
 197          'manual' => get_string('attemptreopenmethod_manual', 'mod_assign'),
 198          'untilpass' => get_string('attemptreopenmethod_untilpass', 'mod_assign')
 199      );
 200      $name = new lang_string('attemptreopenmethod', 'mod_assign');
 201      $description = new lang_string('attemptreopenmethod_help', 'mod_assign');
 202      $setting = new admin_setting_configselect('assign/attemptreopenmethod',
 203                                                      $name,
 204                                                      $description,
 205                                                      'none',
 206                                                      $options);
 207      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 208      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 209      $settings->add($setting);
 210  
 211      // Constants from "locallib.php".
 212      $options = array(-1 => get_string('unlimitedattempts', 'mod_assign'));
 213      $options += array_combine(range(1, 30), range(1, 30));
 214      $name = new lang_string('maxattempts', 'mod_assign');
 215      $description = new lang_string('maxattempts_help', 'mod_assign');
 216      $setting = new admin_setting_configselect('assign/maxattempts',
 217                                                      $name,
 218                                                      $description,
 219                                                      -1,
 220                                                      $options);
 221      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 222      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 223      $settings->add($setting);
 224  
 225      $name = new lang_string('teamsubmission', 'mod_assign');
 226      $description = new lang_string('teamsubmission_help', 'mod_assign');
 227      $setting = new admin_setting_configcheckbox('assign/teamsubmission',
 228                                                      $name,
 229                                                      $description,
 230                                                      0);
 231      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 232      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 233      $settings->add($setting);
 234  
 235      $name = new lang_string('preventsubmissionnotingroup', 'mod_assign');
 236      $description = new lang_string('preventsubmissionnotingroup_help', 'mod_assign');
 237      $setting = new admin_setting_configcheckbox('assign/preventsubmissionnotingroup',
 238          $name,
 239          $description,
 240          0);
 241      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 242      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 243      $settings->add($setting);
 244  
 245      $name = new lang_string('requireallteammemberssubmit', 'mod_assign');
 246      $description = new lang_string('requireallteammemberssubmit_help', 'mod_assign');
 247      $setting = new admin_setting_configcheckbox('assign/requireallteammemberssubmit',
 248                                                      $name,
 249                                                      $description,
 250                                                      0);
 251      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 252      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 253      $settings->add($setting);
 254  
 255      $name = new lang_string('teamsubmissiongroupingid', 'mod_assign');
 256      $description = new lang_string('teamsubmissiongroupingid_help', 'mod_assign');
 257      $setting = new admin_setting_configempty('assign/teamsubmissiongroupingid',
 258                                                      $name,
 259                                                      $description);
 260      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 261      $settings->add($setting);
 262  
 263      $name = new lang_string('sendnotifications', 'mod_assign');
 264      $description = new lang_string('sendnotifications_help', 'mod_assign');
 265      $setting = new admin_setting_configcheckbox('assign/sendnotifications',
 266                                                      $name,
 267                                                      $description,
 268                                                      0);
 269      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 270      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 271      $settings->add($setting);
 272  
 273      $name = new lang_string('sendlatenotifications', 'mod_assign');
 274      $description = new lang_string('sendlatenotifications_help', 'mod_assign');
 275      $setting = new admin_setting_configcheckbox('assign/sendlatenotifications',
 276                                                      $name,
 277                                                      $description,
 278                                                      0);
 279      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 280      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 281      $settings->add($setting);
 282  
 283      $name = new lang_string('sendstudentnotificationsdefault', 'mod_assign');
 284      $description = new lang_string('sendstudentnotificationsdefault_help', 'mod_assign');
 285      $setting = new admin_setting_configcheckbox('assign/sendstudentnotifications',
 286                                                      $name,
 287                                                      $description,
 288                                                      1);
 289      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 290      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 291      $settings->add($setting);
 292  
 293      $name = new lang_string('blindmarking', 'mod_assign');
 294      $description = new lang_string('blindmarking_help', 'mod_assign');
 295      $setting = new admin_setting_configcheckbox('assign/blindmarking',
 296                                                      $name,
 297                                                      $description,
 298                                                      0);
 299      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 300      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 301      $settings->add($setting);
 302  
 303      $name = new lang_string('hidegrader', 'mod_assign');
 304      $description = new lang_string('hidegrader_help', 'mod_assign');
 305      $setting = new admin_setting_configcheckbox('assign/hidegrader',
 306                                                      $name,
 307                                                      $description,
 308                                                      0);
 309      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 310      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 311      $settings->add($setting);
 312  
 313      $name = new lang_string('markingworkflow', 'mod_assign');
 314      $description = new lang_string('markingworkflow_help', 'mod_assign');
 315      $setting = new admin_setting_configcheckbox('assign/markingworkflow',
 316                                                      $name,
 317                                                      $description,
 318                                                      0);
 319      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 320      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 321      $settings->add($setting);
 322  
 323      $name = new lang_string('markingallocation', 'mod_assign');
 324      $description = new lang_string('markingallocation_help', 'mod_assign');
 325      $setting = new admin_setting_configcheckbox('assign/markingallocation',
 326                                                      $name,
 327                                                      $description,
 328                                                      0);
 329      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
 330      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
 331      $settings->add($setting);
 332  }
 333  
 334  $ADMIN->add('modassignfolder', $settings);
 335  // Tell core we already added the settings structure.
 336  $settings = null;
 337  
 338  $ADMIN->add('modassignfolder', new admin_category('assignsubmissionplugins',
 339      new lang_string('submissionplugins', 'assign'), !$module->is_enabled()));
 340  $ADMIN->add('assignsubmissionplugins', new assign_admin_page_manage_assign_plugins('assignsubmission'));
 341  $ADMIN->add('modassignfolder', new admin_category('assignfeedbackplugins',
 342      new lang_string('feedbackplugins', 'assign'), !$module->is_enabled()));
 343  $ADMIN->add('assignfeedbackplugins', new assign_admin_page_manage_assign_plugins('assignfeedback'));
 344  
 345  foreach (core_plugin_manager::instance()->get_plugins_of_type('assignsubmission') as $plugin) {
 346      /** @var \mod_assign\plugininfo\assignsubmission $plugin */
 347      $plugin->load_settings($ADMIN, 'assignsubmissionplugins', $hassiteconfig);
 348  }
 349  
 350  foreach (core_plugin_manager::instance()->get_plugins_of_type('assignfeedback') as $plugin) {
 351      /** @var \mod_assign\plugininfo\assignfeedback $plugin */
 352      $plugin->load_settings($ADMIN, 'assignfeedbackplugins', $hassiteconfig);
 353  }