Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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   * Defines the form for editing activity results block instances.
  19   *
  20   * @package    block_activity_results
  21   * @copyright  2016 Stephen Bourget
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die;
  26  
  27  if ($ADMIN->fulltree) {
  28  
  29      // Default high scores.
  30      $setting = new admin_setting_configtext('block_activity_results/config_showbest',
  31          new lang_string('defaulthighestgrades', 'block_activity_results'),
  32          new lang_string('defaulthighestgrades_desc', 'block_activity_results'), 3, PARAM_INT);
  33      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
  34      $settings->add($setting);
  35  
  36      // Default low scores.
  37      $setting = new admin_setting_configtext('block_activity_results/config_showworst',
  38          new lang_string('defaultlowestgrades', 'block_activity_results'),
  39          new lang_string('defaultlowestgrades_desc', 'block_activity_results'), 0, PARAM_INT);
  40      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
  41      $settings->add($setting);
  42  
  43      // Default group display.
  44      $yesno = array(0 => get_string('no'), 1 => get_string('yes'));
  45      $setting = new admin_setting_configselect('block_activity_results/config_usegroups',
  46          new lang_string('defaultshowgroups', 'block_activity_results'),
  47          new lang_string('defaultshowgroups_desc', 'block_activity_results'), 0, $yesno);
  48      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
  49      $settings->add($setting);
  50  
  51      // Default privacy settings.
  52      $nameoptions = array(
  53          B_ACTIVITYRESULTS_NAME_FORMAT_FULL => get_string('config_names_full', 'block_activity_results'),
  54          B_ACTIVITYRESULTS_NAME_FORMAT_ID => get_string('config_names_id', 'block_activity_results'),
  55          B_ACTIVITYRESULTS_NAME_FORMAT_ANON => get_string('config_names_anon', 'block_activity_results')
  56      );
  57      $setting = new admin_setting_configselect('block_activity_results/config_nameformat',
  58          new lang_string('defaultnameoptions', 'block_activity_results'),
  59          new lang_string('defaultnameoptions_desc', 'block_activity_results'), B_ACTIVITYRESULTS_NAME_FORMAT_FULL, $nameoptions);
  60      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
  61      $settings->add($setting);
  62  
  63      // Default grade display settings.
  64      $gradeoptions = array(
  65          B_ACTIVITYRESULTS_GRADE_FORMAT_PCT => get_string('config_format_percentage', 'block_activity_results'),
  66          B_ACTIVITYRESULTS_GRADE_FORMAT_FRA => get_string('config_format_fraction', 'block_activity_results'),
  67          B_ACTIVITYRESULTS_GRADE_FORMAT_ABS => get_string('config_format_absolute', 'block_activity_results')
  68      );
  69      $setting = new admin_setting_configselect('block_activity_results/config_gradeformat',
  70          new lang_string('defaultgradedisplay', 'block_activity_results'),
  71          new lang_string('defaultgradedisplay_desc', 'block_activity_results'), B_ACTIVITYRESULTS_GRADE_FORMAT_PCT, $gradeoptions);
  72      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
  73      $settings->add($setting);
  74  
  75      // Default decimal places.
  76      $places = array();
  77      for ($i = 0; $i <= 5; $i++) {
  78          $places[$i] = $i;
  79      }
  80      $setting = new admin_setting_configselect('block_activity_results/config_decimalpoints',
  81          new lang_string('defaultdecimalplaces', 'block_activity_results'),
  82          new lang_string('defaultdecimalplaces_desc', 'block_activity_results'), 2, $places);
  83      $setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
  84      $settings->add($setting);
  85  
  86  }