mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-80461 courseformat: Use choicedropdown for the format setting
In MDL-79985 a new form element was created to display a new generic dropdown with extra information like a description or an icon on each option. This commits replaces the select for the course format form element in the Course settings page with this new component.
This commit is contained in:
parent
69ee5c3395
commit
2a708f985a
@ -120,12 +120,28 @@ class tool_uploadcourse_step2_form extends tool_uploadcourse_base_form {
|
||||
$mform->addHelpButton('defaults[enddate]', 'enddate');
|
||||
|
||||
$courseformats = get_sorted_course_formats(true);
|
||||
$formcourseformats = array();
|
||||
$formcourseformats = new core\output\choicelist();
|
||||
$formcourseformats->set_allow_empty(false);
|
||||
foreach ($courseformats as $courseformat) {
|
||||
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
|
||||
$definition = [];
|
||||
$component = "format_$courseformat";
|
||||
if (get_string_manager()->string_exists('plugin_description', $component)) {
|
||||
$definition['description'] = get_string('plugin_description', $component);
|
||||
}
|
||||
$formcourseformats->add_option(
|
||||
$courseformat,
|
||||
get_string('pluginname', "format_$courseformat"),
|
||||
[
|
||||
'description' => $definition,
|
||||
],
|
||||
);
|
||||
}
|
||||
$mform->addElement('select', 'defaults[format]', get_string('format'), $formcourseformats);
|
||||
$mform->addHelpButton('defaults[format]', 'format');
|
||||
$mform->addElement(
|
||||
'choicedropdown',
|
||||
'defaults[format]',
|
||||
get_string('format'),
|
||||
$formcourseformats,
|
||||
);
|
||||
$mform->setDefault('defaults[format]', $courseconfig->format);
|
||||
|
||||
if (!empty($CFG->allowcoursethemes)) {
|
||||
|
@ -221,23 +221,40 @@ class course_edit_form extends moodleform {
|
||||
$mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin'));
|
||||
|
||||
$courseformats = get_sorted_course_formats(true);
|
||||
$formcourseformats = array();
|
||||
$formcourseformats = new core\output\choicelist();
|
||||
$formcourseformats->set_allow_empty(false);
|
||||
foreach ($courseformats as $courseformat) {
|
||||
$formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat");
|
||||
$definition = [];
|
||||
$component = "format_$courseformat";
|
||||
if (get_string_manager()->string_exists('plugin_description', $component)) {
|
||||
$definition['description'] = get_string('plugin_description', $component);
|
||||
}
|
||||
$formcourseformats->add_option(
|
||||
$courseformat,
|
||||
get_string('pluginname', "format_$courseformat"),
|
||||
[
|
||||
'description' => $definition,
|
||||
],
|
||||
);
|
||||
}
|
||||
if (isset($course->format)) {
|
||||
$course->format = course_get_format($course)->get_format(); // replace with default if not found
|
||||
$course->format = course_get_format($course)->get_format(); // Replace with default if not found.
|
||||
if (!in_array($course->format, $courseformats)) {
|
||||
// this format is disabled. Still display it in the dropdown
|
||||
$formcourseformats[$course->format] = get_string('withdisablednote', 'moodle',
|
||||
get_string('pluginname', 'format_'.$course->format));
|
||||
// This format is disabled. Still display it in the dropdown.
|
||||
$formcourseformats->add_option(
|
||||
$course->format,
|
||||
get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_'.$course->format)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'format', get_string('format'), $formcourseformats, [
|
||||
'data-formatchooser-field' => 'selector',
|
||||
]);
|
||||
$mform->addHelpButton('format', 'format');
|
||||
$mform->addElement(
|
||||
'choicedropdown',
|
||||
'format',
|
||||
get_string('format'),
|
||||
$formcourseformats,
|
||||
['data-formatchooser-field' => 'selector'],
|
||||
);
|
||||
$mform->setDefault('format', $courseconfig->format);
|
||||
|
||||
// Button to update format-specific options on format change (will be hidden by JavaScript).
|
||||
|
@ -30,6 +30,7 @@ $string['erroractivitytype'] = 'Type of activity is not set up in Course setting
|
||||
$string['orphaned'] = 'Orphaned';
|
||||
$string['orphanedwarning'] = 'These activities are unreachable by users!';
|
||||
$string['pluginname'] = 'Single activity';
|
||||
$string['plugin_description'] = 'The course contains only one activity or resource.';
|
||||
$string['sectionname'] = '';
|
||||
$string['warningchangeformat'] = 'When changing the existing course format to "Single activity" make sure that you removed all extra activities from the course including "Announcements". Note that sections structure may be modified.';
|
||||
$string['privacy:metadata'] = 'The Single activity format plugin does not store any personal data.';
|
||||
|
@ -26,5 +26,6 @@
|
||||
$string['numberdiscussions'] = 'Number of discussions';
|
||||
$string['numberdiscussions_help'] = 'This setting specifies how many discussions should be displayed.';
|
||||
$string['pluginname'] = 'Social';
|
||||
$string['plugin_description'] = 'The course is centred around a main forum on the course page. Additional activities and resources can be added using the Social activities block.';
|
||||
$string['sectionname'] = 'section';
|
||||
$string['privacy:metadata'] = 'The Social format plugin does not store any personal data.';
|
||||
|
@ -27,6 +27,7 @@ $string['hidefromothers'] = 'Hide';
|
||||
$string['page-course-view-topics'] = 'Any course main page in custom sections format';
|
||||
$string['page-course-view-topics-x'] = 'Any course page in custom sections format';
|
||||
$string['pluginname'] = 'Custom sections';
|
||||
$string['plugin_description'] = 'The course is divided into customisable sections.';
|
||||
$string['privacy:metadata'] = 'The Custom sections format plugin does not store any personal data.';
|
||||
$string['indentation'] = 'Allow indentation on course page';
|
||||
$string['indentation_help'] = 'Allow teachers, and other users with the manage activities capability, to indent items on the course page.';
|
||||
|
@ -47,6 +47,8 @@ always linked because a new page, section.php, has been created to display any s
|
||||
- course/format/topics/renderer.php
|
||||
- course/format/weeks/renderer.php
|
||||
* New core_courseformat\sectiondelegate class. The class can be extended by plugins to take control of a course section.
|
||||
* The course format setting has been updated to use a choice dropdown form element instead of a select element. Third-party
|
||||
plugins can now include the string 'plugin_description' to provide a description of the course format.
|
||||
|
||||
=== 4.3 ===
|
||||
* New core_courseformat\output\activitybadge class that can be extended by any module to display content near the activity name.
|
||||
|
@ -30,6 +30,7 @@ $string['hidefromothers'] = 'Hide';
|
||||
$string['page-course-view-weeks'] = 'Any course main page in weekly sections format';
|
||||
$string['page-course-view-weeks-x'] = 'Any course page in weekly sections format';
|
||||
$string['pluginname'] = 'Weekly sections';
|
||||
$string['plugin_description'] = 'The course is divided into sections corresponding to each week, beginning from the course start date.';
|
||||
$string['privacy:metadata'] = 'The Weekly sections format plugin does not store any personal data.';
|
||||
$string['indentation'] = 'Allow indentation on course page';
|
||||
$string['indentation_help'] = 'Allow teachers, and other users with the manage activities capability, to indent items on the course page.';
|
||||
|
@ -132,3 +132,4 @@ topicshow,core
|
||||
topichide,core
|
||||
summary_help,core
|
||||
editsummary,core
|
||||
format_help,core
|
||||
|
@ -935,12 +935,6 @@ $string['forgotten'] = 'Forgotten your username or password?';
|
||||
$string['forgottenduplicate'] = 'The email address is shared by several accounts, please enter username instead';
|
||||
$string['forgotteninvalidurl'] = 'Invalid password reset URL';
|
||||
$string['format'] = 'Format';
|
||||
$string['format_help'] = 'The course format determines the layout of the course page.
|
||||
|
||||
* Single activity - The course contains only one activity or resource.
|
||||
* Social - A forum is displayed on the course page.
|
||||
* Custom sections - The course is divided into customisable sections.
|
||||
* Weekly sections - The course is divided into sections corresponding to each week, beginning from the course start date.';
|
||||
$string['formathtml'] = 'HTML format';
|
||||
$string['formatmarkdown'] = 'Markdown format';
|
||||
$string['formatplain'] = 'Plain text format';
|
||||
@ -2501,3 +2495,9 @@ $string['topicshow'] = 'Show this topic to {$a}';
|
||||
$string['topichide'] = 'Hide this topic from {$a}';
|
||||
$string['summary_help'] = 'The idea of a summary is a short text to prepare students for the activities within the topic or week. The text is shown on the course page under the section name.';
|
||||
$string['editsummary'] = 'Edit summary';
|
||||
$string['format_help'] = 'The course format determines the layout of the course page.
|
||||
|
||||
* Single activity - The course contains only one activity or resource.
|
||||
* Social - The course is centred around a main forum on the course page. Additional activities and resources can be added using the Social activities block.
|
||||
* Custom sections - The course is divided into customisable sections.
|
||||
* Weekly sections - The course is divided into sections corresponding to each week, beginning from the course start date.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user