Merge branch 'MDL-72725-master' of git://github.com/ferranrecio/moodle

This commit is contained in:
Andrew Nicols 2021-10-19 10:05:37 +08:00
commit f09effd936
8 changed files with 29 additions and 48 deletions

View File

@ -383,6 +383,23 @@ abstract class base {
return false;
}
/**
* Returns true if this course format uses activity indentation.
*
* Indentation is not supported by core formats anymore and may be deprecated in the future.
* This method will keep a default return "true" for legacy reasons but new formats should override
* it with a return false to prevent future deprecations.
*
* A message in a bottle: if indentation is finally deprecated, both behat steps i_indent_right_activity
* and i_indent_left_activity should be removed as well. Right now no core behat uses them but indentation
* is not officially deprecated so they are still available for the contrib formats.
*
* @return bool if the course format uses indentation.
*/
public function uses_indentation(): bool {
return true;
}
/**
* Returns a list of sections used in the course
*

View File

@ -165,7 +165,7 @@ class cm implements renderable, templatable {
'textclasses' => $displayoptions['textclasses'],
];
if (!empty($mod->indent)) {
if (!empty($mod->indent) && $format->uses_indentation()) {
$data->indent = $mod->indent;
if ($mod->indent > 15) {
$data->hugeindent = true;

View File

@ -164,7 +164,7 @@ class controlmenu implements renderable, templatable {
$format = $this->format;
$mod = $this->mod;
$sectionreturn = $format->get_section_number();
if (!empty($this->displayoptions['disableindentation'])) {
if (!empty($this->displayoptions['disableindentation']) || !$format->uses_indentation()) {
$indent = -1;
} else {
$indent = $mod->indent;

View File

@ -50,6 +50,10 @@ class format_topics extends core_courseformat\base {
return true;
}
public function uses_indentation(): bool {
return false;
}
/**
* Returns the display name of the given section that the course prefers.
*

View File

@ -5,6 +5,7 @@ Overview of this plugin type at http://docs.moodle.org/dev/Course_formats
=== 4.0 ===
* New core_courseformat\base::uses_course_index() to define whether the course format uses course index or not.
* New core_courseformat\base::supports_components() to specify if the format is compatible with reactive components.
* New core_courseformat\base::uses_indentation() to specify if the format is compatible with activity indentation.
=== 3.10 ===
* Added the missing callback supports_ajax() to format_social.

View File

@ -49,6 +49,10 @@ class format_weeks extends core_courseformat\base {
return true;
}
public function uses_indentation(): bool {
return false;
}
/**
* Generate the title for this section page
* @return string the page title

View File

@ -1,36 +0,0 @@
@core @core_course @_cross_browser
Feature: Indent items on the course page
In order to create a structured view of activities
As a teacher
I need to move activities and resources to left and right
@javascript
Scenario: Indent course items with Javascript enabled
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | weeks |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Glossary" to section "1" and I fill the form with:
| Name | Test glossary name |
| Description | Test glossary description |
When I indent right "Test glossary name" activity
Then "#section-1 li.glossary div.mod-indent-1" "css_element" should exist
And I indent right "Test glossary name" activity
And "//li[@id='section-1']/descendant::li[contains(concat(' ', @class, ' '), ' glossary ')]/descendant::a[not(contains(concat(' ', @class, ' '), ' hidden '))]/descendant::span[normalize-space(.)='Move left']" "xpath_element" should exist
And "#section-1 li.glossary div.mod-indent-2" "css_element" should exist
And I reload the page
And "#section-1 li.glossary div.mod-indent-2" "css_element" should exist
And I indent left "Test glossary name" activity
And I indent left "Test glossary name" activity
And "#section-1 li.glossary div.mod-indent-2" "css_element" should not exist
And "#section-1 li.glossary div.mod-indent-1" "css_element" should not exist
And "//li[@id='section-1']/descendant::li[contains(concat(' ', @class, ' '), ' glossary ')]/descendant::a[not(contains(concat(' ', @class, ' '), ' hidden '))]/descendant::span[normalize-space(.)='Move left']" "xpath_element" should not exist

View File

@ -2,7 +2,7 @@
Feature: Course activity controls works as expected
In order to manage my course's activities
As a teacher
I need to edit, hide, show and indent activities inside course sections
I need to edit, hide and show activities inside course sections
# The difference between these two scenario outlines is that one is with
# JS enabled and the other one with JS disabled; we can not use Background
@ -42,10 +42,6 @@ Feature: Course activity controls works as expected
| Forum name | Test forum name 2 |
| Description | Test forum description 2 |
And <belowpage> "section" <should_see_other_sections> exist
And I indent right "Test forum name 1" activity
And <belowpage> "section" <should_see_other_sections> exist
And I indent left "Test forum name 1" activity
And <belowpage> "section" <should_see_other_sections> exist
And I open "Test forum name 1" actions menu
And I click on "Edit settings" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
@ -111,11 +107,6 @@ Feature: Course activity controls works as expected
And I click on "Delete Recent activity block" "link"
And I press "Yes"
And <belowpage> "section" <should_see_other_sections> exist
And <belowpage> "section" <should_see_other_sections> exist
And I indent right "Test forum name 1" activity
And <belowpage> "section" <should_see_other_sections> exist
And I indent left "Test forum name 1" activity
And <belowpage> "section" <should_see_other_sections> exist
And I click on "Edit settings" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
And I should see "Display description on course page"