MDL-80190 core_courseformat: prevent delegated sections loops

This patch prevent dropping an activity with delegated sections inside
another delegated section. Without this patch the teacher can create a
deadlock drag&droping the subsection inside itself. We won't allow
subsections inside subsections so any activity with subsection cannot
be dropped inside a subsección.
This commit is contained in:
Ferran Recio
2024-02-07 12:14:59 +01:00
parent d244a206a3
commit 34ce0eddc0
15 changed files with 62 additions and 12 deletions
@@ -72,4 +72,10 @@ class sectiondelegate_test extends \advanced_testcase {
$this->assertInstanceOf('\test_component\courseformat\sectiondelegate', sectiondelegate::instance($sectioninfos[2]));
$this->assertNull(sectiondelegate::instance($sectioninfos[3]));
}
public function test_has_delegate_class(): void {
$this->assertFalse(sectiondelegate::has_delegate_class('missing_component'));
$this->assertFalse(sectiondelegate::has_delegate_class('mod_label'));
$this->assertTrue(sectiondelegate::has_delegate_class('test_component'));
}
}