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 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   * Settings used by the lesson module, were moved from mod_edit
  19   *
  20   * @package mod_lesson
  21   * @copyright  2009 Sam Hemelryk
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
  23   **/
  24  
  25  defined('MOODLE_INTERNAL') || die;
  26  
  27  if ($ADMIN->fulltree) {
  28      require_once($CFG->dirroot.'/mod/lesson/locallib.php');
  29      $yesno = array(0 => get_string('no'), 1 => get_string('yes'));
  30  
  31      // Introductory explanation that all the settings are defaults for the add lesson form.
  32      $settings->add(new admin_setting_heading('mod_lesson/lessonintro', '', get_string('configintro', 'lesson')));
  33  
  34      // Appearance settings.
  35      $settings->add(new admin_setting_heading('mod_lesson/appearance', get_string('appearance'), ''));
  36  
  37      // Media file popup settings.
  38      $setting = new admin_setting_configempty('mod_lesson/mediafile', get_string('mediafile', 'lesson'),
  39              get_string('mediafile_help', 'lesson'));
  40  
  41      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true);
  42      $settings->add($setting);
  43  
  44      $settings->add(new admin_setting_configtext('mod_lesson/mediawidth', get_string('mediawidth', 'lesson'),
  45              get_string('configmediawidth', 'lesson'), 640, PARAM_INT));
  46  
  47      $settings->add(new admin_setting_configtext('mod_lesson/mediaheight', get_string('mediaheight', 'lesson'),
  48              get_string('configmediaheight', 'lesson'), 480, PARAM_INT));
  49  
  50      $settings->add(new admin_setting_configcheckbox('mod_lesson/mediaclose', get_string('mediaclose', 'lesson'),
  51              get_string('configmediaclose', 'lesson'), false, PARAM_TEXT));
  52  
  53      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/progressbar',
  54          get_string('progressbar', 'lesson'), get_string('progressbar_help', 'lesson'),
  55          array('value' => 0, 'adv' => false), $yesno));
  56  
  57      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/ongoing',
  58          get_string('ongoing', 'lesson'), get_string('ongoing_help', 'lesson'),
  59          array('value' => 0, 'adv' => true), $yesno));
  60  
  61      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/displayleftmenu',
  62          get_string('displayleftmenu', 'lesson'), get_string('displayleftmenu_help', 'lesson'),
  63          array('value' => 0, 'adv' => false), $yesno));
  64  
  65      $percentage = array();
  66      for ($i = 100; $i >= 0; $i--) {
  67          $percentage[$i] = $i.'%';
  68      }
  69      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/displayleftif',
  70          get_string('displayleftif', 'lesson'), get_string('displayleftif_help', 'lesson'),
  71          array('value' => 0, 'adv' => true), $percentage));
  72  
  73      // Slideshow settings.
  74      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/slideshow',
  75          get_string('slideshow', 'lesson'), get_string('slideshow_help', 'lesson'),
  76          array('value' => 0, 'adv' => true), $yesno));
  77  
  78      $settings->add(new admin_setting_configtext('mod_lesson/slideshowwidth', get_string('slideshowwidth', 'lesson'),
  79              get_string('configslideshowwidth', 'lesson'), 640, PARAM_INT));
  80  
  81      $settings->add(new admin_setting_configtext('mod_lesson/slideshowheight', get_string('slideshowheight', 'lesson'),
  82              get_string('configslideshowheight', 'lesson'), 480, PARAM_INT));
  83  
  84      $settings->add(new admin_setting_configtext('mod_lesson/slideshowbgcolor', get_string('slideshowbgcolor', 'lesson'),
  85              get_string('configslideshowbgcolor', 'lesson'), '#FFFFFF', PARAM_TEXT));
  86  
  87      $numbers = array();
  88      for ($i = 20; $i > 1; $i--) {
  89          $numbers[$i] = $i;
  90      }
  91  
  92      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/maxanswers',
  93          get_string('maximumnumberofanswersbranches', 'lesson'), get_string('maximumnumberofanswersbranches_help', 'lesson'),
  94          array('value' => '5', 'adv' => true), $numbers));
  95  
  96      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/defaultfeedback',
  97          get_string('displaydefaultfeedback', 'lesson'), get_string('displaydefaultfeedback_help', 'lesson'),
  98          array('value' => 0, 'adv' => true), $yesno));
  99  
 100      $setting = new admin_setting_configempty('mod_lesson/activitylink', get_string('activitylink', 'lesson'),
 101          '');
 102  
 103      $setting->set_advanced_flag_options(admin_setting_flag::ENABLED, true);
 104      $settings->add($setting);
 105  
 106      // Availability settings.
 107      $settings->add(new admin_setting_heading('mod_lesson/availibility', get_string('availability'), ''));
 108  
 109      $settings->add(new admin_setting_configduration_with_advanced('mod_lesson/timelimit',
 110          get_string('timelimit', 'lesson'), get_string('configtimelimit_desc', 'lesson'),
 111              array('value' => '0', 'adv' => false), 60));
 112  
 113      $settings->add(new admin_setting_configcheckbox_with_advanced('mod_lesson/password',
 114          get_string('password', 'lesson'), get_string('configpassword_desc', 'lesson'),
 115          array('value' => 0, 'adv' => true)));
 116  
 117      // Flow Control.
 118      $settings->add(new admin_setting_heading('lesson/flowcontrol', get_string('flowcontrol', 'lesson'), ''));
 119  
 120      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/modattempts',
 121          get_string('modattempts', 'lesson'), get_string('modattempts_help', 'lesson'),
 122          array('value' => 0, 'adv' => false), $yesno));
 123  
 124      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/displayreview',
 125          get_string('displayreview', 'lesson'), get_string('displayreview_help', 'lesson'),
 126          array('value' => 0, 'adv' => false), $yesno));
 127  
 128      $attempts = ['0' => get_string('unlimited')];
 129      for ($i = 10; $i > 0; $i--) {
 130          $attempts[$i] = $i;
 131      }
 132  
 133      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/maximumnumberofattempts',
 134          get_string('maximumnumberofattempts', 'lesson'), get_string('maximumnumberofattempts_help', 'lesson'),
 135          array('value' => '1', 'adv' => false), $attempts));
 136  
 137      $defaultnextpages = array();
 138      $defaultnextpages[0] = get_string("normal", "lesson");
 139      $defaultnextpages[LESSON_UNSEENPAGE] = get_string("showanunseenpage", "lesson");
 140      $defaultnextpages[LESSON_UNANSWEREDPAGE] = get_string("showanunansweredpage", "lesson");
 141  
 142      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/defaultnextpage',
 143              get_string('actionaftercorrectanswer', 'lesson'), '',
 144              array('value' => 0, 'adv' => true), $defaultnextpages));
 145  
 146      $pages = array();
 147      for ($i = 100; $i >= 0; $i--) {
 148          $pages[$i] = $i;
 149      }
 150      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/numberofpagestoshow',
 151          get_string('numberofpagestoshow', 'lesson'), get_string('numberofpagestoshow_help', 'lesson'),
 152          array('value' => '1', 'adv' => true), $pages));
 153  
 154      // Grade.
 155      $settings->add(new admin_setting_heading('lesson/grade', get_string('gradenoun'), ''));
 156  
 157      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/practice',
 158          get_string('practice', 'lesson'), get_string('practice_help', 'lesson'),
 159          array('value' => 0, 'adv' => false), $yesno));
 160  
 161      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/customscoring',
 162          get_string('customscoring', 'lesson'), get_string('customscoring_help', 'lesson'),
 163          array('value' => 1, 'adv' => true), $yesno));
 164  
 165      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/retakesallowed',
 166          get_string('retakesallowed', 'lesson'), get_string('retakesallowed_help', 'lesson'),
 167          array('value' => 0, 'adv' => false), $yesno));
 168  
 169      $options = array();
 170      $options[0] = get_string('usemean', 'lesson');
 171      $options[1] = get_string('usemaximum', 'lesson');
 172  
 173      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/handlingofretakes',
 174          get_string('handlingofretakes', 'lesson'), get_string('handlingofretakes_help', 'lesson'),
 175          array('value' => 0, 'adv' => true), $options));
 176  
 177      $settings->add(new admin_setting_configselect_with_advanced('mod_lesson/minimumnumberofquestions',
 178          get_string('minimumnumberofquestions', 'lesson'), get_string('minimumnumberofquestions_help', 'lesson'),
 179          array('value' => 0, 'adv' => true), $pages));
 180  
 181  }