feat: add completion tracking to view_content.php
Integrated course module completion tracking to ensure activities are marked complete for users. This leverages the existing completionlib.php library to update the completion state. This enhancement ensures accurate tracking of user progress.
This commit is contained in:
parent
6cbe774d79
commit
9066e451c3
1 changed files with 10 additions and 0 deletions
|
@ -3,6 +3,8 @@
|
|||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once(dirname(__FILE__) . '/lib.php');
|
||||
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
|
||||
$cm = get_coursemodule_from_id('exp360', $id, 0, false, MUST_EXIST);
|
||||
|
@ -11,6 +13,14 @@ $exp360 = $DB->get_record('exp360', array('id' => $cm->instance), '*', MUST_EXIS
|
|||
|
||||
$content_id = $exp360->content_id;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
Loading…
Reference in a new issue