From 5f9bd120cb8e67eaa609f8d3ff4828ca6bdb4230 Mon Sep 17 00:00:00 2001 From: Anders Rasmussen Date: Mon, 18 Dec 2023 11:28:06 +0100 Subject: [PATCH] #102 - Fixed issue with activity copy button --- README.md | 2 ++ block_sharing_cart.php | 15 ++++++++++----- version.php | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c16ba05..ebd2924 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Change Log * 4.3, release 1 2023.11.01 * Adapted Sharing Cart to new core Moodle 4.3 Backup feature which allows backup without editing the backup. * 4.2, release skipped. +* 4.1, release 4 2023.12.18 + * Fixed issue with activity copy button, where only activities from section 0 would be shown * 4.1, release 3 2023.09.20 * Added activity copy button, if user has capability to back up activities, but not to manage activities * 4.1, release 2 2023.07.05 diff --git a/block_sharing_cart.php b/block_sharing_cart.php index ea3b36d..c9c9bcd 100644 --- a/block_sharing_cart.php +++ b/block_sharing_cart.php @@ -69,7 +69,8 @@ public function has_config(): bool { public function get_content() { global $USER, $COURSE, $PAGE; - $section_id = optional_param('section', 0, PARAM_INT); + $section_id = optional_param('sectionid', 0, PARAM_INT); + $section_section = optional_param('section', 0, PARAM_INT); $context = context_course::instance($this->page->course->id); @@ -156,13 +157,13 @@ public function get_content() { } } - $footer .= $this->insert_copy_section_in_footer($section_id, $sections_dropdown); + $footer .= $this->insert_copy_section_in_footer($section_section, $sections_dropdown); if (!has_capability('moodle/course:manageactivities', $context)) { $activities_dropdown = ''; /** @var \cm_info $activity */ foreach ($activities as $activity) { - if ($this->is_activity_not_in_section($section_id, $activity)) { + if (!$this->is_activity_in_section($section_id, $section_section, $activity)) { continue; } @@ -191,8 +192,12 @@ public function get_content() { return $this->content = (object) array('text' => $html, 'footer' => $footer); } - private function is_activity_not_in_section(int $section_id, \cm_info $activity): bool { - return $section_id !== $activity->get_section_info()->section; + private function is_activity_in_section(int $section_id, int $section, \cm_info $activity): bool { + if ($section === 0 && $section_id == 0) { + return $activity->get_section_info()->section === 0; + } + + return ($section === $activity->get_section_info()->section && $activity->get_section_info()->section !== 0) || $section_id == $activity->get_section_info()->id; } private function is_activity_deletion_in_progress(\cm_info $activity): bool { diff --git a/version.php b/version.php index a898abe..d5d37de 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ /** @var object $plugin */ $plugin->component = 'block_sharing_cart'; -$plugin->version = 2023110100; +$plugin->version = 2023121800; $plugin->requires = 2021051704; // Moodle 3.11.4 $plugin->release = '4.3, release 1'; $plugin->maturity = MATURITY_STABLE;