Skip to content
Permalink
Browse files

MDL-40052 events: Add content view events for reports

Includes:
* Add content view events for report_log
* Add content view events for report_loglive
* Add content view events for report_outline
* Add content view events for report_participation
* Add content view events for report_stats
  • Loading branch information...
ankitagarwal authored and damyon committed Aug 20, 2013
1 parent 5897483 commit bb0038074ecdf3cec392b2d4531d435a1086e62f
@@ -0,0 +1,35 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when some content in log report is viewed.
*
* @package report_log
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_log\event;
/**
* Event triggered, when some content in log report is viewed.
*
* @package report_log
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content_viewed extends \core\event\content_viewed {
}
@@ -67,7 +67,12 @@
}
}
add_to_log($course->id, 'course', 'report log', "report/log/graph.php?user=$user->id&id=$course->id&type=$type&date=$date", $course->id);
// Trigger a content view event.
$event = \report_log\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'log graph')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report log', "report/log/graph.php?user=$user->id&id=$course->id&type=$type&date=$date", $course->id));
$event->trigger();
$logs = array();
@@ -115,7 +115,12 @@
require_capability('report/log:view', $context);
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
// Trigger a content view event.
$event = \report_log\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'logs')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id));
$event->trigger();
if (!empty($page)) {
$strlogs = get_string('logs'). ": ". get_string('page', 'report_log', $page+1);
@@ -62,8 +62,6 @@
}
}
add_to_log($course->id, 'course', 'report log', "report/log/user.php?id=$user->id&course=$course->id&mode=$mode", $course->id);
$stractivityreport = get_string('activityreport');
$PAGE->set_pagelayout('admin');
@@ -72,6 +70,14 @@
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
$PAGE->set_title("$course->shortname: $stractivityreport");
$PAGE->set_heading($course->fullname);
// Trigger a content view event.
$event = \report_log\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'user logs')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report log', "report/log/user.php?id=$user->id&course=$course->id&mode=$mode", $course->id));
$event->trigger();
echo $OUTPUT->header();
if ($mode === 'today') {
@@ -0,0 +1,35 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when some content in loglive report is viewed.
*
* @package report_loglive
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_loglive\event;
/**
* Event triggered, when some content in loglive report is viewed.
*
* @package report_loglive
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content_viewed extends \core\event\content_viewed {
}
@@ -48,8 +48,6 @@
if ($inpopup) {
session_get_instance()->write_close();
add_to_log($course->id, 'course', 'report live', "report/loglive/index.php?id=$course->id", $course->id);
$date = time() - 3600;
$url = new moodle_url('/report/loglive/index.php', array('id'=>$course->id, 'user'=>0, 'date'=>$date, 'inpopup'=>1));
@@ -65,6 +63,13 @@
$PAGE->set_heading($strlivelogs);
echo $OUTPUT->header();
// Trigger a content view event.
$event = \report_loglive\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'loglive')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report live', "report/loglive/index.php?id=$course->id", $course->id));
$event->trigger();
print_log($course, 0, $date, "l.time DESC", $page, 500, $url);
echo $OUTPUT->footer();
@@ -0,0 +1,35 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when some content in outline report is viewed.
*
* @package report_outline
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_outline\event;
/**
* Event for when some content in outline report is viewed.
*
* @package report_outline
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content_viewed extends \core\event\content_viewed {
}
@@ -37,7 +37,12 @@
$context = context_course::instance($course->id);
require_capability('report/outline:view', $context);
add_to_log($course->id, 'course', 'report outline', "report/outline/index.php?id=$course->id", $course->id);
// Trigger a content view event.
$event = \report_outline\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'outline')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report outline', "report/outline/index.php?id=$course->id", $course->id));
$event->trigger();
$showlastaccess = true;
$hiddenfields = explode(',', $CFG->hiddenuserfields);
@@ -53,7 +53,12 @@
require_capability('report/outline:view', $coursecontext);
}
add_to_log($course->id, 'course', 'report outline', "report/outline/user.php?id=$user->id&course=$course->id&mode=$mode", $course->id);
// Trigger a content view event.
$event = \report_outline\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'user outline')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report outline', "report/outline/user.php?id=$user->id&course=$course->id&mode=$mode", $course->id));
$event->trigger();
$stractivityreport = get_string('activityreport');
@@ -0,0 +1,35 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when some content in participation report is viewed.
*
* @package report_participation
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_participation\event;
/**
* Event triggered, when some content in participation report is viewed.
*
* @package report_participation
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content_viewed extends \core\event\content_viewed {
}
@@ -63,8 +63,6 @@
$context = context_course::instance($course->id);
require_capability('report/participation:view', $context);
add_to_log($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->id);
$strparticipation = get_string('participationreport');
$strviews = get_string('views');
$strposts = get_string('posts');
@@ -84,6 +82,13 @@
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
// Trigger a content view event.
$event = \report_participation\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'participants')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->id));
$event->trigger();
$modinfo = get_fast_modinfo($course);
$modules = $DB->get_records_select('modules', "visible = 1", null, 'name ASC');
@@ -0,0 +1,35 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when some content in stats report is viewed.
*
* @package report_stats
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_stats\event;
/**
* Event triggered, when some content in stats report is viewed.
*
* @package report_stats
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class content_viewed extends \core\event\content_viewed {
}
@@ -62,7 +62,12 @@
require_capability('report/stats:view', $coursecontext);
}
add_to_log($course->id, 'course', 'report stats', "report/stats/graph.php?userid=$userid&id=$course->id&mode=$mode&roleid=$roleid", $course->id);
// Trigger a content view event.
$event = \report_stats\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'stats graph')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report stats', "report/stats/graph.php?userid=$userid&id=$course->id&mode=$mode&roleid=$roleid", $course->id));
$event->trigger();
stats_check_uptodate($course->id);
@@ -67,7 +67,12 @@
'mode' => $mode,
'userid' => $userid)));
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
// Trigger a content view event.
$event = \report_stats\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'stats')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id));
$event->trigger();
stats_check_uptodate($course->id);
if ($course->id == SITEID) {
@@ -49,8 +49,6 @@
error('Can not access user statistics report');
}
add_to_log($course->id, 'course', 'report stats', "report/stats/user.php?id=$user->id&course=$course->id", $course->id);
$stractivityreport = get_string('activityreport');
$PAGE->set_pagelayout('admin');
@@ -61,6 +59,12 @@
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
// Trigger a content view event.
$event = \report_stats\event\content_viewed::create(array('courseid' => $course->id,
'other' => array('content' => 'user stats')));
$event->set_page_detail();
$event->set_legacy_logdata(array($course->id, 'course', 'report stats', "report/stats/user.php?id=$user->id&course=$course->id", $course->id));
$event->trigger();
if (empty($CFG->enablestats)) {
print_error('statsdisable', 'error');

0 comments on commit bb00380

Please sign in to comment.
You can’t perform that action at this time.