Search moodle.org's
Developer Documentation

   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_once(dirname(dirname(dirname(__FILE__))).'/config.php');
  27  require_once(dirname(__FILE__).'/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')));

Search This Site: