mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-34859 course: use defaultcustom element for sections
This commit is contained in:
parent
b4eb5f0212
commit
f840bf03e0
@ -20,27 +20,16 @@ class editsection_form extends moodleform {
|
||||
|
||||
$mform = $this->_form;
|
||||
$course = $this->_customdata['course'];
|
||||
$sectioninfo = $this->_customdata['cs'];
|
||||
|
||||
$mform->addElement('header', 'generalhdr', get_string('general'));
|
||||
|
||||
$elementgroup = array();
|
||||
$elementgroup[] = $mform->createElement('text', 'name', '', array('size' => '30', 'maxlength' => '255'));
|
||||
|
||||
// Get default section name.
|
||||
$defaultsectionname = $this->_customdata['defaultsectionname'];
|
||||
if ($defaultsectionname) {
|
||||
$defaultsectionname = ' [' . $defaultsectionname . ']';
|
||||
}
|
||||
|
||||
$elementgroup[] = $mform->createElement('checkbox', 'usedefaultname', '',
|
||||
get_string('sectionusedefaultname') . $defaultsectionname);
|
||||
|
||||
$mform->addGroup($elementgroup, 'name_group', get_string('sectionname'), ' ', false);
|
||||
$mform->addGroupRule('name_group', array('name' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255))));
|
||||
|
||||
$mform->setDefault('usedefaultname', true);
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->disabledIf('name','usedefaultname','checked');
|
||||
$mform->addElement('defaultcustom', 'name', get_string('sectionname'), [
|
||||
'defaultvalue' => $this->_customdata['defaultsectionname'],
|
||||
'customvalue' => $sectioninfo->name,
|
||||
], ['size' => 30, 'maxlength' => 255]);
|
||||
$mform->setDefault('name', false);
|
||||
$mform->addGroupRule('name', array('name' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255))));
|
||||
|
||||
/// Prepare course and the editor
|
||||
|
||||
@ -98,7 +87,9 @@ class editsection_form extends moodleform {
|
||||
$editoroptions = $this->_customdata['editoroptions'];
|
||||
$default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions,
|
||||
$editoroptions['context'], 'course', 'section', $default_values->id);
|
||||
$default_values->usedefaultname = (strval($default_values->name) === '');
|
||||
if (strval($default_values->name) === '') {
|
||||
$default_values->name = false;
|
||||
}
|
||||
parent::set_data($default_values);
|
||||
}
|
||||
|
||||
@ -113,7 +104,7 @@ class editsection_form extends moodleform {
|
||||
if ($data !== null) {
|
||||
$editoroptions = $this->_customdata['editoroptions'];
|
||||
// Set name as an empty string if use default section name is checked.
|
||||
if (!empty($data->usedefaultname)) {
|
||||
if ($data->name === false) {
|
||||
$data->name = '';
|
||||
}
|
||||
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions,
|
||||
|
@ -26,19 +26,21 @@ Feature: Sections can be edited and deleted in topics format
|
||||
|
||||
Scenario: View the default name of the general section in topics format
|
||||
When I click on "Edit section" "link" in the "li#section-0" "css_element"
|
||||
Then I should see "Use default section name [General]"
|
||||
Then the field "Custom" matches value "0"
|
||||
And the field "New value for Section name" matches value "General"
|
||||
|
||||
Scenario: Edit the default name of the general section in topics format
|
||||
When I click on "Edit section" "link" in the "li#section-0" "css_element"
|
||||
And I set the following fields to these values:
|
||||
| Use default section name | 0 |
|
||||
| name | This is the general section |
|
||||
| Custom | 1 |
|
||||
| New value for Section name | This is the general section |
|
||||
And I press "Save changes"
|
||||
Then I should see "This is the general section" in the "li#section-0" "css_element"
|
||||
|
||||
Scenario: View the default name of the second section in topics format
|
||||
When I click on "Edit topic" "link" in the "li#section-2" "css_element"
|
||||
Then I should see "Use default section name [Topic 2]"
|
||||
Then the field "Custom" matches value "0"
|
||||
And the field "New value for Section name" matches value "Topic 2"
|
||||
|
||||
Scenario: Edit section summary in topics format
|
||||
When I edit the section "2" and I fill the form with:
|
||||
@ -47,8 +49,8 @@ Feature: Sections can be edited and deleted in topics format
|
||||
|
||||
Scenario: Edit section default name in topics format
|
||||
When I edit the section "2" and I fill the form with:
|
||||
| Use default section name | 0 |
|
||||
| name | This is the second topic |
|
||||
| Custom | 1 |
|
||||
| New value for Section name | This is the second topic |
|
||||
Then I should see "This is the second topic" in the "li#section-2" "css_element"
|
||||
And I should not see "Topic 2" in the "li#section-2" "css_element"
|
||||
|
||||
|
@ -26,19 +26,21 @@ Feature: Sections can be edited and deleted in weeks format
|
||||
|
||||
Scenario: View the default name of the general section in weeks format
|
||||
When I click on "Edit section" "link" in the "li#section-0" "css_element"
|
||||
Then I should see "Use default section name [General]"
|
||||
Then the field "Custom" matches value "0"
|
||||
And the field "New value for Section name" matches value "General"
|
||||
|
||||
Scenario: Edit the default name of the general section in weeks format
|
||||
When I click on "Edit section" "link" in the "li#section-0" "css_element"
|
||||
And I set the following fields to these values:
|
||||
| Use default section name | 0 |
|
||||
| name | This is the general section |
|
||||
| Custom | 1 |
|
||||
| New value for Section name | This is the general section |
|
||||
And I press "Save changes"
|
||||
Then I should see "This is the general section" in the "li#section-0" "css_element"
|
||||
|
||||
Scenario: View the default name of the second section in weeks format
|
||||
When I click on "Edit week" "link" in the "li#section-2" "css_element"
|
||||
Then I should see "Use default section name [8 May - 14 May]"
|
||||
Then the field "Custom" matches value "0"
|
||||
And the field "New value for Section name" matches value "8 May - 14 May"
|
||||
|
||||
Scenario: Edit section summary in weeks format
|
||||
When I click on "Edit week" "link" in the "li#section-2" "css_element"
|
||||
@ -51,8 +53,8 @@ Feature: Sections can be edited and deleted in weeks format
|
||||
Given I should see "8 May - 14 May" in the "li#section-2" "css_element"
|
||||
When I click on "Edit week" "link" in the "li#section-2" "css_element"
|
||||
And I set the following fields to these values:
|
||||
| Use default section name | 0 |
|
||||
| name | This is the second week |
|
||||
| Custom | 1 |
|
||||
| New value for Section name | This is the second week |
|
||||
And I press "Save changes"
|
||||
Then I should see "This is the second week" in the "li#section-2" "css_element"
|
||||
And I should not see "8 May - 14 May" in the "li#section-2" "css_element"
|
||||
|
@ -61,4 +61,5 @@ timesent,core_message
|
||||
userssearchresults,core_message
|
||||
loginpasswordautocomplete,core_admin
|
||||
loginpasswordautocomplete_help,core_admin
|
||||
deletecomment,core
|
||||
deletecomment,core
|
||||
sectionusedefaultname,core
|
||||
|
@ -1649,7 +1649,6 @@ $string['section'] = 'Section';
|
||||
$string['sectionactionnotsupported'] = 'Section action "{$a}" is not supported here';
|
||||
$string['sectionname'] = 'Section name';
|
||||
$string['sections'] = 'Sections';
|
||||
$string['sectionusedefaultname'] = 'Use default section name';
|
||||
$string['seealsostats'] = 'See also: stats';
|
||||
$string['select'] = 'Select';
|
||||
$string['selectacategory'] = 'Please select a category';
|
||||
@ -2063,4 +2062,5 @@ $string['modchooserenable'] = 'Activity chooser on';
|
||||
$string['modchooserdisable'] = 'Activity chooser off';
|
||||
|
||||
// Deprecated since Moodle 3.3.
|
||||
$string['deletecomment'] = 'Delete this comment';
|
||||
$string['deletecomment'] = 'Delete this comment';
|
||||
$string['sectionusedefaultname'] = 'Use default section name';
|
||||
|
Loading…
x
Reference in New Issue
Block a user