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.
   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * Aggregates the grades for submission and grades for assessments
  20   *
  21   * @package    mod_workshop
  22   * @copyright  2009 David Mudrak <david.mudrak@gmail.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  require(__DIR__.'/../../config.php');
  27  require_once (__DIR__.'/locallib.php');
  28  
  29  $cmid       = required_param('cmid', PARAM_INT);            // course module
  30  $confirm    = optional_param('confirm', false, PARAM_BOOL); // confirmation
  31  
  32  // the params to be re-passed to view.php
  33  $page       = optional_param('page', 0, PARAM_INT);
  34  $sortby     = optional_param('sortby', 'lastname', PARAM_ALPHA);
  35  $sorthow    = optional_param('sorthow', 'ASC', PARAM_ALPHA);
  36  
  37  $cm         = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
  38  $course     = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  39  $workshop   = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
  40  $workshop   = new workshop($workshop, $cm, $course);
  41  
  42  $PAGE->set_url($workshop->aggregate_url(), compact('confirm', 'page', 'sortby', 'sorthow'));
  43  
  44  require_login($course, false, $cm);
  45  require_capability('mod/workshop:overridegrades', $PAGE->context);
  46  
  47  // load and init the grading evaluator
  48  $evaluator = $workshop->grading_evaluation_instance();
  49  $settingsform = $evaluator->get_settings_form($PAGE->url);
  50  
  51  if ($settingsdata = $settingsform->get_data()) {
  52      $workshop->aggregate_submission_grades();           // updates 'grade' in {workshop_submissions}
  53      $evaluator->update_grading_grades($settingsdata);   // updates 'gradinggrade' in {workshop_assessments}
  54      $workshop->aggregate_grading_grades();              // updates 'gradinggrade' in {workshop_aggregations}
  55  }
  56  
  57  redirect(new moodle_url($workshop->view_url(), compact('page', 'sortby', 'sorthow')));