[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/grade/report/grader/ -> index.php (source)

   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   * The gradebook grader report
  19   *
  20   * @package   gradereport_grader
  21   * @copyright 2007 Moodle Pty Ltd (http://moodle.com)
  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($CFG->dirroot.'/user/renderer.php');
  28  require_once($CFG->dirroot.'/grade/lib.php');
  29  require_once($CFG->dirroot.'/grade/report/grader/lib.php');
  30  
  31  $courseid      = required_param('id', PARAM_INT);        // course id
  32  $page          = optional_param('page', 0, PARAM_INT);   // active page
  33  $edit          = optional_param('edit', -1, PARAM_BOOL); // sticky editting mode
  34  
  35  $sortitemid    = optional_param('sortitemid', 0, PARAM_ALPHANUM); // sort by which grade item
  36  $action        = optional_param('action', 0, PARAM_ALPHAEXT);
  37  $move          = optional_param('move', 0, PARAM_INT);
  38  $type          = optional_param('type', 0, PARAM_ALPHA);
  39  $target        = optional_param('target', 0, PARAM_ALPHANUM);
  40  $toggle        = optional_param('toggle', null, PARAM_INT);
  41  $toggle_type   = optional_param('toggle_type', 0, PARAM_ALPHANUM);
  42  
  43  $graderreportsifirst  = optional_param('sifirst', null, PARAM_NOTAGS);
  44  $graderreportsilast   = optional_param('silast', null, PARAM_NOTAGS);
  45  
  46  // The report object is recreated each time, save search information to SESSION object for future use.
  47  if (isset($graderreportsifirst)) {
  48      $SESSION->gradereport['filterfirstname'] = $graderreportsifirst;
  49  }
  50  if (isset($graderreportsilast)) {
  51      $SESSION->gradereport['filtersurname'] = $graderreportsilast;
  52  }
  53  
  54  $PAGE->set_url(new moodle_url('/grade/report/grader/index.php', array('id'=>$courseid)));
  55  $PAGE->requires->yui_module('moodle-gradereport_grader-gradereporttable', 'Y.M.gradereport_grader.init', null, null, true);
  56  
  57  // basic access checks
  58  if (!$course = $DB->get_record('course', array('id' => $courseid))) {
  59      print_error('nocourseid');
  60  }
  61  require_login($course);
  62  $context = context_course::instance($course->id);
  63  
  64  require_capability('gradereport/grader:view', $context);
  65  require_capability('moodle/grade:viewall', $context);
  66  
  67  // return tracking object
  68  $gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'grader', 'courseid'=>$courseid, 'page'=>$page));
  69  
  70  // last selected report session tracking
  71  if (!isset($USER->grade_last_report)) {
  72      $USER->grade_last_report = array();
  73  }
  74  $USER->grade_last_report[$course->id] = 'grader';
  75  
  76  // Build editing on/off buttons
  77  
  78  if (!isset($USER->gradeediting)) {
  79      $USER->gradeediting = array();
  80  }
  81  
  82  if (has_capability('moodle/grade:edit', $context)) {
  83      if (!isset($USER->gradeediting[$course->id])) {
  84          $USER->gradeediting[$course->id] = 0;
  85      }
  86  
  87      if (($edit == 1) and confirm_sesskey()) {
  88          $USER->gradeediting[$course->id] = 1;
  89      } else if (($edit == 0) and confirm_sesskey()) {
  90          $USER->gradeediting[$course->id] = 0;
  91      }
  92  
  93      // page params for the turn editting on
  94      $options = $gpr->get_options();
  95      $options['sesskey'] = sesskey();
  96  
  97      if ($USER->gradeediting[$course->id]) {
  98          $options['edit'] = 0;
  99          $string = get_string('turneditingoff');
 100      } else {
 101          $options['edit'] = 1;
 102          $string = get_string('turneditingon');
 103      }
 104  
 105      $buttons = new single_button(new moodle_url('index.php', $options), $string, 'get');
 106  } else {
 107      $USER->gradeediting[$course->id] = 0;
 108      $buttons = '';
 109  }
 110  
 111  $gradeserror = array();
 112  
 113  // Handle toggle change request
 114  if (!is_null($toggle) && !empty($toggle_type)) {
 115      set_user_preferences(array('grade_report_show'.$toggle_type => $toggle));
 116  }
 117  
 118  // Perform actions
 119  if (!empty($target) && !empty($action) && confirm_sesskey()) {
 120      grade_report_grader::do_process_action($target, $action, $courseid);
 121  }
 122  
 123  $reportname = get_string('pluginname', 'gradereport_grader');
 124  
 125  // Do this check just before printing the grade header (and only do it once).
 126  grade_regrade_final_grades_if_required($course);
 127  
 128  // Print header
 129  print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
 130  
 131  //Initialise the grader report object that produces the table
 132  //the class grade_report_grader_ajax was removed as part of MDL-21562
 133  $report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);
 134  $numusers = $report->get_numusers(true, true);
 135  
 136  // make sure separate group does not prevent view
 137  if ($report->currentgroup == -2) {
 138      echo $OUTPUT->heading(get_string("notingroup"));
 139      echo $OUTPUT->footer();
 140      exit;
 141  }
 142  
 143  // processing posted grades & feedback here
 144  if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) {
 145      $warnings = $report->process_data($data);
 146  } else {
 147      $warnings = array();
 148  }
 149  
 150  // final grades MUST be loaded after the processing
 151  $report->load_users();
 152  $report->load_final_grades();
 153  echo $report->group_selector;
 154  
 155  // User search
 156  $url = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id));
 157  $firstinitial = isset($SESSION->gradereport['filterfirstname']) ? $SESSION->gradereport['filterfirstname'] : '';
 158  $lastinitial  = isset($SESSION->gradereport['filtersurname']) ? $SESSION->gradereport['filtersurname'] : '';
 159  $totalusers = $report->get_numusers(true, false);
 160  $renderer = $PAGE->get_renderer('core_user');
 161  echo $renderer->user_search($url, $firstinitial, $lastinitial, $numusers, $totalusers, $report->currentgroupname);
 162  
 163  //show warnings if any
 164  foreach ($warnings as $warning) {
 165      echo $OUTPUT->notification($warning);
 166  }
 167  
 168  $studentsperpage = $report->get_students_per_page();
 169  // Don't use paging if studentsperpage is empty or 0 at course AND site levels
 170  if (!empty($studentsperpage)) {
 171      echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
 172  }
 173  
 174  $displayaverages = true;
 175  if ($numusers == 0) {
 176      $displayaverages = false;
 177  }
 178  
 179  $reporthtml = $report->get_grade_table($displayaverages);
 180  
 181  // print submit button
 182  if ($USER->gradeediting[$course->id] && ($report->get_pref('showquickfeedback') || $report->get_pref('quickgrading'))) {
 183      echo '<form action="index.php" enctype="application/x-www-form-urlencoded" method="post" id="gradereport_grader">'; // Enforce compatibility with our max_input_vars hack.
 184      echo '<div>';
 185      echo '<input type="hidden" value="'.s($courseid).'" name="id" />';
 186      echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
 187      echo '<input type="hidden" value="'.time().'" name="timepageload" />';
 188      echo '<input type="hidden" value="grader" name="report"/>';
 189      echo '<input type="hidden" value="'.$page.'" name="page"/>';
 190      echo $reporthtml;
 191      echo '<div class="submit"><input type="submit" id="gradersubmit" value="'.s(get_string('savechanges')).'" /></div>';
 192      echo '</div></form>';
 193  } else {
 194      echo $reporthtml;
 195  }
 196  
 197  // prints paging bar at bottom for large pages
 198  if (!empty($studentsperpage) && $studentsperpage >= 20) {
 199      echo $OUTPUT->paging_bar($numusers, $report->page, $studentsperpage, $report->pbarurl);
 200  }
 201  
 202  $event = \gradereport_grader\event\grade_report_viewed::create(
 203      array(
 204          'context' => $context,
 205          'courseid' => $courseid,
 206      )
 207  );
 208  $event->trigger();
 209  
 210  echo $OUTPUT->footer();


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1