Skip to content

Commit

Permalink
MDL-78531 administration: New default course settings section
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaia Anabitarte committed Aug 18, 2023
1 parent e998f14 commit baecc57
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 74 deletions.
109 changes: 68 additions & 41 deletions admin/settings/courses.php
Expand Up @@ -43,12 +43,6 @@
array('moodle/category:manage', 'moodle/course:create')
)
);
$ADMIN->add('courses',
new admin_externalpage('course_customfield', new lang_string('course_customfield', 'admin'),
$CFG->wwwroot . '/course/customfield.php',
array('moodle/course:configurecustomfields')
)
);
$ADMIN->add('courses',
new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
new moodle_url('/course/editcategory.php', array('parent' => 0)),
Expand All @@ -68,6 +62,49 @@
)
);

// Download course content.
$downloadcoursedefaulturl = new moodle_url('/admin/settings.php', ['section' => 'coursesettings']);
$temp = new admin_settingpage('downloadcoursecontent', new lang_string('downloadcoursecontent', 'course'));
$temp->add(new admin_setting_configcheckbox('downloadcoursecontentallowed',
new lang_string('downloadcoursecontentallowed', 'admin'),
new lang_string('downloadcoursecontentallowed_desc', 'admin', $downloadcoursedefaulturl->out()), 0));

// 50MB default maximum size per file when downloading course content.
$defaultmaxdownloadsize = 50 * filesize::UNIT_MB;
$temp->add(new filesize('maxsizeperdownloadcoursefile', new lang_string('maxsizeperdownloadcoursefile', 'admin'),
new lang_string('maxsizeperdownloadcoursefile_desc', 'admin'), $defaultmaxdownloadsize, filesize::UNIT_MB));
$temp->hide_if('maxsizeperdownloadcoursefile', 'downloadcoursecontentallowed');

$ADMIN->add('courses', $temp);

// "courserequests" settingpage.
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests',
new lang_string('enablecourserequests', 'admin'),
new lang_string('configenablecourserequests', 'admin'), 1));
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory',
new lang_string('defaultrequestcategory', 'admin'),
new lang_string('configdefaultrequestcategory', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('lockrequestcategory',
new lang_string('lockrequestcategory', 'admin'),
new lang_string('configlockrequestcategory', 'admin'), 0));
$temp->add(new admin_setting_users_with_capability(
'courserequestnotify',
new lang_string('courserequestnotify', 'admin'),
new lang_string('configcourserequestnotify2', 'admin'),
[],
'moodle/site:approvecourse'
));
$ADMIN->add('courses', $temp);

// Pending course requests.
if (!empty($CFG->enablecourserequests)) {
$ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
}

// Add a category for the course Default settings.
$ADMIN->add('courses', new admin_category('coursedefaultsettings', new lang_string('defaultsettingscategory', 'course')));
// Course Default Settings Page.
// NOTE: these settings must be applied after all other settings because they depend on them.

Expand Down Expand Up @@ -226,42 +263,32 @@
new lang_string('coursecommunication_desc', 'course'),
$defaulprovider, $communicationproviders));

$ADMIN->add('courses', $temp);

// Download course content.
$downloadcoursedefaulturl = new moodle_url('/admin/settings.php', ['section' => 'coursesettings']);
$temp = new admin_settingpage('downloadcoursecontent', new lang_string('downloadcoursecontent', 'course'));
$temp->add(new admin_setting_configcheckbox('downloadcoursecontentallowed',
new lang_string('downloadcoursecontentallowed', 'admin'),
new lang_string('downloadcoursecontentallowed_desc', 'admin', $downloadcoursedefaulturl->out()), 0));

// 50MB default maximum size per file when downloading course content.
$defaultmaxdownloadsize = 50 * filesize::UNIT_MB;
$temp->add(new filesize('maxsizeperdownloadcoursefile', new lang_string('maxsizeperdownloadcoursefile', 'admin'),
new lang_string('maxsizeperdownloadcoursefile_desc', 'admin'), $defaultmaxdownloadsize, filesize::UNIT_MB));
$temp->hide_if('maxsizeperdownloadcoursefile', 'downloadcoursecontentallowed');

$ADMIN->add('courses', $temp);

// "courserequests" settingpage.
$temp = new admin_settingpage('courserequest', new lang_string('courserequest'));
$temp->add(new admin_setting_configcheckbox('enablecourserequests',
new lang_string('enablecourserequests', 'admin'),
new lang_string('configenablecourserequests', 'admin'), 1));
$temp->add(new admin_settings_coursecat_select('defaultrequestcategory',
new lang_string('defaultrequestcategory', 'admin'),
new lang_string('configdefaultrequestcategory', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('lockrequestcategory',
new lang_string('lockrequestcategory', 'admin'),
new lang_string('configlockrequestcategory', 'admin'), 0));
$temp->add(new admin_setting_users_with_capability('courserequestnotify', new lang_string('courserequestnotify', 'admin'), new lang_string('configcourserequestnotify2', 'admin'), array(), 'moodle/site:approvecourse'));
$ADMIN->add('courses', $temp);
$ADMIN->add('coursedefaultsettings', $temp);
$ADMIN->add('coursedefaultsettings', new admin_externalpage(
'course_customfield',
new lang_string('course_customfield', 'admin'),
$CFG->wwwroot . '/course/customfield.php',
['moodle/course:configurecustomfields'])
);

// Pending course requests.
if (!empty($CFG->enablecourserequests)) {
$ADMIN->add('courses', new admin_externalpage('coursespending', new lang_string('pendingrequests'),
$CFG->wwwroot . '/course/pending.php', array('moodle/site:approvecourse')));
}
$temp = new admin_settingpage('activitychoosersettings', new lang_string('activitychoosersettings', 'course'));
// Tab mode for the activity chooser.
$temp->add(
new admin_setting_configselect(
'activitychoosertabmode',
new lang_string('activitychoosertabmode', 'course'),
new lang_string('activitychoosertabmode_desc', 'course'),
3,
[
3 => new lang_string('activitychoosertabmodefour', 'course'),
4 => new lang_string('activitychoosertabmodefive', 'course'),
5 => new lang_string('activitychoosertabmodesix', 'course'),
0 => new lang_string('activitychoosertabmodeone', 'course'),
1 => new lang_string('activitychoosertabmodetwo', 'course'),
2 => new lang_string('activitychoosertabmodethree', 'course'),
]
)
);

// Add a category for the Activity Chooser.
$ADMIN->add('courses', new admin_category('activitychooser', new lang_string('activitychoosercategory', 'course')));
Expand Down
Expand Up @@ -186,7 +186,7 @@ Feature: The my overview block allows users to group courses by custom fields
| displaygroupingcustomfield | 1 | block_myoverview |
| customfiltergrouping | textfield2 | block_myoverview |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Edit" "link" in the "Text field 2" "table_row"
And I set the field "Visible to" to "Nobody"
And I press "Save changes"
Expand Down
Expand Up @@ -54,7 +54,7 @@ Feature: Allow teachers to edit the visibility of completion conditions in a cou

Scenario Outline: Default showcompletionconditions value in course form on course creation
Given I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
And I navigate to "Courses > Default settings > Course default settings" in site administration
And I set the field "Show activity completion conditions" to "<siteshowcompletion>"
And I press "Save changes"
When I navigate to "Courses > Add a new course" in site administration
Expand All @@ -67,7 +67,7 @@ Feature: Allow teachers to edit the visibility of completion conditions in a cou

Scenario Outline: Default showcompletionconditions displayed when editing a course with disabled completion tracking
Given I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
And I navigate to "Courses > Default settings > Course default settings" in site administration
And I set the field "Show activity completion conditions" to "<siteshowcompletion>"
And I press "Save changes"
And I am on "Course 1" course homepage with editing mode on
Expand Down
4 changes: 2 additions & 2 deletions course/tests/behat/course_activity_dates.feature
Expand Up @@ -53,7 +53,7 @@ Feature: Allow teachers to edit the visibility of activity dates in a course

Scenario: Default activity dates setting default value can changed to No
Given I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
And I navigate to "Courses > Default settings > Course default settings" in site administration
When I set the following fields to these values:
| Show activity dates | No |
And I click on "Save changes" "button"
Expand All @@ -62,7 +62,7 @@ Feature: Allow teachers to edit the visibility of activity dates in a course

Scenario: Default activity dates setting default value can changed to Yes
Given I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
And I navigate to "Courses > Default settings > Course default settings" in site administration
When I set the following fields to these values:
| Show activity dates | Yes |
And I click on "Save changes" "button"
Expand Down
2 changes: 1 addition & 1 deletion course/tests/behat/course_download_content.feature
Expand Up @@ -21,7 +21,7 @@ Feature: Course content can be downloaded
And I set the following fields to these values:
| Download course content feature available | 1 |
And I press "Save changes"
And I navigate to "Courses > Course default settings" in site administration
And I navigate to "Courses > Default settings > Course default settings" in site administration
And I set the field "Enable download course content" to "Yes"
And I press "Save changes"
And I log out
Expand Down
Expand Up @@ -37,7 +37,7 @@ Feature: Access to downloading course content can be controlled
Given I log in as "admin"
And I am on "Hockey 101" course homepage
And "Download course content" "link" should not exist in current page administration
When I navigate to "Courses > Course default settings" in site administration
When I navigate to "Courses > Default settings > Course default settings" in site administration
And I set the field "Enable download course content" to "Yes"
And I press "Save changes"
And I am on "Hockey 101" course homepage
Expand Down
2 changes: 1 addition & 1 deletion course/tests/behat/customfields_locked.feature
Expand Up @@ -21,7 +21,7 @@ Feature: Fields locked control who is able to edit it

Scenario: Editing locked and not locked custom fields
When I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand Down
6 changes: 3 additions & 3 deletions course/tests/behat/customfields_visibility.feature
Expand Up @@ -21,7 +21,7 @@ Feature: The visibility of fields control where they are displayed

Scenario: Display course custom fields on homepage
When I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand All @@ -41,7 +41,7 @@ Feature: The visibility of fields control where they are displayed

Scenario: Do not display course custom fields on homepage
When I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand All @@ -61,7 +61,7 @@ Feature: The visibility of fields control where they are displayed

Scenario: Display course custom fields on homepage only to course editors
When I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand Down
2 changes: 1 addition & 1 deletion course/tests/behat/max_number_sections.feature
Expand Up @@ -12,7 +12,7 @@ Feature: The maximum number of weeks/topics in a course can be configured
| user | course | role |
| manager1 | Acceptance test site | manager |
And I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
And I navigate to "Courses > Default settings > Course default settings" in site administration

@javascript
Scenario: The number of sections can be increased and the limits are applied to courses
Expand Down
2 changes: 1 addition & 1 deletion customfield/field/checkbox/tests/behat/field.feature
Expand Up @@ -9,7 +9,7 @@ Feature: Managers can manage course custom fields checkbox
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration

Scenario: Create a custom course checkbox field
When I click on "Add a new custom field" "link"
Expand Down
2 changes: 1 addition & 1 deletion customfield/field/date/tests/behat/field.feature
Expand Up @@ -9,7 +9,7 @@ Feature: Managers can manage course custom fields date
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration

Scenario: Create a custom course date field
When I click on "Add a new custom field" "link"
Expand Down
2 changes: 1 addition & 1 deletion customfield/field/select/tests/behat/field.feature
Expand Up @@ -9,7 +9,7 @@ Feature: Managers can manage course custom fields select
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration

Scenario: Create a custom course select field
When I click on "Add a new custom field" "link"
Expand Down
8 changes: 4 additions & 4 deletions customfield/field/text/tests/behat/field.feature
Expand Up @@ -9,7 +9,7 @@ Feature: Managers can manage course custom fields text
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration

Scenario: Create a custom course text field
When I click on "Add a new custom field" "link"
Expand Down Expand Up @@ -61,7 +61,7 @@ Feature: Managers can manage course custom fields text
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand Down Expand Up @@ -91,7 +91,7 @@ Feature: Managers can manage course custom fields text
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand All @@ -118,7 +118,7 @@ Feature: Managers can manage course custom fields text
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Short text" "link"
And I set the following fields to these values:
Expand Down
Expand Up @@ -28,7 +28,7 @@ Feature: Default value for the textarea custom field can contain images
| user | filepath | filename |
| admin | lib/tests/fixtures/gd-logo.png | gd-logo.png |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Text area" "link"
And I set the following fields to these values:
Expand Down
2 changes: 1 addition & 1 deletion customfield/field/textarea/tests/behat/field.feature
Expand Up @@ -9,7 +9,7 @@ Feature: Managers can manage course custom fields textarea
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
And I log in as "admin"
And I navigate to "Courses > Course custom fields" in site administration
And I navigate to "Courses > Default settings > Course custom fields" in site administration

Scenario: Create a custom course textarea field
When I click on "Add a new custom field" "link"
Expand Down

0 comments on commit baecc57

Please sign in to comment.