From 94de68f9b88b0061d13af0e842cea42d5478b6c9 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Fri, 6 Mar 2020 07:51:42 +0000 Subject: [PATCH] MDL-67751 course: include inline folders in list of resources. --- blocks/activity_modules/block_activity_modules.php | 4 ++-- course/resources.php | 11 +++++------ report/log/classes/renderable.php | 3 ++- report/log/locallib.php | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/blocks/activity_modules/block_activity_modules.php b/blocks/activity_modules/block_activity_modules.php index af67de2048b..6d3a60c062d 100644 --- a/blocks/activity_modules/block_activity_modules.php +++ b/blocks/activity_modules/block_activity_modules.php @@ -52,8 +52,8 @@ class block_activity_modules extends block_list { $archetypes = array(); foreach($modinfo->cms as $cm) { - // Exclude activities which are not visible or have no link (=label) - if (!$cm->uservisible or !$cm->has_view()) { + // Exclude activities that aren't visible or have no view link (e.g. label). Account for folder being displayed inline. + if (!$cm->uservisible || (!$cm->has_view() && strcmp($cm->modname, 'folder') !== 0)) { continue; } if (array_key_exists($cm->modname, $modfullnames)) { diff --git a/course/resources.php b/course/resources.php index cc05fd65153..96325e686b8 100644 --- a/course/resources.php +++ b/course/resources.php @@ -74,11 +74,8 @@ foreach ($modinfo->cms as $cm) { if (!in_array($cm->modname, $availableresources)) { continue; } - if (!$cm->uservisible) { - continue; - } - if (!$cm->has_view()) { - // Exclude label and similar + // Exclude activities that aren't visible or have no view link (e.g. label). Account for folder being displayed inline. + if (!$cm->uservisible || (!$cm->has_view() && strcmp($cm->modname, 'folder') !== 0)) { continue; } $cms[$cm->id] = $cm; @@ -140,9 +137,11 @@ foreach ($cms as $cm) { } $class = $cm->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed + $url = $cm->url ?: new moodle_url("/mod/{$cm->modname}/view.php", ['id' => $cm->id]); + $table->data[] = array ( $printsection, - "url."\">".$icon.$cm->get_formatted_name()."", + "" . $icon . $cm->get_formatted_name() . "", $intro); } diff --git a/report/log/classes/renderable.php b/report/log/classes/renderable.php index 56ae1a64cb9..10b580ffff7 100644 --- a/report/log/classes/renderable.php +++ b/report/log/classes/renderable.php @@ -203,7 +203,8 @@ class report_log_renderable implements renderable { $section = 0; $thissection = array(); foreach ($modinfo->cms as $cm) { - if (!$cm->uservisible || !$cm->has_view()) { + // Exclude activities that aren't visible or have no view link (e.g. label). Account for folders displayed inline. + if (!$cm->uservisible || (!$cm->has_view() && strcmp($cm->modname, 'folder') !== 0)) { continue; } if ($cm->sectionnum > 0 and $section <> $cm->sectionnum) { diff --git a/report/log/locallib.php b/report/log/locallib.php index 317203eb173..e0251c7cabc 100644 --- a/report/log/locallib.php +++ b/report/log/locallib.php @@ -376,7 +376,8 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0, $section = 0; $thissection = array(); foreach ($modinfo->cms as $cm) { - if (!$cm->uservisible || !$cm->has_view()) { + // Exclude activities that aren't visible or have no view link (e.g. label). Account for folder being displayed inline. + if (!$cm->uservisible || (!$cm->has_view() && strcmp($cm->modname, 'folder') !== 0)) { continue; } if ($cm->sectionnum > 0 and $section <> $cm->sectionnum) {