mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-57915 mod_data: Move view completion and event code to function
This commit is contained in:
parent
1034421264
commit
023ffa656d
3 changed files with 74 additions and 14 deletions
|
@ -25,7 +25,6 @@
|
|||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/mod/data/lib.php');
|
||||
require_once($CFG->libdir . '/rsslib.php');
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
|
||||
/// One of these is necessary!
|
||||
$id = optional_param('id', 0, PARAM_INT); // course module id
|
||||
|
@ -255,15 +254,8 @@
|
|||
set_user_preference('data_perpage_'.$data->id, $perpage);
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'context' => $context,
|
||||
'objectid' => $data->id
|
||||
);
|
||||
$event = \mod_data\event\course_module_viewed::create($params);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('course', $course);
|
||||
$event->add_record_snapshot('data', $data);
|
||||
$event->trigger();
|
||||
// Completion and trigger events.
|
||||
data_view($data, $course, $cm, $context);
|
||||
|
||||
$urlparams = array('d' => $data->id);
|
||||
if ($record) {
|
||||
|
@ -300,10 +292,6 @@
|
|||
$PAGE->requires->js('/mod/data/js.php?d='.$data->id, true);
|
||||
}
|
||||
|
||||
// Mark as viewed
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
/// Print the page header
|
||||
// Note: MDL-19010 there will be further changes to printing header and blocks.
|
||||
// The code will be much nicer than this eventually.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue