Skip to content

Commit a9d86f8

Browse files
committed
AJAX page visibility actions
1 parent 4f5b5ed commit a9d86f8

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

classes/courseformat/stateactions.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ protected function set_section_visibility(
290290
$allsectionsextra = $format->fmt_get_sections_extra();
291291

292292
$delegatedids = [];
293+
$subids = [];
293294
foreach ($ids as $sectionid) {
294295
$sectionextra = $allsectionsextra[$sectionid];
295296
if (!empty($sectionextra->sectionbase->component)) {
@@ -298,17 +299,22 @@ protected function set_section_visibility(
298299
}
299300
if (!$visible && $sectionextra->section || $visible && $sectionextra->parentvisiblesan) {
300301
for ($subsectionextra = $sectionextra; /* ... */
301-
$subsectionextra && ($subsectionextra->id == $sectionextra->id
302-
|| !$visible && $subsectionextra->levelsan > $sectionextra->levelsan); /* ... */
302+
$subsectionextra && (($subsectionextra->id == $sectionextra->id)
303+
|| ($subsectionextra->levelsan > $sectionextra->levelsan)); /* ... */
303304
$subsectionextra = $subsectionextra->nextanyid ? $allsectionsextra[$subsectionextra->nextanyid] : null) {
304-
course_update_section($course, $subsectionextra->sectionbase, ['visible' => $visible]);
305+
if (($subsectionextra->id == $sectionextra->id) || !$visible) {
306+
course_update_section($course, $subsectionextra->sectionbase, ['visible' => $visible]);
307+
}
308+
$subids[] = $subsectionextra->id;
305309
}
306310
}
307311
}
308312
if (count($delegatedids) > 0) {
309313
parent::set_section_visibility($updates, $course, $delegatedids, $visible);
310314
}
311-
$this->section_state($updates, $course, $ids);
315+
if (count($subids) > 0) {
316+
$this->section_state($updates, $course, $subids);
317+
}
312318
}
313319

314320
}

classes/output/courseformat/content/section/controlmenu.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ protected function get_section_visibility_item(): ?link {
133133

134134
if ($link) {
135135
unset($link->attributes['data-sectionreturn']);
136-
if ($this->fmtonsectionpage) {
137-
unset($link->attributes['data-action']);
138-
}
139136
if ($this->section->visible) {
140137
$stateaction = 'section_hide';
141138
} else if (!$this->fmtsectionextra->parentvisiblesan) {

0 commit comments

Comments
 (0)