Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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   * Grader report preferences configuration page
  19   *
  20   * @package   gradereport_grader
  21   * @copyright 2007 Nicolas Connault
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  require_once '../../../config.php';
  26  require_once $CFG->libdir . '/gradelib.php';
  27  require_once  '../../lib.php';
  28  core_php_time_limit::raise();
  29  
  30  $courseid      = required_param('id', PARAM_INT);
  31  
  32  $PAGE->set_url(new moodle_url('/grade/report/grader/preferences.php', array('id'=>$courseid)));
  33  $PAGE->set_pagelayout('admin');
  34  
  35  /// Make sure they can even access this course
  36  
  37  if (!$course = $DB->get_record('course', array('id' => $courseid))) {
  38      print_error('invalidcourseid');
  39  }
  40  
  41  require_login($course);
  42  
  43  $context = context_course::instance($course->id);
  44  $systemcontext = context_system::instance();
  45  require_capability('gradereport/grader:view', $context);
  46  
  47  require ('preferences_form.php');
  48  $mform = new grader_report_preferences_form('preferences.php', compact('course'));
  49  
  50  // If data submitted, then process and store.
  51  if (!$mform->is_cancelled() && $data = $mform->get_data()) {
  52      foreach ($data as $preference => $value) {
  53          if (substr($preference, 0, 6) !== 'grade_') {
  54              continue;
  55          }
  56  
  57          if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
  58              unset_user_preference($preference);
  59          } else {
  60              set_user_preference($preference, $value);
  61          }
  62      }
  63  
  64      redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid); // message here breaks accessability and is sloooowww
  65      exit;
  66  }
  67  
  68  if ($mform->is_cancelled()){
  69      redirect($CFG->wwwroot . '/grade/report/grader/index.php?id='.$courseid);
  70  }
  71  
  72  print_grade_page_head($courseid, 'settings', 'grader', get_string('preferences', 'gradereport_grader'));
  73  
  74  // If USER has admin capability, print a link to the site config page for this report
  75  if (has_capability('moodle/site:config', $systemcontext)) {
  76      echo '<div id="siteconfiglink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section=gradereportgrader">';
  77      echo get_string('changereportdefaults', 'grades');
  78      echo "</a></div>\n";
  79  }
  80  
  81  echo $OUTPUT->box_start();
  82  
  83  $mform->display();
  84  echo $OUTPUT->box_end();
  85  
  86  echo $OUTPUT->footer();
  87