MDL-40241 completion: Default roles unable to manually complete course

Thanks to Jon Sharp for authoring the original patch!
This commit is contained in:
Aaron Barnes 2013-09-05 13:18:09 +12:00 committed by David Monllao
parent ca0e301c7b
commit 37ee40f3e0
6 changed files with 83 additions and 7 deletions

View file

@ -19,6 +19,9 @@
* Toggles the manual completion flag for a particular activity or course completion
* and the current user.
*
* If by student params: course=2
* If by manager params: course=2&user=4&rolec=3&sesskey=ghfgsdf
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package course
*/
@ -31,6 +34,10 @@ $cmid = optional_param('id', 0, PARAM_INT);
$courseid = optional_param('course', 0, PARAM_INT);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
// Check if we are marking a user complete via the completion report
$user = optional_param('user', 0, PARAM_INT);
$rolec = optional_param('rolec', 0, PARAM_INT);
if (!$cmid && !$courseid) {
print_error('invalidarguments');
}
@ -45,16 +52,14 @@ if ($courseid) {
require_login($course);
$completion = new completion_info($course);
$trackeduser = ($user ? $user : $USER->id);
if (!$completion->is_enabled()) {
throw new moodle_exception('completionnotenabled', 'completion');
} elseif (!$completion->is_tracked_user($USER->id)) {
} elseif (!$completion->is_tracked_user($trackeduser)) {
throw new moodle_exception('nottracked', 'completion');
}
// Check if we are marking a user complete via the completion report
$user = optional_param('user', 0, PARAM_INT);
$rolec = optional_param('rolec', 0, PARAM_INT);
if ($user && $rolec) {
require_sesskey();