mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-76994 core_course: New course format setting to enable indentation
This commit is contained in:
parent
4b7c58febf
commit
ec4eacd1da
@ -106,7 +106,7 @@ class cmitem implements named_templatable, renderable {
|
|||||||
'extraclasses' => $mod->extraclasses,
|
'extraclasses' => $mod->extraclasses,
|
||||||
'cmformat' => $item->export_for_template($output),
|
'cmformat' => $item->export_for_template($output),
|
||||||
'hasinfo' => $hasinfo,
|
'hasinfo' => $hasinfo,
|
||||||
'indent' => $mod->indent,
|
'indent' => ($format->uses_indentation()) ? $mod->indent : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,9 @@ class cm implements renderable {
|
|||||||
'sectionnumber' => $section->section,
|
'sectionnumber' => $section->section,
|
||||||
'uservisible' => $cm->uservisible,
|
'uservisible' => $cm->uservisible,
|
||||||
'hascmrestrictions' => $this->get_has_restrictions(),
|
'hascmrestrictions' => $this->get_has_restrictions(),
|
||||||
'indent' => $cm->indent,
|
|
||||||
'module' => $cm->modname,
|
'module' => $cm->modname,
|
||||||
'plugin' => 'mod_' . $cm->modname,
|
'plugin' => 'mod_' . $cm->modname,
|
||||||
|
'indent' => ($format->uses_indentation()) ? $cm->indent : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Check the user access type to this cm.
|
// Check the user access type to this cm.
|
||||||
|
@ -42,5 +42,16 @@ function xmldb_format_topics_upgrade($oldversion) {
|
|||||||
// Automatically generated Moodle v4.1.0 release upgrade line.
|
// Automatically generated Moodle v4.1.0 release upgrade line.
|
||||||
// Put any upgrade step following this.
|
// Put any upgrade step following this.
|
||||||
|
|
||||||
|
if ($oldversion < 2023030700) {
|
||||||
|
// For sites migrating from 4.0.x or 4.1.x where the indentation was removed,
|
||||||
|
// we are disabling 'indentation' value by default.
|
||||||
|
if ($oldversion >= 2022041900) {
|
||||||
|
set_config('indentation', 0, 'format_topics');
|
||||||
|
} else {
|
||||||
|
set_config('indentation', 1, 'format_topics');
|
||||||
|
}
|
||||||
|
upgrade_plugin_savepoint(true, 2023030700, 'format', 'topics');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -36,3 +36,5 @@ $string['page-course-view-topics-x'] = 'Any course page in topics format';
|
|||||||
$string['hidefromothers'] = 'Hide topic';
|
$string['hidefromothers'] = 'Hide topic';
|
||||||
$string['showfromothers'] = 'Show topic';
|
$string['showfromothers'] = 'Show topic';
|
||||||
$string['privacy:metadata'] = 'The Topics format plugin does not store any personal data.';
|
$string['privacy:metadata'] = 'The Topics 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.';
|
||||||
|
@ -50,6 +50,10 @@ class format_topics extends core_courseformat\base {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function uses_indentation(): bool {
|
||||||
|
return (get_config('format_topics', 'indentation')) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the display name of the given section that the course prefers.
|
* Returns the display name of the given section that the course prefers.
|
||||||
*
|
*
|
||||||
|
34
course/format/topics/settings.php
Normal file
34
course/format/topics/settings.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings for format_topics
|
||||||
|
*
|
||||||
|
* @package format_topics
|
||||||
|
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
|
if ($ADMIN->fulltree) {
|
||||||
|
$settings->add(new admin_setting_configcheckbox(
|
||||||
|
'format_topics/indentation',
|
||||||
|
new lang_string('indentation', 'format_topics'),
|
||||||
|
new lang_string('indentation_help', 'format_topics'),
|
||||||
|
1
|
||||||
|
));
|
||||||
|
}
|
@ -24,6 +24,6 @@
|
|||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->version = 2022112800; // The current plugin version (Date: YYYYMMDDXX).
|
$plugin->version = 2023030700; // The current plugin version (Date: YYYYMMDDXX).
|
||||||
$plugin->requires = 2022111800; // Requires this Moodle version.
|
$plugin->requires = 2022111800; // Requires this Moodle version.
|
||||||
$plugin->component = 'format_topics'; // Full name of the plugin (used for diagnostics).
|
$plugin->component = 'format_topics'; // Full name of the plugin (used for diagnostics).
|
||||||
|
@ -42,5 +42,16 @@ function xmldb_format_weeks_upgrade($oldversion) {
|
|||||||
// Automatically generated Moodle v4.1.0 release upgrade line.
|
// Automatically generated Moodle v4.1.0 release upgrade line.
|
||||||
// Put any upgrade step following this.
|
// Put any upgrade step following this.
|
||||||
|
|
||||||
|
if ($oldversion < 2023030700) {
|
||||||
|
// For sites migrating from 4.0.x or 4.1.x where the indentation was removed,
|
||||||
|
// we are disabling 'indentation' value by default.
|
||||||
|
if ($oldversion >= 2022041900) {
|
||||||
|
set_config('indentation', 0, 'format_weeks');
|
||||||
|
} else {
|
||||||
|
set_config('indentation', 1, 'format_weeks');
|
||||||
|
}
|
||||||
|
upgrade_plugin_savepoint(true, 2023030700, 'format', 'weeks');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,3 +39,5 @@ $string['showfromothers'] = 'Show week';
|
|||||||
$string['automaticenddate'] = 'Calculate the end date from the number of sections';
|
$string['automaticenddate'] = 'Calculate the end date from the number of sections';
|
||||||
$string['automaticenddate_help'] = 'If enabled, the end date for the course will be automatically calculated from the number of sections and the course start date.';
|
$string['automaticenddate_help'] = 'If enabled, the end date for the course will be automatically calculated from the number of sections and the course start date.';
|
||||||
$string['privacy:metadata'] = 'The Weekly format plugin does not store any personal data.';
|
$string['privacy:metadata'] = 'The Weekly 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.';
|
||||||
|
@ -49,6 +49,10 @@ class format_weeks extends core_courseformat\base {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function uses_indentation(): bool {
|
||||||
|
return (get_config('format_weeks', 'indentation')) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the title for this section page
|
* Generate the title for this section page
|
||||||
* @return string the page title
|
* @return string the page title
|
||||||
|
34
course/format/weeks/settings.php
Normal file
34
course/format/weeks/settings.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings for format_weeks
|
||||||
|
*
|
||||||
|
* @package format_weeks
|
||||||
|
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
|
if ($ADMIN->fulltree) {
|
||||||
|
$settings->add(new admin_setting_configcheckbox(
|
||||||
|
'format_weeks/indentation',
|
||||||
|
new lang_string('indentation', 'format_weeks'),
|
||||||
|
new lang_string('indentation_help', 'format_weeks'),
|
||||||
|
1
|
||||||
|
));
|
||||||
|
}
|
@ -25,6 +25,6 @@
|
|||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->version = 2022112800; // The current plugin version (Date: YYYYMMDDXX).
|
$plugin->version = 2023030700; // The current plugin version (Date: YYYYMMDDXX).
|
||||||
$plugin->requires = 2022111800; // Requires this Moodle version.
|
$plugin->requires = 2022111800; // Requires this Moodle version.
|
||||||
$plugin->component = 'format_weeks'; // Full name of the plugin (used for diagnostics).
|
$plugin->component = 'format_weeks'; // Full name of the plugin (used for diagnostics).
|
||||||
|
@ -178,3 +178,29 @@ Feature: Course activity controls works as expected
|
|||||||
| courseformat |
|
| courseformat |
|
||||||
| topics |
|
| topics |
|
||||||
| weeks |
|
| weeks |
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario Outline: Admins could disable indentation
|
||||||
|
Given the following "courses" exist:
|
||||||
|
| fullname | shortname | format | coursedisplay | numsections | startdate |
|
||||||
|
| Course 1 | C1 | <courseformat> | <coursedisplay> | 5 | 0 |
|
||||||
|
And the following "activities" exist:
|
||||||
|
| activity | name | intro | course | idnumber |
|
||||||
|
| forum | Test forum name | Test forum description | C1 | forum1 |
|
||||||
|
And I log in as "admin"
|
||||||
|
And I am on "Course 1" course homepage with editing mode on
|
||||||
|
And I open "Test forum name" actions menu
|
||||||
|
And "Move right" "link" should be visible
|
||||||
|
And "Move left" "link" should not be visible
|
||||||
|
And I click on "Move right" "link" in the "Test forum name" activity
|
||||||
|
When the following config values are set as admin:
|
||||||
|
| indentation | 0 | format_<courseformat> |
|
||||||
|
And I am on "Course 1" course homepage with editing mode on
|
||||||
|
And I open "Test forum name" actions menu
|
||||||
|
Then "Move right" "link" should not exist
|
||||||
|
And "Move left" "link" should not exist
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| courseformat |
|
||||||
|
| topics |
|
||||||
|
| weeks |
|
||||||
|
@ -2725,13 +2725,19 @@ class externallib_test extends externallib_advanced_testcase {
|
|||||||
// Expect to receive all the fields.
|
// Expect to receive all the fields.
|
||||||
$this->assertCount(41, $result['courses'][0]);
|
$this->assertCount(41, $result['courses'][0]);
|
||||||
// Check default values for course format topics.
|
// Check default values for course format topics.
|
||||||
$this->assertCount(2, $result['courses'][0]['courseformatoptions']);
|
$this->assertCount(3, $result['courses'][0]['courseformatoptions']);
|
||||||
foreach ($result['courses'][0]['courseformatoptions'] as $option) {
|
foreach ($result['courses'][0]['courseformatoptions'] as $option) {
|
||||||
if ($option['name'] == 'hiddensections') {
|
switch ($option['name']) {
|
||||||
$this->assertEquals(1, $option['value']);
|
case 'hiddensections':
|
||||||
} else {
|
$this->assertEquals(1, $option['value']);
|
||||||
$this->assertEquals('coursedisplay', $option['name']);
|
break;
|
||||||
$this->assertEquals(0, $option['value']);
|
case 'coursedisplay':
|
||||||
|
$this->assertEquals(0, $option['value']);
|
||||||
|
break;
|
||||||
|
case 'indentation':
|
||||||
|
$this->assertEquals(1, $option['value']);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user