--- /dev/null
+<?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/>.
+
+/**
+ * Grader report viewed event.
+ *
+ * @package gradereport_grader
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace gradereport_grader\event;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Grader report viewed event class.
+ *
+ * @package gradereport_grader
+ * @since Moodle 2.8
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class report_viewed extends \core\event\grade_report_viewed {
+
+ /**
+ * Returns localised general event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('eventreportviewed', 'gradereport_grader');
+ }
+}
$reportname = get_string('pluginname', 'gradereport_grader');
+$event = \gradereport_grader\event\report_viewed::create(
+ array(
+ 'context' => $context,
+ 'courseid' => $courseid,
+ )
+);
+$event->trigger();
+
// Print header
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
$string['ajaxfailedupdate'] = 'Unable to update [1] for [2]';
$string['ajaxfieldchanged'] = 'The field you are currently editing has changed, would you like to use the updated value?';
$string['ajaxchoosescale'] = 'Choose';
+$string['eventreportviewed'] = 'Grader report viewed';
$string['grader:manage'] = 'Manage the grader report';
$string['grader:view'] = 'View the grader report';
$string['pluginname'] = 'Grader report';
--- /dev/null
+<?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/>.
+
+/**
+ * Outcomes report viewed event.
+ *
+ * @package gradereport_outcomes
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace gradereport_outcomes\event;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Outcomes report viewed event class.
+ *
+ * @package gradereport_outcomes
+ * @since Moodle 2.8
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class report_viewed extends \core\event\grade_report_viewed {
+
+ /**
+ * Returns localised general event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('eventreportviewed', 'gradereport_outcomes');
+ }
+}
$row++;
}
-
+$event = \gradereport_outcomes\event\report_viewed::create(
+ array(
+ 'context' => $context,
+ 'courseid' => $courseid,
+ )
+);
+$event->trigger();
$html .= '</table>';
$string['addoutcome'] = 'Add an outcome';
$string['courseoutcomes'] = 'Course outcomes';
$string['coursespecoutcome'] = 'Course outcomes';
+$string['eventreportviewed'] = 'Outcomes report viewed';
$string['pluginname'] = 'Outcomes report';
$string['outcomes:view'] = 'View the outcomes report';
$string['usedgradeitem'] = 'Number of grade items';
--- /dev/null
+<?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/>.
+
+/**
+ * Overview report viewed event.
+ *
+ * @package gradereport_overview
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace gradereport_overview\event;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Overview report viewed event class.
+ *
+ * @package gradereport_overview
+ * @since Moodle 2.8
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class report_viewed extends \core\event\grade_report_viewed {
+
+ /**
+ * Returns localised general event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('eventreportviewed', 'gradereport_overview');
+ }
+
+ /**
+ * Custom validation.
+ *
+ * Throw \coding_exception notice in case of any problems.
+ */
+ protected function validate_data() {
+ parent::validate_data();
+
+ if (!isset($this->relateduserid)) {
+ throw new \coding_exception('The \'relateduserid\' value must be set.');
+ }
+ }
+}
}
}
+$event = \gradereport_overview\event\report_viewed::create(
+ array(
+ 'context' => $context,
+ 'courseid' => $courseid,
+ 'relateduserid' => $userid,
+ )
+);
+$event->trigger();
+
echo $OUTPUT->footer();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['eventreportviewed'] = 'Overview report viewed';
$string['pluginname'] = 'Overview report';
$string['overview:view'] = 'View the overview report';
--- /dev/null
+<?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/>.
+
+/**
+ * User report viewed event.
+ *
+ * @package gradereport_user
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace gradereport_user\event;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * User report viewed event class.
+ *
+ * @package gradereport_user
+ * @since Moodle 2.8
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class report_viewed extends \core\event\grade_report_viewed {
+
+ /**
+ * Returns localised general event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('eventreportviewed', 'gradereport_user');
+ }
+
+ /**
+ * Custom validation.
+ *
+ * Throw \coding_exception notice in case of any problems.
+ */
+ protected function validate_data() {
+ parent::validate_data();
+
+ if (!isset($this->relateduserid)) {
+ throw new \coding_exception('The \'relateduserid\' value must be set.');
+ }
+ }
+}
}
}
+$event = \gradereport_user\event\report_viewed::create(
+ array(
+ 'context' => $context,
+ 'courseid' => $courseid,
+ 'relateduserid' => $userid,
+ )
+);
+$event->trigger();
+
echo $OUTPUT->footer();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['eventreportviewed'] = 'User grade report viewed';
$string['pluginname'] = 'User report';
$string['user:view'] = 'View your own grade report';
$string['tablesummary'] = 'The table is arranged as a list of graded items including categories of graded items. When items are in a category they will be indicated as such.';
$string['errorupdatinggradecategoryaggregatesubcats'] = 'Error updating the "Aggregate including subcategories" setting of grade category ID {$a->id}';
$string['errorupdatinggradecategoryaggregation'] = 'Error updating the aggregation type of grade category ID {$a->id}';
$string['errorupdatinggradeitemaggregationcoef'] = 'Error updating the aggregation coefficient (weight or extra credit) of grade item ID {$a->id}';
+$string['eventgradeviewed'] = 'Grades were viewed in the gradebook';
$string['eventusergraded'] = 'User grade edited in gradebook';
$string['excluded'] = 'Excluded';
$string['excluded_help'] = 'If ticked, the grade will not be included in any aggregation.';
--- /dev/null
+<?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/>.
+
+/**
+ * Grade report viewed event.
+ *
+ * @package core
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace core\event;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Grade report viewed event class.
+ *
+ * @package core
+ * @since Moodle 2.8
+ * @copyright 2014 Adrian Greeve <adrian@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+abstract class grade_report_viewed extends base {
+
+ /** string $reporttype The report type being viewed. */
+ protected $reporttype;
+
+ /**
+ * Initialise the event data.
+ */
+ protected function init() {
+ $reporttype = explode('\\', $this->eventname);
+ $shorttype = explode('_', $reporttype[1]);
+ $this->reporttype = $shorttype[1];
+
+ $this->data['crud'] = 'r';
+ $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
+ }
+
+ /**
+ * Returns localised general event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('eventgradeviewed', 'grades');
+ }
+
+ /**
+ * Returns non-localised description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "The user with id '$this->userid' viewed the $this->reporttype report in the gradebook.";
+ }
+
+ /**
+ * Returns relevant URL.
+ * @return \moodle_url
+ */
+ public function get_url() {
+ $url = '/grade/report/' . $this->reporttype . '/index.php';
+ return new \moodle_url($url, array('id' => $this->courseid));
+ }
+
+ /**
+ * Custom validation.
+ *
+ * To be overwritten by child classes.
+ */
+ protected function validate_data() {
+ parent::validate_data();
+ }
+}
defined('MOODLE_INTERNAL') || die();
+require_once(__DIR__.'/fixtures/event_fixtures.php');
+
class core_events_testcase extends advanced_testcase {
/**
$this->assertEventLegacyLogData($expected, $event);
$this->assertEventContextNotUsed($event);
}
+
+ /**
+ * There is no API associated with this event, so we will just test standard features.
+ */
+ public function test_grade_viewed() {
+ $this->resetAfterTest();
+ $this->setAdminUser();
+
+ $user = $this->getDataGenerator()->create_user();
+ $course = $this->getDataGenerator()->create_course();
+ $coursecontext = context_course::instance($course->id);
+
+ $event = \core_tests\event\grade_report_viewed::create(
+ array(
+ 'context' => $coursecontext,
+ 'courseid' => $course->id,
+ 'userid' => $user->id,
+ )
+ );
+
+ // Trigger and capture the event.
+ $sink = $this->redirectEvents();
+ $event->trigger();
+ $events = $sink->get_events();
+ $event = reset($events);
+
+ $this->assertInstanceOf('\core\event\grade_report_viewed', $event);
+ $this->assertEquals($event->courseid, $course->id);
+ $this->assertEquals($event->userid, $user->id);
+ $this->assertEventContextNotUsed($event);
+ }
}
class course_module_viewed_noinit extends \core\event\course_module_viewed {
}
+/**
+ * Event for testing core\event\grade_report_viewed.
+ */
+class grade_report_viewed extends \core\event\grade_report_viewed {
+}
+
/**
* Event to test context used in event functions
*/