Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ public function get_default_blocks() {
* @return array of options
*/
public function course_format_options($foreditform = false) {
global $CFG;
static $courseformatoptions = false;
if ($courseformatoptions === false) {
$courseconfig = get_config('format_onetopic');
Expand Down Expand Up @@ -584,8 +585,32 @@ public function course_format_options($foreditform = false) {
}

if ($foreditform && !isset($courseformatoptions['coursedisplay']['label'])) {
if ($CFG->version >= 2025082900) {
$hiddensectionslist = new core\output\choicelist();
$hiddensectionslist->set_allow_empty(false);
$hiddensectionslist->add_option(
self::HIDDENSENTIONS_INVISIBLE,
new lang_string('hiddensectionsinvisible'),
[
'description' => new lang_string('hiddensectionsinvisible_description'),
],
);
$hiddensectionslist->add_option(
self::HIDDENSENTIONS_COLLAPSED,
new lang_string('hiddensectionscollapsed'),
[
'description' => new lang_string('hiddensectionscollapsed_description'),
],
);
$hiddensectionslist->add_option(
self::HIDDENSENTIONS_HELP,
new lang_string('hiddensectionshelp', 'format_onetopic'),
[],
);
}

$courseformatoptionsedit = [
'hiddensections' => [
'hiddensections' => ($CFG->version < 2025082900) ? [
'label' => new lang_string('hiddensections'),
'help' => 'hiddensections',
'help_component' => 'moodle',
Expand All @@ -597,6 +622,12 @@ public function course_format_options($foreditform = false) {
self::HIDDENSENTIONS_HELP => new lang_string('hiddensectionshelp', 'format_onetopic'),
],
],
] : [
'label' => new lang_string('hiddensections'),
'element_type' => 'choicedropdown',
'element_attributes' => [
$hiddensectionslist,
],
],
'hidetabsbar' => [
'label' => get_string('hidetabsbar', 'format_onetopic'),
Expand Down
31 changes: 21 additions & 10 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,27 @@
$settings->add($setting);

// Default hidden sections visibility.
$options = [
\format_onetopic::HIDDENSENTIONS_COLLAPSED => new lang_string('hiddensectionscollapsed'),
\format_onetopic::HIDDENSENTIONS_INVISIBLE => new lang_string('hiddensectionsinvisible'),
\format_onetopic::HIDDENSENTIONS_HELP => new lang_string('hiddensectionshelp', 'format_onetopic'),
];
$settings->add(new admin_setting_configselect('format_onetopic/defaulthiddensections',
get_string('hiddensections'),
get_string('hiddensections_help'),
\format_onetopic::HIDDENSENTIONS_HELP,
$options)
if ($CFG->version < 2025082900) {
$options = [
\format_onetopic::HIDDENSENTIONS_COLLAPSED => new lang_string('hiddensectionscollapsed'),
\format_onetopic::HIDDENSENTIONS_INVISIBLE => new lang_string('hiddensectionsinvisible'),
\format_onetopic::HIDDENSENTIONS_HELP => new lang_string('hiddensectionshelp', 'format_onetopic'),
];
} else {
$options = [
\format_onetopic::HIDDENSENTIONS_INVISIBLE => new lang_string('hiddensectionsinvisible'),
\format_onetopic::HIDDENSENTIONS_COLLAPSED => new lang_string('hiddensectionscollapsed'),
\format_onetopic::HIDDENSENTIONS_HELP => new lang_string('hiddensectionshelp', 'format_onetopic'),
];
}
$settings->add(
new admin_setting_configselect(
'format_onetopic/defaulthiddensections',
get_string('hiddensections'),
($CFG->version < 2025082900) ? get_string('hiddensections_help') : null,
\format_onetopic::HIDDENSENTIONS_HELP,
$options
)
);

// Default course display.
Expand Down