Skip to content

Commit

Permalink
MDL-36003 events: Added events for viewing grade reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Jun 23, 2014
1 parent 7784c3a commit 06dc1e7
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 1 deletion.
47 changes: 47 additions & 0 deletions grade/report/grader/classes/event/report_viewed.php
@@ -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');
}
}
8 changes: 8 additions & 0 deletions grade/report/grader/index.php
Expand Up @@ -125,6 +125,14 @@

$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);

Expand Down
1 change: 1 addition & 0 deletions grade/report/grader/lang/en/gradereport_grader.php
Expand Up @@ -28,6 +28,7 @@
$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';
Expand Down
47 changes: 47 additions & 0 deletions grade/report/outcomes/classes/event/report_viewed.php
@@ -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');
}
}
8 changes: 7 additions & 1 deletion grade/report/outcomes/index.php
Expand Up @@ -170,7 +170,13 @@
$row++;
}


$event = \gradereport_outcomes\event\report_viewed::create(
array(
'context' => $context,
'courseid' => $courseid,
)
);
$event->trigger();

$html .= '</table>';

Expand Down
1 change: 1 addition & 0 deletions grade/report/outcomes/lang/en/gradereport_outcomes.php
Expand Up @@ -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 changes: 60 additions & 0 deletions grade/report/overview/classes/event/report_viewed.php
@@ -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.');
}
}
}
9 changes: 9 additions & 0 deletions grade/report/overview/index.php
Expand Up @@ -148,6 +148,15 @@
}
}

$event = \gradereport_overview\event\report_viewed::create(
array(
'context' => $context,
'courseid' => $courseid,
'relateduserid' => $userid,
)
);
$event->trigger();

echo $OUTPUT->footer();


1 change: 1 addition & 0 deletions grade/report/overview/lang/en/gradereport_overview.php
Expand Up @@ -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 changes: 60 additions & 0 deletions grade/report/user/classes/event/report_viewed.php
@@ -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.');
}
}
}
9 changes: 9 additions & 0 deletions grade/report/user/index.php
Expand Up @@ -164,4 +164,13 @@
}
}

$event = \gradereport_user\event\report_viewed::create(
array(
'context' => $context,
'courseid' => $courseid,
'relateduserid' => $userid,
)
);
$event->trigger();

echo $OUTPUT->footer();
1 change: 1 addition & 0 deletions grade/report/user/lang/en/gradereport_user.php
Expand Up @@ -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.';
1 change: 1 addition & 0 deletions lang/en/grades.php
Expand Up @@ -186,6 +186,7 @@
$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.';
Expand Down

0 comments on commit 06dc1e7

Please sign in to comment.