MDL-85247 report_log: Remove course filter for course log report

This commit is contained in:
Amaia Anabitarte
2025-05-19 09:34:52 +02:00
parent b4a8c83ea3
commit 6c167f36d3
5 changed files with 32 additions and 2 deletions
+6
View File
@@ -99,6 +99,9 @@ class report_log_renderable implements renderable {
/** @var bool if the page is activity page */
public $isactivitypage;
/** @var bool if the page is course page */
public $iscoursepage;
/**
* Constructor.
*
@@ -121,6 +124,7 @@ class report_log_renderable implements renderable {
* @param string $order (optional) sortorder of fetched records
* @param string $origin (optional) origin of the event.
* @param bool $isactivitypage (optional) if the page is activity page.
* @param bool $iscoursepage (optional) if the page is course page.
*/
public function __construct(
$logreader = "",
@@ -142,6 +146,7 @@ class report_log_renderable implements renderable {
$order = "timecreated ASC",
$origin ='',
bool $isactivitypage = false,
bool $iscoursepage = false,
) {
global $PAGE;
@@ -188,6 +193,7 @@ class report_log_renderable implements renderable {
$this->logformat = $logformat;
$this->origin = $origin;
$this->isactivitypage = $isactivitypage;
$this->iscoursepage = $iscoursepage;
}
/**
+1 -1
View File
@@ -183,7 +183,7 @@ class report_log_renderer extends plugin_renderer_base {
*/
private function get_course_selector_field(report_log_renderable $reportlog, int $selectedcourseid): string {
// When the log report is accessed vie an activity, we do not need a course selector.
if ($reportlog->isactivitypage) {
if ($reportlog->isactivitypage || $reportlog->iscoursepage) {
return html_writer::empty_tag(
'input',
['type' => 'hidden', 'name' => 'id', 'value' => $selectedcourseid]
+2
View File
@@ -36,6 +36,7 @@ $user = optional_param('user', 0, PARAM_INT); // User to display.
$date = optional_param('date', 0, PARAM_INT); // Date to display.
$modid = optional_param('modid', 0, PARAM_ALPHANUMEXT); // Module id or 'site_errors'.
$isactivitypage = optional_param('isactivitypage', false, PARAM_BOOL); // Is this a course module page?
$iscoursepage = optional_param('iscoursepage', false, PARAM_BOOL); // Is this a course report page?
$modaction = optional_param('modaction', '', PARAM_ALPHAEXT); // An action as recorded in the logs.
$page = optional_param('page', '0', PARAM_INT); // Which page to show.
$perpage = optional_param('perpage', '100', PARAM_INT); // How many per page.
@@ -186,6 +187,7 @@ $reportlog = new report_log_renderable(
order: 'timecreated DESC',
origin: $origin,
isactivitypage: $isactivitypage,
iscoursepage: ($iscoursepage || $isactivitypage),
);
$readers = $reportlog->get_readers();
+7 -1
View File
@@ -34,8 +34,14 @@ defined('MOODLE_INTERNAL') || die;
* @param stdClass $context The context of the course
*/
function report_log_extend_navigation_course($navigation, $course, $context) {
global $SITE;
if (has_capability('report/log:view', $context)) {
$url = new moodle_url('/report/log/index.php', array('id'=>$course->id));
$params = [
'id' => $course->id,
'iscoursepage' => ($course->id && ($course->id != $SITE->id)),
];
$url = new moodle_url('/report/log/index.php', $params);
$navigation->add(get_string('pluginname', 'report_log'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
}
}
@@ -24,3 +24,19 @@ Feature: In a course administration page, navigate through report page, test for
And I click on "Logs" "link"
Then "Report" "field" should exist in the "tertiary-navigation" "region"
And I should see "Logs" in the "tertiary-navigation" "region"
@javascript
Scenario: Course filter should be available only in the Site administration and Home report log page
Given I log in as "admin"
When I navigate to "Reports > Logs" in site administration
Then I should see "Acceptance test site" in the "region-main" "region"
And I click on "Home" "link"
And I navigate to "Reports > Logs" in current page administration
And I should see "Acceptance test site" in the "region-main" "region"
And I am on "Course 1" course homepage
And I navigate to "Reports" in current page administration
And I click on "Logs" "link"
And I should not see "Acceptance test site" in the "region-main" "region"
And I should not see "Course 1" in the "region-main" "region"
And I click on "Get these logs" "button"
And I should see "Course 1" in the "region-main" "region"