Merge branch 'two_failures' of https://github.com/stronk7/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2021-10-21 23:21:51 +02:00
commit 0e4bc1212b
4 changed files with 17 additions and 32 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -48,13 +48,12 @@ export default class Component extends BaseComponent {
CM: `[data-for='cmitem']`,
TOGGLER: `[data-action="togglecoursecontentsection"]`,
COLLAPSE: `[data-toggle="collapse"]`,
// Formats can override the activity tag but a default one is needed to create new elements.
ACTIVITYTAG: 'li',
};
// Default classes to toggle on refresh.
this.classes = {
COLLAPSED: `collapsed`,
// Formats can override the activity tag but a default one is needed to create new elements.
ACTIVITYTAG: 'li',
// Course content classes.
ACTIVITY: `activity`,
STATEDREADY: `stateready`,
@ -89,6 +88,16 @@ export default class Component extends BaseComponent {
this._indexContents();
// Activate section togglers.
this.addEventListener(this.element, 'click', this._sectionTogglers);
if (this.reactive.supportComponents) {
// Actions are only available in edit mode.
if (this.reactive.isEditing) {
new DispatchActions(this);
}
// Mark content as state ready.
this.element.classList.add(this.classes.STATEDREADY);
}
}
/**
@ -123,30 +132,6 @@ export default class Component extends BaseComponent {
}
}
/**
*
* Course content elements could not provide JS Components because the elements HTML is applied
* directly from the course actions. To keep internal components updated this module keeps
* a list of the active components and mark them as "indexed". This way when any action replace
* the HTML this component will recreate the components an add any necessary event listener.
*
* Format plugins can override this method to provide extra logic to the course frontend.
*
*/
stateReady() {
this._indexContents();
if (this.reactive.supportComponents) {
// Actions are only available in edit mode.
if (this.reactive.isEditing) {
new DispatchActions(this);
}
// Mark content as state ready.
this.element.classList.add(this.classes.STATEDREADY);
}
}
/**
* Return the component watchers.
*

View File

@ -268,6 +268,9 @@
// inclusion we pass parameters around this way..
$displaysection = $section;
// Include course AJAX
include_course_ajax($course, $modnamesused);
// Include the actual course format.
require($CFG->dirroot .'/course/format/'. $course->format .'/format.php');
// Content wrapper end.
@ -279,9 +282,6 @@
// anything after that point.
course_view(context_course::instance($course->id), $section);
// Include course AJAX
include_course_ajax($course, $modnamesused);
// If available, include the JS to prepare the download course content modal.
if ($candownloadcourse) {
$PAGE->requires->js_call_amd('core_course/downloadcontent', 'init');