From ee2e084e89a6ca14b1e3402ff4faa92a1c61c005 Mon Sep 17 00:00:00 2001 From: Ferran Recio Date: Thu, 20 Jul 2023 12:16:04 +0200 Subject: [PATCH 1/2] MDL-78291 core_courseformat: availability in activity action menu --- .../output/local/content/cm/visibility.php | 15 ++-- .../local/content/cm/visibility.mustache | 6 +- course/format/upgrade.txt | 2 + course/lib.php | 84 +++---------------- lang/en/deprecated.txt | 2 + lang/en/moodle.php | 4 +- lib/classes/output/choicelist.php | 8 ++ 7 files changed, 38 insertions(+), 83 deletions(-) diff --git a/course/format/classes/output/local/content/cm/visibility.php b/course/format/classes/output/local/content/cm/visibility.php index 04b847df70d..e1fc3ed9d54 100644 --- a/course/format/classes/output/local/content/cm/visibility.php +++ b/course/format/classes/output/local/content/cm/visibility.php @@ -153,7 +153,7 @@ class visibility implements named_templatable, renderable { * Get the availability choice list. * @return choicelist */ - protected function get_choice_list(): choicelist { + public function get_choice_list(): choicelist { $choice = $this->create_choice_list(); if (!$this->mod->visible) { $selected = 'hide'; @@ -174,11 +174,14 @@ class visibility implements named_templatable, renderable { global $CFG; $choice = new choicelist(); - $choice->add_option( - 'show', - get_string('availability_show', 'core_courseformat'), - $this->get_option_data('show', 'cmShow') - ); + if ($this->section->visible || $this->mod->has_view()) { + $label = $this->section->visible ? 'show' : 'stealth'; + $choice->add_option( + 'show', + get_string("availability_{$label}", 'core_courseformat'), + $this->get_option_data($label, 'cmShow') + ); + } $choice->add_option( 'hide', get_string('availability_hide', 'core_courseformat'), diff --git a/course/format/templates/local/content/cm/visibility.mustache b/course/format/templates/local/content/cm/visibility.mustache index 82a954b05d2..3ec4e089f3a 100644 --- a/course/format/templates/local/content/cm/visibility.mustache +++ b/course/format/templates/local/content/cm/visibility.mustache @@ -64,7 +64,7 @@ } }} {{#isInteractive}} -
+
{{#dropwdown}} {{< core/local/dropdown/status}} {{$ buttonclasses }} badge badge-pill badge-secondary dropdown-toggle border-0 {{/ buttonclasses }} @@ -74,12 +74,12 @@ {{/isInteractive}} {{^isInteractive}} {{#modhiddenfromstudents}} -
+
{{#pix}}i/show, core{{/pix}}{{#str}}hiddenfromstudents{{/str}}
{{/modhiddenfromstudents}} {{#modstealth}} -
+
{{#pix}}t/stealth, core{{/pix}}{{#str}}hiddenoncoursepage{{/str}}
{{/modstealth}} diff --git a/course/format/upgrade.txt b/course/format/upgrade.txt index 6bd026461a2..84ab8791254 100644 --- a/course/format/upgrade.txt +++ b/course/format/upgrade.txt @@ -45,6 +45,8 @@ Some considerations about the activitybadge feature: * New core_courseformat\base::get_format_string() to get strings that can be overridden by the format plugin. The method will check first the string in the format_PLUGINNAME.php lang file and, if not, it will return the core_courseformat string instead. +* New course format output classes: + - core_courseformat\output\local\content\cm\visibility to display the activity availability. === 4.1 === * New \core_courseformat\stateupdates methods add_section_remove() and add_cm_remove() have been added to replace diff --git a/course/lib.php b/course/lib.php index 2fe83a0eaf2..f3373a97b02 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1661,8 +1661,8 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) { if (!isset($str)) { $str = get_strings( [ - 'delete', 'move', 'moveright', 'moveleft', 'editsettings', 'duplicate', 'modhide', - 'makeavailable', 'makeunavailable', 'modshow', 'modshowcmtitle', 'makeavailablecmtitle', + 'delete', 'move', 'moveright', 'moveleft', 'editsettings', + 'duplicate', 'availability' ], 'moodle' ); @@ -1759,76 +1759,16 @@ function course_get_cm_edit_actions(cm_info $mod, $indent = -1, $sr = null) { // Hide/Show/Available/Unavailable. if (has_capability('moodle/course:activityvisibility', $modcontext)) { - $allowstealth = !empty($CFG->allowstealth) && $courseformat->allow_stealth_module_visibility($mod, $sectioninfo); - - $sectionvisible = $sectioninfo->visible; - // The module on the course page may be in one of the following states: - // - Available and displayed on the course page ($displayedoncoursepage); - // - Not available and not displayed on the course page ($unavailable); - // - Available but not displayed on the course page ($stealth) - this can also be a visible activity in a hidden section. - $displayedoncoursepage = $mod->visible && $mod->visibleoncoursepage && $sectionvisible; - $unavailable = !$mod->visible; - $stealth = $mod->visible && (!$mod->visibleoncoursepage || !$sectionvisible); - if ($displayedoncoursepage) { - $actions['hide'] = new action_menu_link_secondary( - new moodle_url($baseurl, array('hide' => $mod->id)), - new pix_icon('t/hide', '', 'moodle', array('class' => 'iconsmall')), - $str->modhide, - [ - 'class' => 'editing_hide', - 'data-action' => ($usecomponents) ? 'cmHide' : 'hide', - 'data-id' => $mod->id, - ] - ); - } else if (!$displayedoncoursepage && $sectionvisible) { - // Offer to "show" only if the section is visible. - $actions['show'] = new action_menu_link_secondary( - new moodle_url($baseurl, array('show' => $mod->id)), - new pix_icon('t/show', '', 'moodle', array('class' => 'iconsmall')), - $str->modshow, - [ - 'class' => 'editing_show', - 'data-action' => ($usecomponents) ? 'cmShow' : 'show', - 'data-id' => $mod->id, - // Title is needed mostly for behat tests. Otherwise it will follow any link with "show". - 'title' => $str->modshowcmtitle, - ] - ); - } - - if ($stealth) { - // When making the "stealth" module unavailable we perform the same action as hiding the visible module. - $actions['hide'] = new action_menu_link_secondary( - new moodle_url($baseurl, array('hide' => $mod->id)), - new pix_icon('t/unblock', '', 'moodle', array('class' => 'iconsmall')), - $str->makeunavailable, - [ - 'class' => 'editing_makeunavailable', - 'data-action' => ($usecomponents) ? 'cmHide' : 'hide', - 'data-sectionreturn' => $sr, - 'data-id' => $mod->id, - ] - ); - } else if ($unavailable && (!$sectionvisible || $allowstealth) && $mod->has_view()) { - // Allow to make visually hidden module available in gradebook and other reports by making it a "stealth" module. - // When the section is hidden it is an equivalent of "showing" the module. - // Activities without the link (i.e. labels) can not be made available but hidden on course page. - $action = $sectionvisible ? 'stealth' : 'show'; - if ($usecomponents) { - $action = 'cm' . ucfirst($action); - } - $actions[$action] = new action_menu_link_secondary( - new moodle_url($baseurl, array('stealth' => $mod->id)), - new pix_icon('t/block', '', 'moodle', array('class' => 'iconsmall')), - $str->makeavailable, - [ - 'class' => 'editing_makeavailable', - 'data-action' => $action, - 'data-sectionreturn' => $sr, - 'data-id' => $mod->id, - // Title is needed mostly for behat tests. Otherwise it will follow any link with "make available". - 'title' => $str->makeavailablecmtitle, - ] + $availabilityclass = $courseformat->get_output_classname('content\\cm\\visibility'); + /** @var core_courseformat\output\local\content\cm\visibility */ + $availability = new $availabilityclass($courseformat, $sectioninfo, $mod); + $availabilitychoice = $availability->get_choice_list(); + if ($availabilitychoice->count_options() > 1) { + $actions['availability'] = new action_menu_subpanel( + $str->availability, + $availabilitychoice, + ['class' => 'editing_availability'], + new pix_icon('t/hide', '', 'moodle', array('class' => 'iconsmall')) ); } } diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index a030d457c9f..8e825710064 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -84,3 +84,5 @@ backpackemail,core_badges backpackemail_help,core_badges editcoursecompletionsettings,core_completion clicktochangeinbrackets,core +modshowcmtitle,core +makeavailablecmtitle,core diff --git a/lang/en/moodle.php b/lang/en/moodle.php index bcf6fbb02ff..c4dceb445f9 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1248,7 +1248,6 @@ $string['mailteachers'] = 'Inform teachers'; $string['maincoursepage'] = 'Main course page'; $string['makeafolder'] = 'Create folder'; $string['makeavailable'] = 'Make available'; -$string['makeavailablecmtitle'] = 'Make activity available'; $string['makeeditable'] = 'If you make \'{$a}\' editable by the web server process (eg apache) then you could edit this file directly from this page'; $string['makethismyhome'] = 'Make this my home page'; $string['makeunavailable'] = 'Make unavailable'; @@ -1350,7 +1349,6 @@ $string['missingusername'] = 'Missing username'; $string['moddoesnotsupporttype'] = 'Module {$a->modname} does not support uploads of type {$a->type}'; $string['modhide'] = 'Hide'; $string['modshow'] = 'Show'; -$string['modshowcmtitle'] = 'Show activity'; $string['modvisible'] = 'Availability'; $string['modvisible_help'] = '* Show on course page: Available to students (subject to any access restrictions which may be set). * Hide on course page: Not available to students.'; @@ -2452,3 +2450,5 @@ $string['supplyinfo'] = 'More details'; // Deprecated since Moodle 4.3. $string['clicktochangeinbrackets'] = '{$a} (Click to change)'; +$string['modshowcmtitle'] = 'Show activity'; +$string['makeavailablecmtitle'] = 'Make activity available'; diff --git a/lib/classes/output/choicelist.php b/lib/classes/output/choicelist.php index 6f3a032507c..ae38e786329 100644 --- a/lib/classes/output/choicelist.php +++ b/lib/classes/output/choicelist.php @@ -83,6 +83,14 @@ class choicelist implements renderable, named_templatable { } } + /** + * Get the number of options added to the choice list. + * @return int + */ + public function count_options(): int { + return count($this->options); + } + /** * Set the selected option. * From 174125dabc541ff07d543d7fdf5c85b4fe908312 Mon Sep 17 00:00:00 2001 From: Ferran Recio Date: Thu, 20 Jul 2023 12:17:12 +0200 Subject: [PATCH 2/2] MDL-78291 core_courseformat: fix cm visibility behats --- .../site_main_menu/block_site_main_menu.php | 25 ++++++---- .../tests/behat/edit_activities.feature | 21 ++------ .../block_social_activities.php | 25 ++++++---- .../tests/behat/edit_activities.feature | 22 ++------- .../tests/behat/activity_visibility.feature | 32 ++++++------- .../format/tests/behat/behat_courseformat.php | 3 ++ .../tests/behat/course_courseindex.feature | 4 +- .../tests/behat/section_visibility.feature | 6 +-- .../behat/activities_visibility_icons.feature | 48 ++++--------------- course/tests/behat/course_controls.feature | 4 +- .../grader/tests/behat/switch_views.feature | 4 +- mod/h5pactivity/tests/behat/locking.feature | 2 +- .../tests/behat/label_visibility.feature | 5 +- 13 files changed, 80 insertions(+), 121 deletions(-) diff --git a/blocks/site_main_menu/block_site_main_menu.php b/blocks/site_main_menu/block_site_main_menu.php index 82b76e962e0..a66e29c802b 100644 --- a/blocks/site_main_menu/block_site_main_menu.php +++ b/blocks/site_main_menu/block_site_main_menu.php @@ -60,6 +60,11 @@ class block_site_main_menu extends block_list { $cmnameclass = $format->get_output_classname('content\\cm\\cmname'); $controlmenuclass = $format->get_output_classname('content\\cm\\controlmenu'); + $badgeattributes = [ + 'class' => 'badge badge-pill badge-warning mt-2', + 'data-region' => 'visibility' + ]; + // Extra fast view mode. if (!$isediting) { $modinfo = get_fast_modinfo($course); @@ -81,7 +86,7 @@ class block_site_main_menu extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenfromstudents'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -89,7 +94,7 @@ class block_site_main_menu extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenoncoursepage'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -99,7 +104,8 @@ class block_site_main_menu extends block_list { 'activity-basis d-flex align-items-center'); $content = html_writer::div( $activitybasis . $badges, - 'contentwithoutlink activity-item activity' + 'contentwithoutlink activity-item activity', + ['data-activityname' => $cm->name] ); } else { $cmname = new $cmnameclass($format, $cm->get_section_info(), $cm); @@ -108,7 +114,8 @@ class block_site_main_menu extends block_list { 'activity-basis d-flex align-items-center'); $content = html_writer::div( $activitybasis . $badges, - 'activity-item activity' + 'activity-item activity', + ['data-activityname' => $cm->name] ); } @@ -190,7 +197,7 @@ class block_site_main_menu extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenfromstudents'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -198,7 +205,7 @@ class block_site_main_menu extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenoncoursepage'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -211,7 +218,8 @@ class block_site_main_menu extends block_list { 'activity-basis d-flex align-items-center'); $content = html_writer::div( $activitybasis . $badges, - 'contentwithoutlink activity-item activity' + 'contentwithoutlink activity-item activity', + ['data-activityname' => $mod->name] ); } else { $cmname = new $cmnameclass($format, $mod->get_section_info(), $mod); @@ -223,7 +231,8 @@ class block_site_main_menu extends block_list { 'activity-basis d-flex align-items-center'); $content = html_writer::div( $activitybasis . $badges, - 'activity-item activity' + 'activity-item activity', + ['data-activityname' => $mod->name] ); } $this->content->items[] = html_writer::div($content, 'main-menu-content'); diff --git a/blocks/site_main_menu/tests/behat/edit_activities.feature b/blocks/site_main_menu/tests/behat/edit_activities.feature index dcb4380cf7f..336c14bc652 100644 --- a/blocks/site_main_menu/tests/behat/edit_activities.feature +++ b/blocks/site_main_menu/tests/behat/edit_activities.feature @@ -38,24 +38,9 @@ Feature: Edit activities in main menu block And I log in as "admin" And I am on site homepage And I turn editing mode on - And "My forum name" activity in site main menu block should have "Hide" editing icon - And "My forum name" activity in site main menu block should not have "Show" editing icon - And "My forum name" activity in site main menu block should not have "Make available" editing icon - And "My forum name" activity in site main menu block should not have "Make unavailable" editing icon - And I open "My forum name" actions menu in site main menu block - And I click on "Hide" "link" in the "My forum name" activity in site main menu block - And "My forum name" activity in site main menu block should be hidden - And "My forum name" activity in site main menu block should not have "Hide" editing icon - And "My forum name" activity in site main menu block should have "Show" editing icon - And "My forum name" activity in site main menu block should have "Make available" editing icon - And "My forum name" activity in site main menu block should not have "Make unavailable" editing icon - And I open "My forum name" actions menu in site main menu block - And I click on "Make available" "link" in the "My forum name" activity in site main menu block - And "My forum name" activity in site main menu block should be available but hidden from course page - And "My forum name" activity in site main menu block should not have "Hide" editing icon - And "My forum name" activity in site main menu block should have "Show" editing icon - And "My forum name" activity in site main menu block should not have "Make available" editing icon - And "My forum name" activity in site main menu block should have "Make unavailable" editing icon + When I open "My forum name" actions menu in site main menu block + And I choose "Availability > Make available but don't show on course page" in the open action menu + Then I should see "Available but not shown on course page" in the "My forum name" "core_courseformat > Activity visibility" # Make sure that "Availability" dropdown in the edit menu has three options. And I open "My forum name" actions menu in site main menu block And I click on "Edit settings" "link" in the "My forum name" activity in site main menu block diff --git a/blocks/social_activities/block_social_activities.php b/blocks/social_activities/block_social_activities.php index 046e0d036d5..d964b528bfa 100644 --- a/blocks/social_activities/block_social_activities.php +++ b/blocks/social_activities/block_social_activities.php @@ -61,6 +61,11 @@ class block_social_activities extends block_list { $cmnameclass = $format->get_output_classname('content\\cm\\cmname'); $controlmenuclass = $format->get_output_classname('content\\cm\\controlmenu'); + $badgeattributes = [ + 'class' => 'badge badge-pill badge-warning mt-2', + 'data-region' => 'visibility' + ]; + // Extra fast view mode. if (!$isediting) { if (!empty($modinfo->sections[0])) { @@ -75,7 +80,7 @@ class block_social_activities extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenfromstudents'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -83,7 +88,7 @@ class block_social_activities extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenoncoursepage'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -94,7 +99,8 @@ class block_social_activities extends block_list { ); $content = html_writer::div( $activitybasis . $badges, - 'contentwithoutlink activity-item activity' + 'contentwithoutlink activity-item activity', + ['data-activityname' => $cm->name] ); $this->content->items[] = $content; $this->content->icons[] = ''; @@ -105,7 +111,8 @@ class block_social_activities extends block_list { 'activity-basis d-flex align-items-center'); $content = html_writer::div( $activitybasis . $badges, - 'activity-item activity' + 'activity-item activity', + ['data-activityname' => $cm->name] ); $this->content->items[] = $content; } @@ -179,7 +186,7 @@ class block_social_activities extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenfromstudents'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -187,7 +194,7 @@ class block_social_activities extends block_list { $badges = html_writer::tag( 'span', get_string('hiddenoncoursepage'), - ['class' => 'badge badge-pill badge-warning mt-2'] + $badgeattributes ); } @@ -200,7 +207,8 @@ class block_social_activities extends block_list { $moveaction . $activitybasis . $badges, - 'contentwithoutlink activity-item activity' + 'contentwithoutlink activity-item activity', + ['data-activityname' => $mod->name] ); $this->content->items[] = $content; $this->content->icons[] = ''; @@ -214,7 +222,8 @@ class block_social_activities extends block_list { $moveaction . $activitybasis . $badges, - 'activity-item activity' + 'activity-item activity', + ['data-activityname' => $mod->name] ); $this->content->items[] = $content; } diff --git a/blocks/social_activities/tests/behat/edit_activities.feature b/blocks/social_activities/tests/behat/edit_activities.feature index 2b37eeb7209..9094e19c24e 100644 --- a/blocks/social_activities/tests/behat/edit_activities.feature +++ b/blocks/social_activities/tests/behat/edit_activities.feature @@ -44,25 +44,9 @@ Feature: Edit activities in social activities block And I click on "Add a new Forum" "link" in the "Add an activity or resource" "dialogue" And I set the field "Forum name" to "My forum name" And I press "Save and return to course" - And "My forum name" activity in social activities block should have "Hide" editing icon - And "My forum name" activity in social activities block should not have "Show" editing icon - And "My forum name" activity in social activities block should not have "Make available" editing icon - And "My forum name" activity in social activities block should not have "Make unavailable" editing icon - And I wait until the page is ready - And I open "My forum name" actions menu in social activities block - And I click on "Hide" "link" in the "My forum name" activity in social activities block - And "My forum name" activity in social activities block should be hidden - And "My forum name" activity in social activities block should not have "Hide" editing icon - And "My forum name" activity in social activities block should have "Show" editing icon - And "My forum name" activity in social activities block should have "Make available" editing icon - And "My forum name" activity in social activities block should not have "Make unavailable" editing icon - And I open "My forum name" actions menu in social activities block - And I click on "Make available" "link" in the "My forum name" activity in social activities block - And "My forum name" activity in social activities block should be available but hidden from course page - And "My forum name" activity in social activities block should not have "Hide" editing icon - And "My forum name" activity in social activities block should have "Show" editing icon - And "My forum name" activity in social activities block should not have "Make available" editing icon - And "My forum name" activity in social activities block should have "Make unavailable" editing icon + When I open "My forum name" actions menu in social activities block + And I choose "Availability > Make available but don't show on course page" in the open action menu + Then I should see "Available but not shown on course page" in the "My forum name" "core_courseformat > Activity visibility" # Make sure that "Availability" dropdown in the edit menu has three options. And I open "My forum name" actions menu in social activities block And I click on "Edit settings" "link" in the "My forum name" activity in social activities block diff --git a/course/format/tests/behat/activity_visibility.feature b/course/format/tests/behat/activity_visibility.feature index 2a4d2dd0504..a08a616d3bb 100644 --- a/course/format/tests/behat/activity_visibility.feature +++ b/course/format/tests/behat/activity_visibility.feature @@ -27,14 +27,14 @@ Feature: Verify activity visibility interface. Scenario: Teacher can hide an activity using the actions menu. Given I should not see "Hidden from students" in the "Activity sample 1" "activity" When I open "Activity sample 1" actions menu - And I click on "Hide" "link" in the "Activity sample 1" "activity" - Then I should see "Hidden from students" in the "Activity sample 1" "activity" + And I choose "Availability > Hide on course page" in the open action menu + Then I should see "Hidden from students" in the "Activity sample 1" "core_courseformat > Activity visibility" @javascript Scenario: Teacher can show an activity using the actions menu. - Given I should see "Hidden from students" in the "Activity sample 2" "activity" + Given I should see "Hidden from students" in the "Activity sample 2" "core_courseformat > Activity visibility" When I open "Activity sample 2" actions menu - And I click on "Show activity" "link" in the "Activity sample 2" "activity" + And I choose "Availability > Show on course page" in the open action menu Then I should not see "Hidden from students" in the "Activity sample 2" "activity" @javascript @@ -42,17 +42,17 @@ Feature: Verify activity visibility interface. Given the following config values are set as admin: | allowstealth | 1 | And I reload the page - And I should see "Hidden from students" in the "Activity sample 2" "activity" + And I should see "Hidden from students" in the "Activity sample 2" "core_courseformat > Activity visibility" When I open "Activity sample 2" actions menu - And I click on "Make activity available" "link" in the "Activity sample 2" "activity" + And I choose "Availability > Make available but don't show on course page" in the open action menu Then I should not see "Hidden from students" in the "Activity sample 2" "activity" - And I should see "Available but not shown on course page" in the "Activity sample 2" "activity" + And I should see "Available but not shown on course page" in the "Activity sample 2" "core_courseformat > Activity visibility" @javascript Scenario: Teacher can show an activity using the visibility badge. - Given I should see "Hidden from students" in the "Activity sample 2" "activity" - When I click on "Hidden from students" "button" in the "Activity sample 2" "activity" - And I click on "Show on course page" "link" in the "Activity sample 2" "activity" + Given I should see "Hidden from students" in the "Activity sample 2" "core_courseformat > Activity visibility" + When I click on "Hidden from students" "button" in the "Activity sample 2" "core_courseformat > Activity visibility" + And I click on "Show on course page" "link" in the "Activity sample 2" "core_courseformat > Activity visibility" Then I should not see "Hidden from students" in the "Activity sample 2" "activity" @javascript @@ -60,17 +60,17 @@ Feature: Verify activity visibility interface. Given the following config values are set as admin: | allowstealth | 1 | And I reload the page - When I click on "Hidden from students" "button" in the "Activity sample 2" "activity" - And I click on "Make available but don't show on course page" "link" in the "Activity sample 2" "activity" + When I click on "Hidden from students" "button" in the "Activity sample 2" "core_courseformat > Activity visibility" + And I click on "Make available but don't show on course page" "link" in the "Activity sample 2" "core_courseformat > Activity visibility" Then I should not see "Hidden from students" in the "Activity sample 2" "activity" - And I should see "Available but not shown on course page" in the "Activity sample 2" "activity" + And I should see "Available but not shown on course page" in the "Activity sample 2" "core_courseformat > Activity visibility" @javascript Scenario: Make available but not shown is available only when stealth activities are enabled. - Given I click on "Hidden from students" "button" in the "Activity sample 2" "activity" + Given I click on "Hidden from students" "button" in the "Activity sample 2" "core_courseformat > Activity visibility" And I should not see "Make available but don't show on course page" in the "Activity sample 2" "activity" When the following config values are set as admin: | allowstealth | 1 | And I reload the page - And I click on "Hidden from students" "button" in the "Activity sample 2" "activity" - Then I should see "Make available but don't show on course page" in the "Activity sample 2" "activity" + And I click on "Hidden from students" "button" in the "Activity sample 2" "core_courseformat > Activity visibility" + Then I should see "Make available but don't show on course page" in the "Activity sample 2" "core_courseformat > Activity visibility" diff --git a/course/format/tests/behat/behat_courseformat.php b/course/format/tests/behat/behat_courseformat.php index 35a724d1b1d..b03bad1ae4f 100644 --- a/course/format/tests/behat/behat_courseformat.php +++ b/course/format/tests/behat/behat_courseformat.php @@ -41,6 +41,9 @@ class behat_courseformat extends behat_base { new behat_component_named_selector('Activity groupmode', [ ".//*[@data-activityname=%locator%]//*[@data-region='groupmode']", ]), + new behat_component_named_selector('Activity visibility', [ + ".//*[@data-activityname=%locator%]//*[@data-region='visibility']", + ]), ]; } } diff --git a/course/format/tests/behat/course_courseindex.feature b/course/format/tests/behat/course_courseindex.feature index 1498e35356c..605f8afcbee 100644 --- a/course/format/tests/behat/course_courseindex.feature +++ b/course/format/tests/behat/course_courseindex.feature @@ -76,7 +76,7 @@ Feature: Course index depending on role And I am on "Course 1" course homepage with editing mode on And I hide section "2" And I open "Activity sample 3" actions menu - And I click on "Hide" "link" in the "Activity sample 3" activity + And I choose "Availability > Hide on course page" in the open action menu And I log out And I log in as "teacher1" When I am on "Course 1" course homepage @@ -93,7 +93,7 @@ Feature: Course index depending on role And I am on "Course 1" course homepage with editing mode on And I hide section "2" And I open "Activity sample 3" actions menu - And I click on "Hide" "link" in the "Activity sample 3" activity + And I choose "Availability > Hide on course page" in the open action menu And I log out And I log in as "student1" When I am on "Course 1" course homepage diff --git a/course/format/tests/behat/section_visibility.feature b/course/format/tests/behat/section_visibility.feature index e6538564363..fb9e1ff862c 100644 --- a/course/format/tests/behat/section_visibility.feature +++ b/course/format/tests/behat/section_visibility.feature @@ -1,5 +1,5 @@ @core @core_courseformat -Feature: Varify section visibility interface. +Feature: Varify section visibility interface In order to edit the course sections visibility As a teacher I need to be able to see the updateds visibility information @@ -26,7 +26,7 @@ Feature: Varify section visibility interface. Scenario: Activities available but not shown on course page only apply to hidden sections. Given I hide section "1" And I open "Activity sample 1" actions menu - And I click on "Make available" "link" in the "Activity sample 1" "activity" + And I choose "Availability > Make available but don't show on course page" in the open action menu And I should see "Available but not shown on course page" in the "Activity sample 1" "activity" When I show section "1" Then I should not see "Available but not shown on course page" in the "Activity sample 1" "activity" @@ -43,7 +43,7 @@ Feature: Varify section visibility interface. @javascript Scenario: Hiden activities in hidden sections stay hidden when the section is shown. Given I open "Activity sample 1" actions menu - And I click on "Hide" "link" in the "Activity sample 1" "activity" + And I choose "Availability > Hide on course page" in the open action menu And I should see "Hidden from students" in the "Activity sample 1" "activity" And I hide section "1" And I should see "Hidden from students" in the "Activity sample 1" "activity" diff --git a/course/tests/behat/activities_visibility_icons.feature b/course/tests/behat/activities_visibility_icons.feature index e3294b6e8a0..a35da5cbade 100644 --- a/course/tests/behat/activities_visibility_icons.feature +++ b/course/tests/behat/activities_visibility_icons.feature @@ -34,23 +34,13 @@ Feature: Toggle activities visibility from the course page And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on When I open "Test forum name" actions menu - Then "Test forum name" actions menu should not have "Show" item - And "Test forum name" actions menu should not have "Make available" item - And "Test forum name" actions menu should not have "Make unavailable" item - And I click on "Hide" "link" in the "Test forum name" activity - And "Test forum name" activity should be hidden + And I choose "Availability > Hide on course page" in the open action menu + Then "Test forum name" activity should be hidden And I open "Test forum name" actions menu - And "Test forum name" actions menu should not have "Hide" item - # Stealth behaviour is not available by default: - And "Test forum name" actions menu should not have "Make available" item - And "Test forum name" actions menu should not have "Make unavailable" item - And I click on "Show activity" "link" in the "Test forum name" activity + And I choose "Availability > Show on course page" in the open action menu And "Test forum name" activity should be visible And I open "Test forum name" actions menu - And "Test forum name" actions menu should not have "Show" item - And "Test forum name" actions menu should not have "Make available" item - And "Test forum name" actions menu should not have "Make unavailable" item - And I click on "Hide" "link" in the "Test forum name" activity + And I choose "Availability > Hide on course page" in the open action menu And "Test forum name" activity should be hidden And I reload the page And "Test forum name" activity should be hidden @@ -63,8 +53,6 @@ Feature: Toggle activities visibility from the course page And the field "Availability" matches value "Hide on course page" And I press "Save and return to course" And "Test forum name" activity should be hidden - And I turn editing mode off - And "Test forum name" activity should be hidden # Student should not see this activity. And I am on the "Course 1" course page logged in as student1 And I should not see "Test forum name" @@ -81,18 +69,12 @@ Feature: Toggle activities visibility from the course page And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on When I hide section "2" - Then "Test forum name" activity should be hidden + And "Test forum name" activity should be hidden And I open "Test forum name" actions menu - And "Test forum name" actions menu should not have "Show" item - And "Test forum name" actions menu should not have "Hide" item - And "Test forum name" actions menu should not have "Make unavailable" item - And I click on "Make available" "link" in the "Test forum name" activity - And "Test forum name" activity should be available but hidden from course page + And I choose "Availability > Make available but don't show on course page" in the open action menu + Then "Test forum name" activity should be available but hidden from course page And I open "Test forum name" actions menu - And "Test forum name" actions menu should not have "Show" item - And "Test forum name" actions menu should not have "Hide" item - And "Test forum name" actions menu should not have "Make available" item - And I click on "Make unavailable" "link" in the "Test forum name" activity + And I choose "Availability > Hide on course page" in the open action menu And "Test forum name" activity should be hidden # Make sure that "Availability" dropdown in the edit menu has three options. And I open "Test forum name" actions menu @@ -120,18 +102,8 @@ Feature: Toggle activities visibility from the course page And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on When I open "Test assignment name" actions menu - Then "Test assignment name" actions menu should not have "Show" item - And "Test assignment name" actions menu should have "Hide" item - And "Test assignment name" actions menu should not have "Make available" item - And "Test assignment name" actions menu should not have "Make unavailable" item - And I click on "Hide" "link" in the "Test assignment name" activity - And "Test assignment name" activity should be hidden - And I open "Test assignment name" actions menu - And "Test assignment name" actions menu should have "Show" item - And "Test assignment name" actions menu should not have "Hide" item - And "Test assignment name" actions menu should not have "Make unavailable" item - And I click on "Make activity available" "link" in the "Test assignment name" activity - And "Test assignment name" activity should be available but hidden from course page + And I choose "Availability > Make available but don't show on course page" in the open action menu + Then "Test assignment name" activity should be available but hidden from course page # Make sure that "Availability" dropdown in the edit menu has three options. And I open "Test assignment name" actions menu And I click on "Edit settings" "link" in the "Test assignment name" activity diff --git a/course/tests/behat/course_controls.feature b/course/tests/behat/course_controls.feature index ee33abdbe53..8963446847d 100644 --- a/course/tests/behat/course_controls.feature +++ b/course/tests/behat/course_controls.feature @@ -50,7 +50,7 @@ Feature: Course activity controls works as expected And I click on "Cancel" "button" And "section" exist And I open "Test forum name 1" actions menu - And I click on "Hide" "link" in the "Test forum name 1" activity + And I choose "Availability > Hide on course page" in the open action menu And "section" exist And I delete "Test forum name 1" activity And I should not see "Test forum name 1" in the "region-main" "region" @@ -110,7 +110,7 @@ Feature: Course activity controls works as expected And I should see "Display description on course page" And I press "Save and return to course" And "section" exist - And I click on "Hide" "link" in the "Test forum name 1" activity + And I click on "Hide on course page" "link" in the "Test forum name 1" activity And "section" exist And I delete "Test forum name 1" activity And "section" exist diff --git a/grade/report/grader/tests/behat/switch_views.feature b/grade/report/grader/tests/behat/switch_views.feature index 8e39b1f7745..340d85dc8b4 100644 --- a/grade/report/grader/tests/behat/switch_views.feature +++ b/grade/report/grader/tests/behat/switch_views.feature @@ -40,7 +40,7 @@ Feature: We can change what we are viewing on the grader report Scenario: View and minimise the grader report containing hidden activities When I am on "Course 1" course homepage with editing mode on And I open "Test assignment name 2" actions menu - And I click on "Hide" "link" in the "Test assignment name 2" activity + And I choose "Availability > Hide on course page" in the open action menu And I am on "Course 1" course homepage with editing mode off And I navigate to "View > Grader report" in the course gradebook And I should see "Test assignment name 1" in the "user-grades" "table" @@ -73,7 +73,7 @@ Feature: We can change what we are viewing on the grader report Scenario: Minimise the grader report containing hidden activities without the 'moodle/grade:viewhidden' capability Given I am on "Course 1" course homepage with editing mode on And I open "Test assignment name 2" actions menu - And I click on "Hide" "link" in the "Test assignment name 2" activity + And I choose "Availability > Hide on course page" in the open action menu And the following "role capability" exists: | role | editingteacher | | moodle/grade:viewhidden | prevent | diff --git a/mod/h5pactivity/tests/behat/locking.feature b/mod/h5pactivity/tests/behat/locking.feature index d00f085114b..04b0be25bfc 100644 --- a/mod/h5pactivity/tests/behat/locking.feature +++ b/mod/h5pactivity/tests/behat/locking.feature @@ -86,7 +86,7 @@ Feature: Add H5P activity context locking Scenario: Access participant report in a hidden activity Given I log in as "admin" And I am on "Course 1" course homepage with editing mode on - And I click on "Hide" "link" in the "H5P package" activity + And I click on "Hide on course page" "link" in the "H5P package" activity When I am on the "H5P package" "h5pactivity activity" page And I navigate to "Attempts report" in current page administration Then I should see "Student 1" diff --git a/mod/label/tests/behat/label_visibility.feature b/mod/label/tests/behat/label_visibility.feature index a4ea75942d4..c219318cd51 100644 --- a/mod/label/tests/behat/label_visibility.feature +++ b/mod/label/tests/behat/label_visibility.feature @@ -51,10 +51,7 @@ Feature: Check label visibility works When I hide section "1" Then "Swanky label" label should be hidden And I open "Swanky label" actions menu - And "Swanky label" actions menu should not have "Show" item - And "Swanky label" actions menu should not have "Hide" item - And "Swanky label" actions menu should not have "Make available" item - And "Swanky label" actions menu should not have "Make unavailable" item + And "Swanky label" actions menu should not have "Availability" item And I click on "Edit settings" "link" in the "Swanky label" activity And I expand all fieldsets And the "Availability" select box should contain "Hide on course page"