settings.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. * enrol_teacherskey file description here.
  18. *
  19. * @package enrol_teacherskey
  20. * @copyright 2022 Alex Sidorov <alex.sidorov@ya.ru>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined("MOODLE_INTERNAL") || die();
  24. if($ADMIN->fulltree){
  25. $option = get_default_enrol_roles(context_system::instance());
  26. $settings->add(new admin_setting_heading('enrol_teacherskey_settings', '', get_string('pluginname_desc', 'enrol_teacherskey')));
  27. $settings->add(new admin_setting_heading('enrol_teacherskey_defaults',
  28. get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
  29. $settings->add(new admin_setting_configcheckbox('enrol_teacherskey/defaultenrol',
  30. get_string('defaultenrol', 'enrol'), get_string('defaultenrol_desc', 'enrol'), 1));
  31. if (!during_initial_install()) {
  32. $options = get_default_enrol_roles(context_system::instance());
  33. $student = get_archetype_roles('student');
  34. $student = reset($student);
  35. $settings->add(new admin_setting_configselect('enrol_teacherskey/roleid',
  36. get_string('defaultrole', 'enrol_teacherskey'),
  37. get_string('defaultrole_desc', 'enrol_teacherskey'),
  38. $student->id ?? null,
  39. $options));
  40. }
  41. }