Skip to content

Commit

Permalink
section action
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Jul 15, 2022
1 parent 8a5c5fa commit a3f9eec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
32 changes: 32 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,36 @@ public function get_config_for_external() {
// Return everything (nothing to hide).
return $this->get_format_options();
}

/**
* Whether this format allows to delete sections.
*
* @param int|stdClass|section_info $section
* @return bool
*/
public function can_delete_section($section) {
return true;
}

/**
* Callback used in WS core_course_edit_section when teacher performs an AJAX action on a section (show/hide).
*
* @param section_info|stdClass $section
* @param string $action
* @param int $sr
* @return null|array any data for the Javascript post-processor (must be json-encodeable)
*/
public function section_action($section, $action, $sr) {
global $PAGE;

if ($action === 'deleteSection') {
// Format 'topics' allows to set and remove markers in addition to common section actions.
require_capability('moodle/course:setcurrentsection', context_course::instance($this->courseid));
$rv = parent::delete_section($section);
} else {
$rv = parent::section_action($section, $action, $sr);
}
return $rv;
}

}
6 changes: 5 additions & 1 deletion templates/section.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@
<div class="coursecontentmasonry content show">
<div class="{{#hasavailability}}description small{{/hasavailability}}">
{{#summary}}
{{> core_courseformat/local/content/section/summary }}
{{#summarytext}}
<div class="course-description-item summarytext m-1">
<div class="description-inner">{{{summarytext}}}</div>
</div>
{{/summarytext}}
{{/summary}}
{{#availability}}
{{> core_courseformat/local/content/section/availability }}
Expand Down

0 comments on commit a3f9eec

Please sign in to comment.