MDL-47782 tool_monitor: Added context column on rule management page.
authorSimey Lameze <simey@moodle.com>
Fri, 24 Oct 2014 03:55:07 +0000 (11:55 +0800)
committerSimey Lameze <simey@moodle.com>
Fri, 24 Oct 2014 07:41:45 +0000 (15:41 +0800)
AMOS BEGIN
CPY [context,message],[context,tool_monitor]
AMOS END

admin/tool/monitor/classes/output/managerules/renderable.php
admin/tool/monitor/lang/en/tool_monitor.php
admin/tool/monitor/tests/behat/rule.feature

index 2c74245..59d0690 100644 (file)
@@ -64,11 +64,13 @@ class renderable extends \table_sql implements \renderable {
     public function __construct($uniqueid, \moodle_url $url, $courseid = 0, $perpage = 100) {
         parent::__construct($uniqueid);
 
+        $this->set_attribute('id', 'toolmonitorrules_table');
         $this->set_attribute('class', 'toolmonitor managerules generaltable generalbox');
-        $this->define_columns(array('name', 'description', 'plugin', 'eventname', 'filters', 'manage'));
+        $this->define_columns(array('name', 'description', 'context', 'plugin', 'eventname', 'filters', 'manage'));
         $this->define_headers(array(
                 get_string('name'),
                 get_string('description'),
+                get_string('context', 'tool_monitor'),
                 get_string('plugin'),
                 get_string('eventname'),
                 get_string('frequency', 'tool_monitor'),
@@ -198,4 +200,15 @@ class renderable extends \table_sql implements \renderable {
             $this->initialbars($total > $pagesize);
         }
     }
+
+    /**
+     * Generate content for context column.
+     *
+     * @param \tool_monitor\rule $rule rule object
+     *
+     * @return string html used to display the context column field.
+     */
+    public function col_context(\tool_monitor\rule $rule) {
+        return ($rule->courseid == 0) ? get_string('system', 'tool_monitor') : get_string('course');
+    }
 }
index bfac799..ec9f050 100644 (file)
@@ -28,6 +28,7 @@ $string['addrule'] = 'Add a new rule';
 $string['allevents'] = 'All events';
 $string['allmodules'] = 'All modules';
 $string['core'] = 'Core';
+$string['context'] = 'Context';
 $string['customisefilters'] = 'Select the frequency of the events';
 $string['customisemessage'] = 'Customise the notification message';
 $string['currentsubscriptions'] = 'Your current subscriptions';
@@ -84,6 +85,7 @@ $string['subcreatesuccess'] = "Subscription successfully created";
 $string['subdeletesuccess'] = "Subscription successfully removed";
 $string['subhelp'] = 'Subscription details';
 $string['subhelp_help'] = 'This subscription listens for when the event \'{$a->eventname}\' has been triggered in \'{$a->moduleinstance}\' {$a->frequency} time(s) in {$a->minutes} minute(s).';
+$string['system'] = "System";
 $string['title'] = '{$a->coursename} : {$a->reportname}';
 $string['monitor:managerules'] = 'Manage event monitor rules';
 $string['monitor:subscribe'] = 'Subscribe to event monitor rules';
index 80f74d3..33287a8 100644 (file)
@@ -55,7 +55,7 @@ Feature: tool_monitor_rule
       | minutes           | 1                                                 |
       | Message template  | The forum post was created. {modulelink}          |
     And   I press "Save changes"
-    Then  I should see "New rule"
+    Then  "New rule" row "Context" column of "toolmonitorrules_table" table should contain "Course"
     And   I should see "I want a rule to monitor posts created on a forum"
     And   I should see "Forum"
     And   I should see "Post created"
@@ -116,7 +116,7 @@ Feature: tool_monitor_rule
       | minutes           | 1                                                 |
       | Message template  | The forum post was created. {modulelink}          |
     And   I press "Save changes"
-    Then  I should see "New rule"
+    Then  "New rule" row "Context" column of "toolmonitorrules_table" table should contain "System"
     And   I should see "I want a rule to monitor posts created on a forum"
     And   I should see "Forum"
     And   I should see "Post created"