From 45faf15dfdc903e10baab81bd2c2c7437d4beb81 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Wed, 4 Dec 2013 16:25:19 +0800 Subject: [PATCH] MDL-43044 events: Deprecate and remove code duplication from instances_list_viewed events --- lib/upgrade.txt | 5 ++ .../course_module_instance_list_viewed.php | 37 ++++++++++ .../classes/event/instances_list_viewed.php | 73 ------------------ mod/book/index.php | 2 +- mod/book/lang/en/book.php | 1 - .../course_module_instance_list_viewed.php | 37 ++++++++++ .../classes/event/instances_list_viewed.php | 73 ------------------ mod/chat/index.php | 2 +- mod/chat/lang/en/chat.php | 1 - .../course_module_instance_list_viewed.php | 37 ++++++++++ .../classes/event/instances_list_viewed.php | 72 ------------------ mod/choice/index.php | 2 +- mod/choice/lang/en/choice.php | 1 - .../course_module_instance_list_viewed.php | 37 ++++++++++ .../classes/event/instances_list_viewed.php | 74 ------------------- mod/feedback/index.php | 2 +- mod/feedback/lang/en/feedback.php | 1 - .../course_module_instance_list_viewed.php | 37 ++++++++++ .../classes/event/instances_list_viewed.php | 74 ------------------- mod/page/index.php | 2 +- mod/page/lang/en/page.php | 1 - 21 files changed, 195 insertions(+), 376 deletions(-) create mode 100644 mod/book/classes/event/course_module_instance_list_viewed.php delete mode 100644 mod/book/classes/event/instances_list_viewed.php create mode 100644 mod/chat/classes/event/course_module_instance_list_viewed.php delete mode 100644 mod/chat/classes/event/instances_list_viewed.php create mode 100644 mod/choice/classes/event/course_module_instance_list_viewed.php delete mode 100644 mod/choice/classes/event/instances_list_viewed.php create mode 100644 mod/feedback/classes/event/course_module_instance_list_viewed.php delete mode 100644 mod/feedback/classes/event/instances_list_viewed.php create mode 100644 mod/page/classes/event/course_module_instance_list_viewed.php delete mode 100644 mod/page/classes/event/instances_list_viewed.php diff --git a/lib/upgrade.txt b/lib/upgrade.txt index de4cde6759f..b720a863222 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -4,6 +4,11 @@ information provided here is intended especially for developers. === 2.7 === * Abstract class \core\event\course_module_instances_list_viewed is deprecated now, use \core\event\instances_list_viewed instead. +* mod_book\event\instances_list_viewed has been deprecated. Please use mod_book\event\course_module_instance_list_viewed instead. +* mod_chat\event\instances_list_viewed has been deprecated. Please use mod_chat\event\course_module_instance_list_viewed instead. +* mod_choice\event\instances_list_viewed has been deprecated. Please use mod_choice\event\course_module_instance_list_viewed instead. +* mod_feedback\event\instances_list_viewed has been deprecated. Please use mod_feedback\event\course_module_instance_list_viewed instead. +* mod_page\event\instances_list_viewed has been deprecated. Please use mod_page\event\course_module_instance_list_viewed instead. === 2.6 === diff --git a/mod/book/classes/event/course_module_instance_list_viewed.php b/mod/book/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 00000000000..29ddf51b47a --- /dev/null +++ b/mod/book/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,37 @@ +. + +/** + * mod_book course module instance list viewed event. + * + * @package mod_book + * @copyright 2013 Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_book\event; +defined('MOODLE_INTERNAL') || die(); + +/** + * mod_book course module instance list viewed event class. + * + * @package mod_book + * @copyright 2013 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { +} + diff --git a/mod/book/classes/event/instances_list_viewed.php b/mod/book/classes/event/instances_list_viewed.php deleted file mode 100644 index 3630e41b714..00000000000 --- a/mod/book/classes/event/instances_list_viewed.php +++ /dev/null @@ -1,73 +0,0 @@ -. - -/** - * mod_book instances list viewed event. - * - * @package mod_book - * @copyright 2013 Frédéric Massart - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace mod_book\event; -defined('MOODLE_INTERNAL') || die(); - -/** - * mod_book instances list viewed event class. - * - * @package mod_book - * @copyright 2013 Frédéric Massart - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class instances_list_viewed extends \core\event\course_module_instances_list_viewed { - - /** - * Returns description of what happened. - * - * @return string - */ - public function get_description() { - return "User $this->userid viewed the list of book activities in the course $this->courseid."; - } - - /** - * Return the legacy event log data. - * - * @return array|null - */ - protected function get_legacy_logdata() { - return array($this->courseid, 'book', 'view all', 'index.php?id=' . $this->courseid, ''); - } - - /** - * Return localised event name. - * - * @return string - */ - public static function get_name() { - return get_string('event_instances_list_viewed', 'mod_book'); - } - - /** - * Get URL related to the action - * - * @return \moodle_url - */ - public function get_url() { - return new \moodle_url('/mod/book/index.php', array('id' => $this->courseid)); - } - -} diff --git a/mod/book/index.php b/mod/book/index.php index 44673916866..027f2355284 100644 --- a/mod/book/index.php +++ b/mod/book/index.php @@ -50,7 +50,7 @@ echo $OUTPUT->header(); $params = array( 'context' => context_course::instance($course->id) ); -$event = \mod_book\event\instances_list_viewed::create($params); +$event = \mod_book\event\course_module_instance_list_viewed::create($params); $event->trigger(); // Get all the appropriate data diff --git a/mod/book/lang/en/book.php b/mod/book/lang/en/book.php index f35e4e2b399..33e96cda6b9 100644 --- a/mod/book/lang/en/book.php +++ b/mod/book/lang/en/book.php @@ -50,7 +50,6 @@ $string['event_chapter_created'] = 'Chapter created'; $string['event_chapter_deleted'] = 'Chapter deleted'; $string['event_chapter_updated'] = 'Chapter updated'; $string['event_chapter_viewed'] = 'Chapter viewed'; -$string['event_instances_list_viewed'] = 'Instances list viewed'; $string['subchapter'] = 'Subchapter'; $string['nocontent'] = 'No content has been added to this book yet.'; $string['numbering'] = 'Chapter formatting'; diff --git a/mod/chat/classes/event/course_module_instance_list_viewed.php b/mod/chat/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 00000000000..c7b3b36aa7d --- /dev/null +++ b/mod/chat/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,37 @@ +. + +/** + * mod_chat course module instance list viewed event. + * + * @package mod_chat + * @copyright 2013 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_chat\event; +defined('MOODLE_INTERNAL') || die(); + +/** + * mod_chat course module instance list viewed event class. + * + * @package mod_chat + * @copyright 2013 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { +} + diff --git a/mod/chat/classes/event/instances_list_viewed.php b/mod/chat/classes/event/instances_list_viewed.php deleted file mode 100644 index d6bcade461e..00000000000 --- a/mod/chat/classes/event/instances_list_viewed.php +++ /dev/null @@ -1,73 +0,0 @@ -. - -/** - * mod_chat instances list viewed event. - * - * @package mod_chat - * @copyright 2013 Frédéric Massart - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace mod_chat\event; -defined('MOODLE_INTERNAL') || die(); - -/** - * mod_chat instances list viewed event class. - * - * @package mod_chat - * @copyright 2013 Frédéric Massart - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class instances_list_viewed extends \core\event\course_module_instances_list_viewed { - - /** - * Returns description of what happened. - * - * @return string - */ - public function get_description() { - return "User $this->userid viewed the list of chat activities in the course $this->courseid."; - } - - /** - * Return the legacy event log data. - * - * @return array|null - */ - protected function get_legacy_logdata() { - return array($this->courseid, 'chat', 'view all', 'index.php?id=' . $this->courseid, ''); - } - - /** - * Return localised event name. - * - * @return string - */ - public static function get_name() { - return get_string('event_instances_list_viewed', 'mod_chat'); - } - - /** - * Get URL related to the action - * - * @return \moodle_url - */ - public function get_url() { - return new \moodle_url('/mod/chat/index.php', array('id' => $this->courseid)); - } - -} diff --git a/mod/chat/index.php b/mod/chat/index.php index 9b8b855bfc3..35a43aa7d23 100644 --- a/mod/chat/index.php +++ b/mod/chat/index.php @@ -17,7 +17,7 @@ $PAGE->set_pagelayout('incourse'); $params = array( 'context' => context_course::instance($id) ); -$event = \mod_chat\event\instances_list_viewed::create($params); +$event = \mod_chat\event\course_module_instance_list_viewed::create($params); $event->trigger(); /// Get all required strings diff --git a/mod/chat/lang/en/chat.php b/mod/chat/lang/en/chat.php index 139ef6d4978..3d03baf4e60 100644 --- a/mod/chat/lang/en/chat.php +++ b/mod/chat/lang/en/chat.php @@ -64,7 +64,6 @@ $string['chatreport'] = 'Chat sessions'; $string['chat:talk'] = 'Talk in a chat'; $string['chattime'] = 'Next chat time'; $string['entermessage'] = "Enter your message"; -$string['event_instances_list_viewed'] = 'Instances list viewed'; $string['event_message_sent'] = 'Message sent'; $string['event_sessions_viewed'] = 'Sessions viewed'; $string['idle'] = 'Idle'; diff --git a/mod/choice/classes/event/course_module_instance_list_viewed.php b/mod/choice/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 00000000000..6174c86cefb --- /dev/null +++ b/mod/choice/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,37 @@ +. + +/** + * mod_choice course module instance list viewed event. + * + * @package mod_choice + * @copyright 2013 Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_choice\event; +defined('MOODLE_INTERNAL') || die(); + +/** + * mod_choice course module instance list event class. + * + * @package mod_choice + * @copyright 2013 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { +} + diff --git a/mod/choice/classes/event/instances_list_viewed.php b/mod/choice/classes/event/instances_list_viewed.php deleted file mode 100644 index 165d58f5207..00000000000 --- a/mod/choice/classes/event/instances_list_viewed.php +++ /dev/null @@ -1,72 +0,0 @@ -. - -/** - * Course module instances list_viewed event. - * - * @package mod_choice - * @copyright 2013 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace mod_choice\event; -defined('MOODLE_INTERNAL') || die(); - -/** - * Course module instances list viewed event class for mod_choice. - * - * @package mod_choice - * @copyright 2013 Adrian Greeve - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class instances_list_viewed extends \core\event\course_module_instances_list_viewed { - - /** - * Returns description of what happened. - * - * @return string - */ - public function get_description() { - return "User $this->userid viewed the list of choice activities in the course $this->courseid."; - } - - /** - * Return the legacy event log data. - * - * @return array - */ - protected function get_legacy_logdata() { - return array($this->courseid, 'choice', 'view all', 'index.php?id=' . $this->courseid, ''); - } - - /** - * Return localised event name. - * - * @return string - */ - public static function get_name() { - return get_string('event_instances_list_viewed', 'mod_choice'); - } - - /** - * Get URL related to the action - * - * @return \moodle_url - */ - public function get_url() { - return new \moodle_url('/mod/choice/index.php', array('id' => $this->courseid)); - } -} diff --git a/mod/choice/index.php b/mod/choice/index.php index 471ff2253db..07e42340626 100644 --- a/mod/choice/index.php +++ b/mod/choice/index.php @@ -15,7 +15,7 @@ $PAGE->set_pagelayout('incourse'); $eventdata = array('context' => context_course::instance($id)); - $event = \mod_choice\event\instances_list_viewed::create($eventdata); + $event = \mod_choice\event\course_module_instance_list_viewed::create($eventdata); $event->trigger(); $strchoice = get_string("modulename", "choice"); diff --git a/mod/choice/lang/en/choice.php b/mod/choice/lang/en/choice.php index 3bd8291dd2d..fb350ed3da0 100644 --- a/mod/choice/lang/en/choice.php +++ b/mod/choice/lang/en/choice.php @@ -33,7 +33,6 @@ $string['displayvertical'] = 'Display vertically'; $string['event_answer_created'] = 'Choice made'; $string['event_answer_updated'] = 'Choice updated'; $string['event_report_viewed'] = 'Choice report viewed'; -$string['event_instances_list_viewed'] = 'Instances list viewed'; $string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available'; $string['atleastoneoption'] = 'You need to provide at least one possible answer.'; $string['full'] = '(Full)'; diff --git a/mod/feedback/classes/event/course_module_instance_list_viewed.php b/mod/feedback/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 00000000000..a744632b52f --- /dev/null +++ b/mod/feedback/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,37 @@ +. + +/** + * mod_feedback course module instance list viewed event. + * + * @package mod_feedback + * @copyright 2013 Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_feedback\event; +defined('MOODLE_INTERNAL') || die(); + +/** + * mod_feedback course module instance list event class. + * + * @package mod_feedback + * @copyright 2013 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { +} + diff --git a/mod/feedback/classes/event/instances_list_viewed.php b/mod/feedback/classes/event/instances_list_viewed.php deleted file mode 100644 index 88a2d739df8..00000000000 --- a/mod/feedback/classes/event/instances_list_viewed.php +++ /dev/null @@ -1,74 +0,0 @@ -. - -/** - * mod_feedback instances list viewed event. - * - * @package mod_feedback - * @copyright 2013 Ankit Agarwal - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace mod_feedback\event; -defined('MOODLE_INTERNAL') || die(); - -/** - * mod_feedback instances list viewed event class. - * - * @package mod_feedback - * @copyright 2013 Ankit Agarwal - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class instances_list_viewed extends \core\event\course_module_instances_list_viewed { - - /** - * Returns description of what happened. - * - * @return string - */ - public function get_description() { - return "User $this->userid viewed the list of feedback activities in the course $this->courseid."; - } - - /** - * Return the legacy event log data. - * - * @return array - */ - protected function get_legacy_logdata() { - return array($this->courseid, 'feedback', 'view all', 'index.php?id=' . $this->courseid, ''); - } - - /** - * Return localised event name. - * - * @return string - */ - public static function get_name() { - return get_string('eventinstanceslistviewed', 'mod_feedback'); - } - - /** - * Get URL related to the action - * - * @return \moodle_url - */ - public function get_url() { - return new \moodle_url('/mod/feedback/index.php', array('id' => $this->courseid)); - } - -} - diff --git a/mod/feedback/index.php b/mod/feedback/index.php index fc2b7d0264f..948e1365765 100644 --- a/mod/feedback/index.php +++ b/mod/feedback/index.php @@ -41,7 +41,7 @@ require_login($course); $PAGE->set_pagelayout('incourse'); // Trigger instances list viewed event. -$event = \mod_feedback\event\instances_list_viewed::create(array('context' => $context)); +$event = \mod_feedback\event\course_module_instance_list_viewed::create(array('context' => $context)); $event->trigger(); /// Print the page header diff --git a/mod/feedback/lang/en/feedback.php b/mod/feedback/lang/en/feedback.php index a98d4957f03..077836e7973 100644 --- a/mod/feedback/lang/en/feedback.php +++ b/mod/feedback/lang/en/feedback.php @@ -104,7 +104,6 @@ $string['export_questions'] = 'Export questions'; $string['export_to_excel'] = 'Export to Excel'; $string['eventresponsedeleted'] = 'Response deleted'; $string['eventresponsesubmitted'] = 'Response submitted'; -$string['eventinstanceslistviewed'] = 'Instances list viewed'; $string['feedback:addinstance'] = 'Add a new feedback'; $string['feedbackclose'] = 'Allow answers to'; $string['feedback:complete'] = 'Complete a feedback'; diff --git a/mod/page/classes/event/course_module_instance_list_viewed.php b/mod/page/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 00000000000..52008df0515 --- /dev/null +++ b/mod/page/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,37 @@ +. + +/** + * mod_page course module instance list viewed event. + * + * @package mod_page + * @copyright 2013 Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace mod_page\event; +defined('MOODLE_INTERNAL') || die(); + +/** + * mod_page course module instance list event class. + * + * @package mod_page + * @copyright 2013 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { +} + diff --git a/mod/page/classes/event/instances_list_viewed.php b/mod/page/classes/event/instances_list_viewed.php deleted file mode 100644 index 342a1792937..00000000000 --- a/mod/page/classes/event/instances_list_viewed.php +++ /dev/null @@ -1,74 +0,0 @@ -. - -/** - * mod_page instances list viewed event. - * - * @package mod_page - * @copyright 2013 Ankit Agarwal - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace mod_page\event; -defined('MOODLE_INTERNAL') || die(); - -/** - * mod_page instances list viewed event class. - * - * @package mod_page - * @copyright 2013 Ankit Agarwal - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class instances_list_viewed extends \core\event\course_module_instances_list_viewed { - - /** - * Returns description of what happened. - * - * @return string - */ - public function get_description() { - return "User $this->userid viewed the list of page activities in the course $this->courseid."; - } - - /** - * Return the legacy event log data. - * - * @return array - */ - protected function get_legacy_logdata() { - return array($this->courseid, 'page', 'view all', 'index.php?id=' . $this->courseid, ''); - } - - /** - * Return localised event name. - * - * @return string - */ - public static function get_name() { - return get_string('eventinstanceslistviewed', 'mod_page'); - } - - /** - * Get URL related to the action - * - * @return \moodle_url - */ - public function get_url() { - return new \moodle_url('/mod/page/index.php', array('id' => $this->courseid)); - } - -} - diff --git a/mod/page/index.php b/mod/page/index.php index e42ff0dc1bb..eb2676a5eb4 100644 --- a/mod/page/index.php +++ b/mod/page/index.php @@ -34,7 +34,7 @@ require_course_login($course, true); $PAGE->set_pagelayout('incourse'); // Trigger instances list viewed event. -$event = \mod_page\event\instances_list_viewed::create(array('context' => context_course::instance($course->id))); +$event = \mod_page\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id))); $event->trigger(); $strpage = get_string('modulename', 'page'); diff --git a/mod/page/lang/en/page.php b/mod/page/lang/en/page.php index 9c07a15e655..605f664af87 100644 --- a/mod/page/lang/en/page.php +++ b/mod/page/lang/en/page.php @@ -31,7 +31,6 @@ $string['displayoptions'] = 'Available display options'; $string['displayselect'] = 'Display'; $string['displayselectexplain'] = 'Select display type.'; $string['legacyfiles'] = 'Migration of old course file'; -$string['eventinstanceslistviewed'] = 'Page instances list viewed'; $string['legacyfilesactive'] = 'Active'; $string['legacyfilesdone'] = 'Finished'; $string['modulename'] = 'Page';