PageRenderTime 48ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/mod/workshop/aggregate.php

http://github.com/moodle/moodle
PHP | 57 lines | 23 code | 11 blank | 23 comment | 1 complexity | 3250add45004738c810ae97d7621b19d MD5 | raw file
Possible License(s): MIT, AGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, Apache-2.0, LGPL-2.1, BSD-3-Clause
  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. * Aggregates the grades for submission and grades for assessments
  18. *
  19. * @package mod_workshop
  20. * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. require(__DIR__.'/../../config.php');
  24. require_once(__DIR__.'/locallib.php');
  25. $cmid = required_param('cmid', PARAM_INT); // course module
  26. $confirm = optional_param('confirm', false, PARAM_BOOL); // confirmation
  27. // the params to be re-passed to view.php
  28. $page = optional_param('page', 0, PARAM_INT);
  29. $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA);
  30. $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA);
  31. $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
  32. $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  33. $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
  34. $workshop = new workshop($workshop, $cm, $course);
  35. $PAGE->set_url($workshop->aggregate_url(), compact('confirm', 'page', 'sortby', 'sorthow'));
  36. require_login($course, false, $cm);
  37. require_capability('mod/workshop:overridegrades', $PAGE->context);
  38. // load and init the grading evaluator
  39. $evaluator = $workshop->grading_evaluation_instance();
  40. $settingsform = $evaluator->get_settings_form($PAGE->url);
  41. if ($settingsdata = $settingsform->get_data()) {
  42. $workshop->aggregate_submission_grades(); // updates 'grade' in {workshop_submissions}
  43. $evaluator->update_grading_grades($settingsdata); // updates 'gradinggrade' in {workshop_assessments}
  44. $workshop->aggregate_grading_grades(); // updates 'gradinggrade' in {workshop_aggregations}
  45. }
  46. redirect(new moodle_url($workshop->view_url(), compact('page', 'sortby', 'sorthow')));