When we change the position of two sections, we just need to update
the position of the affected sections, not all the sections in the course.
This will improve the performance since the system only executes the queries to affected sections.
Also, the system only clears the cache for affected sections, not all the sections in the course.
Newly PHPUnit tests were created to verify the below methods
- course_modinfo::purge_section_cache_by_id()
- course_modinfo::purge_section_cache_by_number()
- move_section_to()
When updating/deleting a section/module, the system now only
invalidate of the element (section/module), not the whole course cache
Also, the system now only recalculate the cache for element (section/module)
if necessary, not the whole course cache
Move module/section purging to course_modinfo:
+ course_modinfo::purge_course_section_cache_by_id was created to purge section by id
+ course_modinfo::purge_course_section_cache_by_number was created to purge section by number
+ course_modinfo::purge_course_module_cache was created to purge module
The format chooser JS assumes that it is the only mform on the page. If
it is not, and another mform appears before it, then the jump will not
work.
This change:
* updates the formatchooser to modern JS
* allows multiple forms to exist on the page
* stops using id fields
* always hide the format selection button
When accessing to User grades and then to the grades from a
specific course, this call was causing several behat errors
because the dashboard node was not found.
The code causing this issue can be safely removed because it
isn't used (the current node is calculated a few lines below).
Before MDL-70801, the "My courses" page didn't exist so the "More"
button displayed bellow the "Enrolled courses" in frontpage pointed
to Dashboard.
I think this is a leftover from the issue when the "My courses" page
was added and it makes more sense using the "My courses" page here
always.
* Add 'space' keydown event handler on the Collapse/Expand all element
on the course homepage.
* Set aria-expanded attribute of the Expand/Collapse all element
accordingly
Reference:
https://www.w3.org/TR/wai-aria-practices-1.1/#disclosure
These methods can be called via UI, and would throw confusing exceptions
if a user entered "unsafe" characters in a search input (e.g. "<").
Defer cleaning of supplied text to inside the methods.
- Introduce core_course_category::get_nearest_editable_subcategory()
- This function will return the first creatable/manageable category
for current user
- With this new function, we can fix the issue that the users with
course management or creation permision at category level cannot see
the manage menu on My courses page
Applied the following changes to various testcase classes:
- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.
Special mention to:
- When belonging to other components and being valid api:
- analytics related tests have been moved to tests/analytics subdir.
- backup & restore related tests have been moved to tests/backup subdir.
- events related tests have been moved to tests/event subdir.
- privacy related tests have been moved to tests/privacy.
- task related tests have been moved to tests/task subdir.
- Some simple renames, not including the component part anymore (not
needed now that they are namespaced):
- some xxxlib_test.php have been renamed lib_test.php
(when they where testing the corresponding lib.php).
- cache stores tests have been all renamed store_test, originally
each one had its own name (file_test, apcu_test, redis_test...)
- assign feedback tests have been all renamed feedback_test, originally
each one had its own name (file_test, editpdf_test...)
Test data providers are executed before `setUpBeforeClass`, so any
library constants used by the providers must already be present.
Reverts part of the change in 691c5b83.
Course formats may want to preserve the existing section information,
but either change the wrapper (.section .course-section-header), or
prepend and append additional content to it.
Prior to this change, the only way to do this was by copying the entire
content of the template.
This change moves the content of the .course-section-header to a
separate template.
This means that a course format can replace the .section
.course-section-header wrapper whilst retaining its content by
overriding the content/section template and including the
content/section/content template. For example:
```
<li id="section-{{num}}"{{!
}} class="section course-section main clearfix{{!
}}{{#onlysummary}} section-summary{{/onlysummary}}{{!
}}{{#ishidden}} hidden{{/ishidden}}{{!
}}{{#iscurrent}} current{{/iscurrent}}{{!
}}{{#isstealth}} orphaned{{/isstealth}}{{!
}}"
data-sectionid="{{num}}"
data-sectionreturnid="{{sectionreturnid}}"
data-for="section"
data-id="{{id}}"
data-number="{{num}}"{{!
}}>
<!--
Add a custom div to the existing wrapper, without replacing the
entire content of the section/content.
-->
<div class="my-custom-content">
<!--
The upstream content is here:
-->
<div class="course-section-header d-flex"
data-for="section_title"
data-id="{{id}}"
data-number="{{num}}"
>
{{$ core_courseformat/local/content/cm/section/content }}
{{> core_courseformat/local/content/cm/section/content }}
{{/ core_courseformat/local/content/cm/section/content }}
</div>
</div>
</li>
```
It also means that a course format can append additional information to
this wrapper, for example:
```
{{< core_courseformat/local/content/section }}
{{$ core_courseformat/local/content/cm/section/content }}
<div class="some-custom-class">
<!--
Some custom content appended _before_ the course section
content but within the wrapper
-->
</div>
{{> core_courseformat/local/content/cm/section/content }}
<div class="some-custom-class">
<!--
Some custom content appended _after_ the course section
content but within the wrapper
-->
</div>
{{/ core_courseformat/local/content/cm/section/content }}
{{/ core_courseformat/local/content/section }}
```
Course formats may want to preserve the existing activity information,
but either change the wrapper (.activity-item), or prepend and append
additional content to it.
Prior to this change, the only way to do this was by copying the entire
content of the template.
This change moves the content of the activity-item to a separate
template.
This means that a course format can replace the activity-item wrapper
whilst retaining its content by overriding the cm template and including
the cm/activity template. For example:
```
<div class="my-custom-activity-item {{!
}}{{#modstealth}}hiddenactivity{{/modstealth}}{{!
}}{{#modhiddenfromstudents}}hiddenactivity{{/modhiddenfromstudents}}{{!
}}{{#modinline}}activityinline{{/modinline}}" data-activityname="{{activityname}}">
{{#moveicon}} {{{moveicon}}} {{/moveicon}}
{{$ core_courseformat/local/content/cm/activity }}
{{> core_courseformat/local/content/cm/activity }}
{{/ core_courseformat/local/content/cm/activity }}
</div>
```
It also means that a course format can append additional information to
this wrapper, for example:
```
{{< core_courseformat/local/content/cm }}
{{$ core_courseformat/local/content/cm/activity }}
{{> core_courseformat/local/content/cm/activity }}
{{#cmmeta}}
<div class="ct-activity-meta-container">
{{{cmmeta}}}
</div>
{{/cmmeta}}
{{/ core_courseformat/local/content/cm/activity }}
{{/ core_courseformat/local/content/cm }}
```