Merge branch 'MDL-78291-master' of https://github.com/ferranrecio/moodle

This commit is contained in:
Andrew Nicols 2023-08-24 14:39:37 +08:00
commit 5a44292a05
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
20 changed files with 118 additions and 204 deletions

View File

@ -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');

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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'),

View File

@ -64,7 +64,7 @@
}
}}
{{#isInteractive}}
<div class="activity-badges my-1">
<div class="activity-badges my-1" data-region="visibility">
{{#dropwdown}}
{{< core/local/dropdown/status}}
{{$ buttonclasses }} badge badge-pill badge-secondary dropdown-toggle border-0 {{/ buttonclasses }}
@ -74,12 +74,12 @@
{{/isInteractive}}
{{^isInteractive}}
{{#modhiddenfromstudents}}
<div class="activity-badges my-1 d-flex align-self-start align-items-center">
<div class="activity-badges my-1 d-flex align-self-start align-items-center" data-region="visibility">
<span class="badge badge-pill badge-secondary">{{#pix}}i/show, core{{/pix}}{{#str}}hiddenfromstudents{{/str}}</span>
</div>
{{/modhiddenfromstudents}}
{{#modstealth}}
<div class="activity-badges my-1 d-flex align-self-start align-items-center">
<div class="activity-badges my-1 d-flex align-self-start align-items-center" data-region="visibility">
<span class="badge badge-pill badge-secondary">{{#pix}}t/stealth, core{{/pix}}{{#str}}hiddenoncoursepage{{/str}}</span>
</div>
{{/modstealth}}

View File

@ -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"

View File

@ -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']",
]),
];
}
}

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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'))
);
}
}

View File

@ -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

View File

@ -50,7 +50,7 @@ Feature: Course activity controls works as expected
And I click on "Cancel" "button"
And <belowpage> "section" <should_see_other_sections> 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 <belowpage> "section" <should_see_other_sections> 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 <belowpage> "section" <should_see_other_sections> 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 <belowpage> "section" <should_see_other_sections> exist
And I delete "Test forum name 1" activity
And <belowpage> "section" <should_see_other_sections> exist

View File

@ -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 |

View File

@ -90,3 +90,5 @@ devicedetectregex,core_admin
devicedetectregex_desc,core_admin
devicedetectregexexpression,core_admin
devicedetectregexvalue,core_admin
modshowcmtitle,core
makeavailablecmtitle,core

View File

@ -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';

View File

@ -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.
*

View File

@ -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"

View File

@ -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"