Skip to content

Commit

Permalink
MDL-73879 core_courseformat: In edit mode availability card is shown
Browse files Browse the repository at this point in the history
* When in editing mode, we should show all availability condition unfolded
* Add behat tests
  • Loading branch information
laurentdavid committed Jun 25, 2024
1 parent 247f661 commit 322557a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ protected function availability_info_from_output(
if (!empty($info->items)) {
$excerpttext = $info->header . ' ' . $info->items[0]->header;
$data['excerpt'] = info::format_info($excerpttext, $course);
$data['isexpanded'] = $this->format->show_editor();
}

return (object) $data;
Expand Down
55 changes: 55 additions & 0 deletions course/format/tests/behat/section_availability.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@core @core_courseformat
Feature: Verify section availability interface
In order to edit the course sections availability
As a teacher
I need to be able to see the updated availability information

Background:
Given the following "course" exists:
| fullname | Course 1 |
| shortname | C1 |
| category | 0 |
| numsections | 3 |
| initsections | 1 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| assign | Activity sample 1 | Test assignment description | C1 | sample1 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
Given I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I edit the section "1"
And I expand all fieldsets
And I press "Add restriction..."
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "direction" to "until"
And I set the field "x[year]" to "2013"
And I set the field "x[month]" to "March"
And I press "Add restriction..."
And I click on "User profile" "button" in the "Add restriction..." "dialogue"
And I set the field "User profile field" to "Email address"
And I set the field "Value to compare against" to "[email protected]"
And I set the field "Method of comparison" to "is equal to"
And I press "Save changes"
And I log out

@javascript
Scenario: As a teacher I can see the section availability information completely unfolded
in editing mode and it is folded by default when editing mode is off.
Given I am on the "Course 1" course page logged in as "teacher1"
And I switch editing mode on
# We use the fact that the section the second condition is only visible when expanded
Then I should see "Email address is [email protected]"
When I switch editing mode off
Then I should not see "Email address is [email protected]"

@javascript
Scenario: As a a student section should be collapsed by default.
Given I am on the "Course 1" course page logged in as "teacher1"
Then I should not see "Email address is [email protected]"
7 changes: 4 additions & 3 deletions lib/templates/showmore.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
"expandedcontent": "Hello...<br>Is it me you're looking for? I can see it in your eyes",
"extraclasses": "p-3",
"collapsedextraclasses": "bg-secondary",
"expandedextraclasses": "bg-secondary"
"expandedextraclasses": "bg-secondary",
"isexpanded": false
}
}}
<div class="showmore-container collapsed {{$extraclasses}}{{extraclasses}}{{/extraclasses}}" data-region="showmore">
<div class="showmore-container {{^isexpanded}}collapsed{{/isexpanded}} {{$extraclasses}}{{extraclasses}}{{/extraclasses}}" data-region="showmore">
<button
type="button"
class="btn btn-sm btn-link p-0 {{$buttonextraclasses}}{{buttonextraclasses}}{{/buttonextraclasses}}"
aria-expanded="false"
{{^isexpanded}}aria-expanded="false"{{/isexpanded}}{{#isexpanded}}aria-expanded="true"{{/isexpanded}}
data-action="toggle-content"
>
<span class="collapsed-content"> {{#str}} showmore, core {{/str}} {{#pix}} t/expandedchevron, core {{/pix}} </span>
Expand Down

0 comments on commit 322557a

Please sign in to comment.