troodle-expcontent/completion.php

25 lines
648 B
PHP
Raw Permalink Normal View History

<?php
require_once($CFG->libdir.'/completionlib.php');
function set_activity_completion($course, $cm, $userId) {
// Ensure completion is enabled for the course module.
$completion = new completion_info($course);
if ($completion->is_enabled($cm)) {
// Mark the activity as completed for this user.
$completion->update_state($cm, COMPLETION_COMPLETE, $userId);
}
}
$courseid = required_param('courseid', PARAM_INT);
$cmid = required_param('cmid', PARAM_INT);
$userid = $USER->id;
$course = get_course($courseid);
$cm = get_coursemodule_from_id(null, $cmid);
set_activity_completion($course, $cm, $userid);