Skip to content

Commit

Permalink
Merge branch 'MDL-77291-master' of https://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Mar 10, 2023
2 parents 5896d29 + 31aee1c commit 27e0329
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 27 deletions.
2 changes: 1 addition & 1 deletion course/format/amd/build/local/courseindex/cm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion course/format/amd/build/local/courseindex/cm.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions course/format/amd/src/local/courseindex/cm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export default class Component extends DndCmItem {
this.reactive.dispatch('setPageItem', 'cm', this.id, true);
this.element.scrollIntoView({block: "center"});
}
// Add anchor logic if the element is not user visible.
if (!cm.uservisible) {
// Add anchor logic if the element is not user visible or the element hasn't URL.
if (!cm.uservisible || !cm.url) {
this.addEventListener(
this.getElement(this.selectors.CM_NAME),
'click',
Expand Down
32 changes: 15 additions & 17 deletions course/format/templates/local/courseindex/cm.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,29 @@
{{#isactive}}active{{/isactive}}
{{#hascmrestrictions}}restrictions{{/hascmrestrictions}}
{{^accessvisible}}dimmed{{/accessvisible}}
{{#url}} d-flex {{/url}} {{^url}} d-flex-noedit {{/url}}
d-flex
{{#indent}} indented {{/indent}}"
id="{{uniqid}}-course-index-cm-{{id}}"
data-for="cm"
data-id="{{id}}"
role="treeitem"
>
<span class="completioninfo" data-for="cm_completion" data-value="NaN"></span>
{{#url}}
{{#uservisible}}
<a class="courseindex-link text-truncate" href="{{{url}}}" data-for="cm_name" tabindex="-1">
{{{name}}}
</a>
{{/uservisible}}
{{^uservisible}}
<a class="courseindex-link text-truncate" href="#{{{anchor}}}" data-for="cm_name" tabindex="-1" data-anchor="true">
{{{name}}}
</a>
{{/uservisible}}
{{/url}}
{{^url}}
<span class="courseindex-name text-truncate" data-for="cm_name">
{{#uservisible}}
<a
class="courseindex-link text-truncate"
{{#url}} href="{{{url}}}" {{/url}}{{^url}} href="#{{{anchor}}}" data-anchor="true" {{/url}}
data-for="cm_name"
tabindex="-1"
>
{{{name}}}
</span>
{{/url}}
</a>
{{/uservisible}}
{{^uservisible}}
<a class="courseindex-link text-truncate" href="#{{{anchor}}}" data-for="cm_name" tabindex="-1" data-anchor="true">
{{{name}}}
</a>
{{/uservisible}}
<span class="courseindex-locked ml-1" data-for="cm_name">
{{#pix}} t/locked, core {{/pix}}
</span>
Expand Down
21 changes: 21 additions & 0 deletions course/format/tests/behat/course_courseindex.feature
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,24 @@ Feature: Course index depending on role
And I follow "Switch role to..." in the user menu
And I press "Student"
Then I should not see "Topic 1" in the "courseindex-content" "region"

@javascript
Scenario: Course index behaviour for activities without url
# Add a label to the course (labels doesn't have URL, because they can't be displayed in a separate page).
Given the following "activities" exist:
| activity | name | intro | course | idnumber | section |
| label | Activity sample 4 | Test label | C1 | sample4 | 2 |
# Check resources without URL, as labels, are displayed in the CI and the link goes to the main page when it is clicked.
When I am on the "sample1" "Activity" page logged in as "student1"
Then I should see "Test label" in the "#courseindex" "css_element"
And I click on "Test label" "link" in the "#courseindex" "css_element"
And I should see "Test label" in the "region-main" "region"
And I should see "Activity sample 2" in the "region-main" "region"
# Check resources without URL, as labels, are displayed for teachers too, and the link is working even when edit mode is on.
And I am on the "sample1" "Activity" page logged in as "teacher1"
And I should see "Test label" in the "#courseindex" "css_element"
And I turn editing mode on
And I should see "Test label" in the "#courseindex" "css_element"
And I click on "Test label" "link" in the "#courseindex" "css_element"
And I should see "Test label" in the "region-main" "region"
And I should see "Activity sample 2" in the "region-main" "region"
2 changes: 1 addition & 1 deletion lib/editor/atto/tests/behat/customtoolbar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Atto editor with customised toolbar
| label | L1 | <a href="../lib/editor/atto/tests/fixtures/custom_toolbar_example.php">FixtureLink</a> | C1 | label1 |
When I log in as "admin"
And I am on "Course 1" course homepage
And I follow "FixtureLink"
And I click on "FixtureLink" "link" in the "region-main" "region"

@javascript
Scenario: Confirm that both editors have different toolbars but still function
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/atto/tests/behat/disablecontrol.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Atto with enable/disable function.
| label | L1 | <a href="../lib/editor/tests/fixtures/disable_control_example.php">Control Enable/Disable Atto</a> | C1 | label1 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I follow "Control Enable/Disable Atto"
And I click on "Control Enable/Disable Atto" "link" in the "region-main" "region"

@javascript
Scenario: Check disable Atto editor.
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/textarea/tests/behat/disablecontrol.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Text area with enable/disable function.
And I set the field "Text editor" to "Plain text area"
And I press "Save changes"
And I am on "Course 1" course homepage
And I follow "Control Enable/Disable Text area"
And I click on "Control Enable/Disable Text area" "link" in the "region-main" "region"

@javascript
Scenario: Check disable Text area editor.
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/behat/largeforms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Forms with a large number of fields
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/tests/fixtures/max_input_vars.php">FixtureLink</a> | C1 | label1 |
When I am on the "C1" "Course" page logged in as "admin"
And I follow "FixtureLink"
And I click on "FixtureLink" "link" in the "region-main" "region"

# Note: These tests do not actually use JavaScript but they don't work with
# the headless 'browser'.
Expand Down
4 changes: 2 additions & 2 deletions lib/tests/behat/readonlyform.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Feature: Read-only forms should work
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/tests/fixtures/readonlyform.php?sections=1">Fixture link</a> | C1 | label1 |
Given I am on the "C1" "Course" page logged in as "admin"
And I follow "Fixture link"
And I click on "Fixture link" "link" in the "region-main" "region"
When I expand all fieldsets
Then the field "Name" matches value "Important information"

Expand All @@ -26,7 +26,7 @@ Feature: Read-only forms should work
| activity | name | intro | course | idnumber |
| label | L1 | <a href="../lib/tests/fixtures/readonlyform.php?sections=2">Fixture link</a> | C1 | label1 |
Given I am on the "C1" "Course" page logged in as "admin"
And I follow "Fixture link"
And I click on "Fixture link" "link" in the "region-main" "region"
When I expand all fieldsets
Then the field "Name" matches value "Important information"
Then the field "Other" matches value "Other information"

0 comments on commit 27e0329

Please sign in to comment.