From 56cc6bf703a9538a85efb2b4ec49716bed8869c1 Mon Sep 17 00:00:00 2001 From: Stefan Hanauska Date: Sat, 10 Sep 2022 20:08:29 +0200 Subject: [PATCH 1/2] MDL-74887 course: Hide stealth mode without view page --- course/moodleform_mod.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index f3d29bc9b2a..62ed08a060e 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -213,6 +213,7 @@ abstract class moodleform_mod extends moodleform { $this->_features->showdescription = plugin_supports('mod', $this->_modname, FEATURE_SHOW_DESCRIPTION, false); $this->_features->gradecat = ($this->_features->outcomes or $this->_features->hasgrades); $this->_features->advancedgrading = plugin_supports('mod', $this->_modname, FEATURE_ADVANCED_GRADING, false); + $this->_features->hasnoview = plugin_supports('mod', $this->_modname, FEATURE_NO_VIEW_LINK, false); $this->_features->canrescale = (component_callback_exists('mod_' . $this->_modname, 'rescale_activity_grades') !== false); } @@ -613,7 +614,10 @@ abstract class moodleform_mod extends moodleform { $mform->addElement('header', 'modstandardelshdr', get_string('modstandardels', 'form')); $section = get_fast_modinfo($COURSE)->get_section_info($this->_section); - $allowstealth = !empty($CFG->allowstealth) && $this->courseformat->allow_stealth_module_visibility($this->_cm, $section); + $allowstealth = + !empty($CFG->allowstealth) && + $this->courseformat->allow_stealth_module_visibility($this->_cm, $section) && + !$this->_features->hasnoview; if ($allowstealth && $section->visible) { $modvisiblelabel = 'modvisiblewithstealth'; } else if ($section->visible) { From c9bd3a20b67f8288b46ad91975eec3bb7e43bdb1 Mon Sep 17 00:00:00 2001 From: Stefan Hanauska Date: Thu, 13 Oct 2022 12:42:26 +0200 Subject: [PATCH 2/2] MDL-74887 mod_label: Update visibility --- mod/label/db/upgrade.php | 15 ++++++++++++++- mod/label/version.php | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mod/label/db/upgrade.php b/mod/label/db/upgrade.php index a1baf5d6278..25e982be958 100644 --- a/mod/label/db/upgrade.php +++ b/mod/label/db/upgrade.php @@ -45,7 +45,7 @@ defined('MOODLE_INTERNAL') || die; function xmldb_label_upgrade($oldversion) { - global $CFG; + global $CFG, $DB; // Automatically generated Moodle v3.6.0 release upgrade line. // Put any upgrade step following this. @@ -62,5 +62,18 @@ function xmldb_label_upgrade($oldversion) { // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022041901) { + $module = $DB->get_field('modules', 'id', ['name' => 'label']); + $DB->execute(' + UPDATE {course_modules} + SET visible = 0, visibleoncoursepage = 1 + WHERE module = :module + AND visible = 1 + AND visibleoncoursepage = 0', + ['module' => $module] + ); + upgrade_mod_savepoint(true, 2022041901, 'label'); + } + return true; } diff --git a/mod/label/version.php b/mod/label/version.php index 2ff503f4404..3c6bfd4536a 100644 --- a/mod/label/version.php +++ b/mod/label/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022041900; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022041901; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'mod_label'; // Full name of the plugin (used for diagnostics) $plugin->cron = 0;