diff --git a/report/log/classes/renderable.php b/report/log/classes/renderable.php index 8bdb8b4b5f1..f5f12fa9e42 100644 --- a/report/log/classes/renderable.php +++ b/report/log/classes/renderable.php @@ -286,7 +286,7 @@ class report_log_renderable implements renderable { 'r' => get_string('view'), 'u' => get_string('update'), 'd' => get_string('delete'), - '' => get_string('allchanges') + 'cud' => get_string('allchanges') ); return $actions; } diff --git a/report/log/classes/table_log.php b/report/log/classes/table_log.php index 58860ceb930..280162f278d 100644 --- a/report/log/classes/table_log.php +++ b/report/log/classes/table_log.php @@ -380,8 +380,9 @@ class report_log_table_log extends table_sql { $params['action'] = '%'.$action.'%'; } } else if (!empty($this->filterparams->action)) { - $sql = "crud = :crud"; - $params['crud'] = $this->filterparams->action; + list($sql, $params) = $DB->get_in_or_equal(preg_split('//', $this->filterparams->action), + SQL_PARAMS_NAMED, 'crud'); + $sql = "crud " . $sql; } else { // Add condition for all possible values of crud (to use db index). list($sql, $params) = $DB->get_in_or_equal(array('c', 'r', 'u', 'd'), diff --git a/report/log/tests/behat/filter_log_actions.feature b/report/log/tests/behat/filter_log_actions.feature new file mode 100644 index 00000000000..ac602ed8d57 --- /dev/null +++ b/report/log/tests/behat/filter_log_actions.feature @@ -0,0 +1,88 @@ +@report @report_log +Feature: In a report, admin can filter log data by action + In order to filter log data by action + As an admin + I need to view the logs and apply a filter + + Background: + Given the following "courses" exist: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And I log in as "admin" + And I am on site homepage + And I follow "Course 1" + And I turn editing mode on + # Create Action. + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test assignment 1 | + | Description | Offline text | + | assignsubmission_file_enabled | 0 | + And I follow "Course 1" + # View Action. + And I follow "Test assignment 1" + # Update Action. + And I navigate to "Edit settings" node in "Assignment administration" + And I press "Save and return to course" + # Delete Action. + And I delete "Test assignment 1" activity + And I log out + + Scenario: View only create actions. + Given I log in as "admin" + When I navigate to "Logs" node in "Site administration > Reports" + And I set the field "menumodaction" to "Create" + And I press "Get these logs" + Then I should see "Course module created" + And I should not see "Course module updated" + And I should not see "The status of the submission has been viewed." + And I should not see "Course module deleted" + + Scenario: View only update actions. + Given I log in as "admin" + When I navigate to "Logs" node in "Site administration > Reports" + And I set the field "menumodaction" to "Update" + And I press "Get these logs" + Then I should see "Course module updated" + And I should not see "Course module created" + And I should not see "The status of the submission has been viewed." + And I should not see "Course module deleted" + + Scenario: View only view actions. + Given I log in as "admin" + When I navigate to "Logs" node in "Site administration > Reports" + And I set the field "menumodaction" to "View" + And I press "Get these logs" + Then I should see "The status of the submission has been viewed." + And I should not see "Course module created" + And I should not see "Course module updated" + And I should not see "Course module deleted" + + Scenario: View only delete actions. + Given I log in as "admin" + When I navigate to "Logs" node in "Site administration > Reports" + And I set the field "menumodaction" to "Delete" + And I press "Get these logs" + Then I should see "Course module deleted" + And I should not see "Course module created" + And I should not see "Course module updated" + And I should not see "The status of the submission has been viewed." + + Scenario: View only changes. + Given I log in as "admin" + When I navigate to "Logs" node in "Site administration > Reports" + And I set the field "menumodaction" to "All changes" + And I press "Get these logs" + Then I should see "Course module deleted" + And I should see "Course module created" + And I should see "Course module updated" + And I should not see "The status of the submission has been viewed." + + Scenario: View all actions. + Given I log in as "admin" + When I navigate to "Logs" node in "Site administration > Reports" + And I set the field "menumodaction" to "All actions" + And I press "Get these logs" + Then I should see "Course module deleted" + And I should see "Course module created" + And I should see "Course module updated" + And I should see "The status of the submission has been viewed."