mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-36003 events: Added events for viewing grade reports.
This commit is contained in:
parent
7784c3ad18
commit
06dc1e7f56
47
grade/report/grader/classes/event/report_viewed.php
Normal file
47
grade/report/grader/classes/event/report_viewed.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
@ -125,6 +125,14 @@ if (!empty($target) && !empty($action) && confirm_sesskey()) {
|
||||
|
||||
$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);
|
||||
|
||||
|
@ -28,6 +28,7 @@ $string['ajaxerror'] = 'Error';
|
||||
$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';
|
||||
|
47
grade/report/outcomes/classes/event/report_viewed.php
Normal file
47
grade/report/outcomes/classes/event/report_viewed.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
@ -170,7 +170,13 @@ foreach ($report_info as $outcomeid => $outcomedata) {
|
||||
$row++;
|
||||
}
|
||||
|
||||
|
||||
$event = \gradereport_outcomes\event\report_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'courseid' => $courseid,
|
||||
)
|
||||
);
|
||||
$event->trigger();
|
||||
|
||||
$html .= '</table>';
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
$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';
|
||||
|
60
grade/report/overview/classes/event/report_viewed.php
Normal file
60
grade/report/overview/classes/event/report_viewed.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.');
|
||||
}
|
||||
}
|
||||
}
|
@ -148,6 +148,15 @@ if (has_capability('moodle/grade:viewall', $systemcontext)) { //Admins will see
|
||||
}
|
||||
}
|
||||
|
||||
$event = \gradereport_overview\event\report_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'courseid' => $courseid,
|
||||
'relateduserid' => $userid,
|
||||
)
|
||||
);
|
||||
$event->trigger();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
|
@ -22,5 +22,6 @@
|
||||
* @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';
|
||||
|
60
grade/report/user/classes/event/report_viewed.php
Normal file
60
grade/report/user/classes/event/report_viewed.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?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.');
|
||||
}
|
||||
}
|
||||
}
|
@ -164,4 +164,13 @@ if (has_capability('moodle/grade:viewall', $context)) { //Teachers will see all
|
||||
}
|
||||
}
|
||||
|
||||
$event = \gradereport_user\event\report_viewed::create(
|
||||
array(
|
||||
'context' => $context,
|
||||
'courseid' => $courseid,
|
||||
'relateduserid' => $userid,
|
||||
)
|
||||
);
|
||||
$event->trigger();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -22,6 +22,7 @@
|
||||
* @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.';
|
||||
|
@ -186,6 +186,7 @@ $string['errorupdatinggradecategoryaggregateoutcomes'] = 'Error updating the "In
|
||||
$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.';
|
||||
|
89
lib/classes/event/grade_report_viewed.php
Normal file
89
lib/classes/event/grade_report_viewed.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
@ -25,6 +25,8 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(__DIR__.'/fixtures/event_fixtures.php');
|
||||
|
||||
class core_events_testcase extends advanced_testcase {
|
||||
|
||||
/**
|
||||
@ -338,4 +340,35 @@ 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);
|
||||
}
|
||||
}
|
||||
|
6
lib/tests/fixtures/event_fixtures.php
vendored
6
lib/tests/fixtures/event_fixtures.php
vendored
@ -250,6 +250,12 @@ class course_module_viewed extends \core\event\course_module_viewed {
|
||||
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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user