course_form.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. * Form to edit a users course preferences.
  18. *
  19. * These are stored as columns in the user table, which
  20. * is why they are in /user and not /course or /admin.
  21. *
  22. * @copyright 2016 Joey Andres <jandres@ualberta.ca>
  23. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24. * @package core_user
  25. */
  26. namespace core_user;
  27. if (!defined('MOODLE_INTERNAL')) {
  28. die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
  29. }
  30. require_once($CFG->dirroot.'/lib/formslib.php');
  31. /**
  32. * Class user_course_form.
  33. *
  34. * @copyright 2016 Joey Andres <jandres@ualberta.ca>
  35. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  36. */
  37. class course_form extends \moodleform {
  38. /**
  39. * Define the form.
  40. */
  41. public function definition () {
  42. global $COURSE;
  43. $mform = $this->_form;
  44. $mform->addElement('advcheckbox',
  45. 'enableactivitychooser',
  46. get_string('enableactivitychooser', 'admin'),
  47. get_string('configenableactivitychooser', 'admin'));
  48. $mform->setDefault('enableactivitychooser',
  49. get_user_preferences('usemodchooser', true, $this->_customdata['userid']));
  50. // Add some extra hidden fields.
  51. $mform->addElement('hidden', 'id');
  52. $mform->setType('id', PARAM_INT);
  53. $mform->addElement('hidden', 'course', $COURSE->id);
  54. $mform->setType('course', PARAM_INT);
  55. $this->add_action_buttons(true, get_string('savechanges'));
  56. }
  57. }