Merge branch 'MDL-82478-main' of https://github.com/aanabit/moodle

This commit is contained in:
Jun Pataleta 2024-08-19 11:42:35 +08:00
commit 83a031e39f
No known key found for this signature in database
GPG key ID: F83510526D99E2C7
6 changed files with 41 additions and 18 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

@ -596,17 +596,31 @@ export default class extends BaseComponent {
let bodyText = null;
let titleText = null;
let delegatedsection = null;
if (cmIds.length == 1) {
const cmInfo = this.reactive.get('cm', cmIds[0]);
titleText = getString('cmdelete_title', 'core_courseformat');
bodyText = getString(
'cmdelete_info',
'core_courseformat',
{
type: cmInfo.modname,
name: cmInfo.name,
}
);
if (cmInfo.hasdelegatedsection) {
delegatedsection = cmInfo.delegatesectionid;
titleText = this.reactive.getFormatString('cmdelete_subsectiontitle');
bodyText = getString(
'sectiondelete_info',
'core_courseformat',
{
type: cmInfo.modname,
name: cmInfo.name,
}
);
} else {
titleText = this.reactive.getFormatString('cmdelete_title');
bodyText = getString(
'cmdelete_info',
'core_courseformat',
{
type: cmInfo.modname,
name: cmInfo.name,
}
);
}
} else {
titleText = getString('cmsdelete_title', 'core_courseformat');
bodyText = getString(
@ -628,6 +642,13 @@ export default class extends BaseComponent {
e.preventDefault();
modal.destroy();
this.reactive.dispatch('cmDelete', cmIds);
if (cmIds.length == 1 && delegatedsection && target.baseURI.includes('section.php')) {
// Redirect to the course main page if the subsection is the current page.
let parameters = new URLSearchParams(window.location.search);
if (parameters.has('id') && parameters.get('id') == delegatedsection) {
this._dispatchSectionDelete([delegatedsection], target);
}
}
}
);
}

View file

@ -184,8 +184,7 @@ class delegatedcontrolmenu extends basecontrolmenu {
}
// Delete deletes the module.
// Only show the delete link if we are not already in the section view page.
if (!$isheadersection && $hasmanageactivities) {
if ($hasmanageactivities) {
$url = clone($cmbaseurl);
$url->param('delete', $cm->id);
$url->param('sr', $cm->sectionnum);