mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-40056 events: Replace old add_to_log calls with new events
This commit is contained in:
parent
25e8023d3d
commit
0a61619043
@ -32,7 +32,9 @@ if (!empty($id)) {
|
||||
require_course_login($course);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
|
||||
// Trigger instances list viewed event.
|
||||
$event = \mod_scorm\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id)));
|
||||
$event->trigger();
|
||||
|
||||
$strscorm = get_string("modulename", "scorm");
|
||||
$strscorms = get_string("modulenameplural", "scorm");
|
||||
|
@ -109,6 +109,12 @@ $string['element'] = 'Element';
|
||||
$string['enter'] = 'Enter';
|
||||
$string['entercourse'] = 'Enter course';
|
||||
$string['errorlogs'] = 'Errors log';
|
||||
$string['eventattemptdeleted'] = 'Attempt deleted';
|
||||
$string['eventinteractionsviewed'] = 'Interactions viewed';
|
||||
$string['eventreportviewed'] = 'Report viewed';
|
||||
$string['eventscolaunched'] = 'Sco launched';
|
||||
$string['eventtracksviewed'] = 'Tracks viewed';
|
||||
$string['eventuserreportviewed'] = 'User report viewed';
|
||||
$string['everyday'] = 'Every day';
|
||||
$string['everytime'] = 'Every time it\'s used';
|
||||
$string['exceededmaxattempts'] = 'You have reached the maximum number of attempts.';
|
||||
|
@ -159,7 +159,16 @@ if (scorm_external_link($sco->launch)) {
|
||||
$result = "$CFG->wwwroot/pluginfile.php/$context->id/mod_scorm/content/$scorm->revision/$launcher";
|
||||
}
|
||||
|
||||
add_to_log($course->id, 'scorm', 'launch', 'view.php?id='.$cm->id, $result, $cm->id);
|
||||
// Trigger a Sco launched event.
|
||||
$event = \mod_scorm\event\sco_launched::create(array(
|
||||
'objectid' => $sco->id,
|
||||
'context' => $context,
|
||||
'other' => array('instanceid' => $scorm->id, 'loadedcontent' => $result)
|
||||
));
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->add_record_snapshot('scorm_scoes', $sco);
|
||||
$event->trigger();
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
|
@ -1268,9 +1268,9 @@ function scorm_debugging($scorm) {
|
||||
* Delete Scorm tracks for selected users
|
||||
*
|
||||
* @param array $attemptids list of attempts that need to be deleted
|
||||
* @param int $scorm instance
|
||||
* @param stdClass $scorm instance
|
||||
*
|
||||
* return bool true deleted all responses, false failed deleting an attempt - stopped here
|
||||
* @return bool true deleted all responses, false failed deleting an attempt - stopped here
|
||||
*/
|
||||
function scorm_delete_responses($attemptids, $scorm) {
|
||||
if (!is_array($attemptids) || empty($attemptids)) {
|
||||
@ -1302,15 +1302,27 @@ function scorm_delete_responses($attemptids, $scorm) {
|
||||
* Delete Scorm tracks for selected users
|
||||
*
|
||||
* @param int $userid ID of User
|
||||
* @param int $scormid ID of Scorm
|
||||
* @param stdClass $scorm Scorm object
|
||||
* @param int $attemptid user attempt that need to be deleted
|
||||
*
|
||||
* return bool true suceeded
|
||||
* @return bool true suceeded
|
||||
*/
|
||||
function scorm_delete_attempt($userid, $scorm, $attemptid) {
|
||||
global $DB;
|
||||
|
||||
$DB->delete_records('scorm_scoes_track', array('userid' => $userid, 'scormid' => $scorm->id, 'attempt' => $attemptid));
|
||||
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
|
||||
|
||||
// Trigger instances list viewed event.
|
||||
$event = \mod_scorm\event\attempt_deleted::create(array(
|
||||
'other' => array('attemptid' => $attemptid),
|
||||
'context' => context_module::instance($cm->instance),
|
||||
'relateduserid' => $userid
|
||||
));
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->trigger();
|
||||
|
||||
include_once('lib.php');
|
||||
scorm_update_grades($scorm, $userid, true);
|
||||
return true;
|
||||
|
@ -148,9 +148,6 @@ if ($scorm->lastattemptlock == 1 && $result->attemptleft == 0) {
|
||||
exit;
|
||||
}
|
||||
|
||||
add_to_log($course->id, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id);
|
||||
|
||||
|
||||
$scoidstr = '&scoid='.$sco->id;
|
||||
$modestr = '&mode='.$mode;
|
||||
|
||||
|
@ -59,7 +59,16 @@ if (count($reportlist) < 1) {
|
||||
print_error('erroraccessingreport', 'scorm');
|
||||
}
|
||||
|
||||
add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id, $cm->id);
|
||||
// Trigger a report viewed event.
|
||||
$event = \mod_scorm\event\report_viewed::create(array(
|
||||
'objectid' => $scorm->id,
|
||||
'context' => $contextmodule,
|
||||
'other' => array('mode' => $mode)
|
||||
));
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->trigger();
|
||||
|
||||
$userdata = null;
|
||||
if (!empty($download)) {
|
||||
$noheader = true;
|
||||
|
@ -43,7 +43,6 @@ class scorm_basic_report extends scorm_default_report {
|
||||
|
||||
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
|
||||
if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
|
||||
add_to_log($course->id, 'scorm', 'delete attempts', 'report.php?id=' . $cm->id, implode(",", $attemptids), $cm->id);
|
||||
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ class scorm_interactions_report extends scorm_default_report {
|
||||
|
||||
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
|
||||
if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
|
||||
add_to_log($course->id, 'scorm', 'delete attempts', 'report.php?id=' . $cm->id, implode(",", $attemptids), $cm->id);
|
||||
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ class scorm_objectives_report extends scorm_default_report {
|
||||
|
||||
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
|
||||
if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
|
||||
add_to_log($course->id, 'scorm', 'delete attempts', 'report.php?id=' . $cm->id, implode(",", $attemptids), $cm->id);
|
||||
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,15 @@ require_login($course, false, $cm);
|
||||
$contextmodule = context_module::instance($cm->id);
|
||||
require_capability('mod/scorm:viewreport', $contextmodule);
|
||||
|
||||
add_to_log($course->id, 'scorm', 'userreport', 'userreport.php?id='.$id, $scorm->id, $id);
|
||||
// Trigger a user report viewed event.
|
||||
$event = \mod_scorm\event\user_report_viewed::create(array(
|
||||
'context' => $contextmodule,
|
||||
'relateduserid' => $userid,
|
||||
'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id)
|
||||
));
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->trigger();
|
||||
|
||||
// Print the page header.
|
||||
$strreport = get_string('report', 'scorm');
|
||||
|
@ -53,8 +53,15 @@ require_login($course, false, $cm);
|
||||
$contextmodule = context_module::instance($cm->id);
|
||||
require_capability('mod/scorm:viewreport', $contextmodule);
|
||||
|
||||
add_to_log($course->id, 'scorm', 'userreportinteractions', 'userreportinteractions.php?id='.$cm->id, $scorm->id, $cm->id);
|
||||
|
||||
// Trigger a user interactions viewed event.
|
||||
$event = \mod_scorm\event\interactions_viewed::create(array(
|
||||
'context' => $contextmodule,
|
||||
'relateduserid' => $userid,
|
||||
'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id)
|
||||
));
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->trigger();
|
||||
|
||||
$trackdata = $DB->get_records('scorm_scoes_track', array('userid' => $user->id, 'scormid' => $scorm->id,
|
||||
'attempt' => $attempt));
|
||||
|
@ -51,7 +51,15 @@ require_login($course, false, $cm);
|
||||
$contextmodule = context_module::instance($cm->id);
|
||||
require_capability('mod/scorm:viewreport', $contextmodule);
|
||||
|
||||
add_to_log($course->id, 'scorm', 'userreporttracks', 'userreporttracks.php?id='.$id, $scorm->id, $id);
|
||||
// Trigger a tracks viewed event.
|
||||
$event = \mod_scorm\event\tracks_viewed::create(array(
|
||||
'context' => $contextmodule,
|
||||
'relateduserid' => $userid,
|
||||
'other' => array('attemptid' => $attempt, 'instanceid' => $scorm->id, 'scoid' => $scoid)
|
||||
));
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->trigger();
|
||||
|
||||
// Print the page header.
|
||||
$strreport = get_string('report', 'scorm');
|
||||
|
@ -113,7 +113,14 @@ $strscorm = get_string("modulename", "scorm");
|
||||
$shortname = format_string($course->shortname, true, array('context' => $context));
|
||||
$pagetitle = strip_tags($shortname.': '.format_string($scorm->name));
|
||||
|
||||
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
|
||||
// Trigger module viewed event.
|
||||
$event = \mod_scorm\event\course_module_viewed::create(array(
|
||||
'objectid' => $scorm->id,
|
||||
'context' => $contextmodule,
|
||||
));
|
||||
$event->add_record_snapshot('scorm', $scorm);
|
||||
$event->add_record_snapshot('course_modules', $cm);
|
||||
$event->trigger();
|
||||
|
||||
if (empty($launch) && (has_capability('mod/scorm:skipview', $contextmodule))) {
|
||||
scorm_simple_play($scorm, $USER, $contextmodule, $cm->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user