Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Regrades a module that has been added or updated when it might take a long time.
19
 *
20
 * A progress bar will be displayed in that case, and then the user can click 'Continue' to proceed.
21
 * If for some reason you get to this page when regrading will not take a long time, then it will
22
 * redirect immediately.
23
 *
24
 * @package core_course
25
 * @copyright 2022 The Open University
26
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
 
29
define('NO_OUTPUT_BUFFERING', true);
30
require('../config.php');
31
require_once($CFG->libdir . '/gradelib.php');
32
 
33
$cmid = required_param('id', PARAM_INT);
34
$urlpath = required_param('url', PARAM_LOCALURL);
35
$url = new moodle_url($urlpath);
36
 
37
// Check that an absolute url/path was specified e.g. /course/view.php (it probably isn't a
38
// security risk to allow a relative one, but isn't necessary here).
39
if (!$url->get_host()) {
40
    throw new moodle_exception('missingparam', 'error', '', 'url');
41
}
42
 
43
// Get course.
44
[$course, $cm] = get_course_and_cm_from_cmid($cmid);
45
$context = \context_module::instance($cm->id);
46
 
47
// Set up page for display.
48
$PAGE->set_url(new moodle_url('/course/modregrade.php', ['id' => $cmid, 'url' => $url]));
49
$PAGE->set_context($context);
50
$PAGE->set_title($course->shortname . ': ' . get_string('recalculatinggrades', 'grades'));
51
 
52
// Security check: must be logged in with manage activities permission.
53
require_login($course, false, $cm);
54
require_capability('moodle/course:manageactivities', $context);
55
 
56
// Do the regrade if necessary.
57
grade_regrade_final_grades_if_required($course);
58
 
59
// Redirect back to the target URL.
60
redirect($url);