MDL-78291 core_courseformat: fix cm visibility behats

This commit is contained in:
Ferran Recio 2023-07-20 12:17:12 +02:00
parent ee2e084e89
commit 174125dabc
13 changed files with 80 additions and 121 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

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

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

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