mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-76997-master' of https://github.com/aanabit/moodle
- Loading branch information
Showing
5 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Reset course indentation | ||
* | ||
* @copyright 2023 Amaia Anabitarte <amaia@moodle.com> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once('../../config.php'); | ||
|
||
require_admin(); | ||
|
||
$format = required_param('format', PARAM_PLUGIN); | ||
$confirm = optional_param('confirm', false, PARAM_BOOL); | ||
$backurl = new moodle_url('/admin/settings.php', ['section' => 'formatsetting'.$format]); | ||
|
||
$PAGE->set_url('/admin/course/resetindentation.php', ['format' => $format]); | ||
$PAGE->set_context(context_system::instance()); | ||
|
||
if ($confirm) { | ||
require_sesskey(); | ||
$courses = $DB->get_records('course', ['format' => $format], 'id', 'id'); | ||
if (!empty($courses)) { | ||
$courseids = array_keys($courses); | ||
list($courseinsql, $courseparams) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED, 'course'); | ||
$DB->set_field_select('course_modules', 'indent', '0', "course $courseinsql AND indent <> 0", $courseparams); | ||
rebuild_course_cache(0, true); | ||
} | ||
redirect( | ||
$backurl, | ||
get_string('resetindentationsuccess', 'admin'), | ||
null, | ||
\core\output\notification::NOTIFY_SUCCESS | ||
); | ||
} | ||
|
||
$strtitle = get_string('resetindentation', 'admin'); | ||
|
||
$PAGE->set_title($strtitle); | ||
$PAGE->set_heading($strtitle); | ||
|
||
navigation_node::override_active_url(new moodle_url( | ||
'/admin/course/resetindentation.php', | ||
['action' => 'confirm', 'format' => $format] | ||
)); | ||
|
||
echo $OUTPUT->header(); | ||
|
||
$displayoptions = ['confirmtitle' => get_string('resetindentation_title', 'admin')]; | ||
$confirmbutton = new single_button( | ||
new moodle_url('/admin/course/resetindentation.php', ['confirm' => 1, 'format' => $format, 'sesskey' => sesskey()]), | ||
get_string('resetindentation', 'admin'), | ||
'post', | ||
single_button::BUTTON_DANGER | ||
); | ||
$cancelbutton = new single_button($backurl, get_string('cancel')); | ||
echo $OUTPUT->confirm( | ||
get_string('resetindentation_help', 'admin', ['format' => get_string('pluginname', 'format_'.$format)]), | ||
$confirmbutton, | ||
$cancelbutton, | ||
$displayoptions | ||
); | ||
|
||
echo $OUTPUT->footer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
@core @core_admin @core_course @javascript | ||
Feature: Reset course indentation | ||
In order to reset indentation in course modules | ||
As a admin | ||
I want change indent value for all the modules of a course format courses in one go | ||
|
||
Background: | ||
Given the following "courses" exist: | ||
| fullname | shortname | format | | ||
| Topics Course 1 | T1 | topics | | ||
| Topics Course 2 | T2 | topics | | ||
| Weekly Course 1 | W1 | weeks | | ||
| Weekly Course 2 | W2 | weeks | | ||
And the following "activities" exist: | ||
| activity | name | intro | course | idnumber | | ||
| forum | Topics forum name | Topics forum description | T1 | forum1 | | ||
| data | Topics database name | Topics database description | T1 | data1 | | ||
| wiki | Topics wiki name | Topics wiki description | T2 | wiki1 | | ||
| forum | Weekly forum name | Weekly forum description | W1 | forum2 | | ||
| data | Weekly database name | Weekly database description | W1 | data2 | | ||
| wiki | Weekly wiki name | Weekly wiki description | W2 | wiki2 | | ||
And I log in as "admin" | ||
And I am on "Topics Course 1" course homepage with editing mode on | ||
And I open "Topics forum name" actions menu | ||
And I click on "Move right" "link" in the "Topics forum name" activity | ||
And I open "Topics forum name" actions menu | ||
And "Move right" "link" in the "Topics forum name" "activity" should not be visible | ||
And "Move left" "link" in the "Topics forum name" "activity" should be visible | ||
And I press the escape key | ||
And I open "Topics database name" actions menu | ||
And "Move right" "link" in the "Topics database name" "activity" should be visible | ||
And "Move left" "link" in the "Topics database name" "activity" should not be visible | ||
And I am on "Topics Course 2" course homepage with editing mode on | ||
And I open "Topics wiki name" actions menu | ||
And I click on "Move right" "link" in the "Topics wiki name" activity | ||
And I open "Topics wiki name" actions menu | ||
And "Move right" "link" in the "Topics wiki name" "activity" should not be visible | ||
And "Move left" "link" in the "Topics wiki name" "activity" should be visible | ||
And I am on "Weekly Course 1" course homepage with editing mode on | ||
And I open "Weekly forum name" actions menu | ||
And I click on "Move right" "link" in the "Weekly forum name" activity | ||
And I open "Weekly forum name" actions menu | ||
And "Move right" "link" in the "Weekly forum name" "activity" should not be visible | ||
And "Move left" "link" in the "Weekly forum name" "activity" should be visible | ||
And I press the escape key | ||
And I open "Weekly database name" actions menu | ||
And "Move right" "link" in the "Weekly database name" "activity" should be visible | ||
And "Move left" "link" in the "Weekly database name" "activity" should not be visible | ||
And I am on "Weekly Course 2" course homepage with editing mode on | ||
And I open "Weekly wiki name" actions menu | ||
And I click on "Move right" "link" in the "Weekly wiki name" activity | ||
And I open "Weekly wiki name" actions menu | ||
And "Move right" "link" in the "Weekly wiki name" "activity" should not be visible | ||
And "Move left" "link" in the "Weekly wiki name" "activity" should be visible | ||
|
||
Scenario Outline: Apply course indentation reset | ||
Given I navigate to "Plugins > Course formats > <format> format" in site administration | ||
And I wait "5" seconds | ||
And "Reset indentation" "link" should exist | ||
When I click on "Reset indentation" "link" | ||
And I should see "Reset indentation on course page" | ||
And "Reset indentation" "button" should exist | ||
And I click on "Reset indentation" "button" | ||
Then I should see "Indentation reset" | ||
And I am on "<format> Course 1" course homepage with editing mode on | ||
And I open "<format> forum name" actions menu | ||
And "Move right" "link" in the "<format> forum name" "activity" should be visible | ||
And "Move left" "link" in the "<format> forum name" "activity" should not be visible | ||
And I press the escape key | ||
And I open "<format> database name" actions menu | ||
And "Move right" "link" in the "<format> database name" "activity" should be visible | ||
And "Move left" "link" in the "<format> database name" "activity" should not be visible | ||
And I am on "<format> Course 2" course homepage with editing mode on | ||
And I open "<format> wiki name" actions menu | ||
And "Move right" "link" in the "<format> wiki name" "activity" should be visible | ||
And "Move left" "link" in the "<format> wiki name" "activity" should not be visible | ||
# Check other course formats had not been reset | ||
And I am on "<other> Course 1" course homepage with editing mode on | ||
And I open "<other> forum name" actions menu | ||
And "Move right" "link" in the "<other> forum name" "activity" should not be visible | ||
And "Move left" "link" in the "<other> forum name" "activity" should be visible | ||
|
||
Examples: | ||
| format | other | | ||
| Topics | Weekly | | ||
| Weekly | Topics | | ||
|
||
Scenario Outline: Cancel course indentation reset | ||
Given I navigate to "Plugins > Course formats > <format> format" in site administration | ||
And "Reset indentation" "link" should exist | ||
When I click on "Reset indentation" "link" | ||
And I should see "Reset indentation on course page" | ||
And "Reset indentation" "button" should exist | ||
And "Cancel" "button" should exist | ||
And I click on "Cancel" "button" | ||
Then I should not see "Indentation reset" | ||
And I am on "<format> Course 1" course homepage with editing mode on | ||
And I open "<format> forum name" actions menu | ||
And "Move right" "link" in the "<format> forum name" "activity" should not be visible | ||
And "Move left" "link" in the "<format> forum name" "activity" should be visible | ||
And I press the escape key | ||
And I open "<format> database name" actions menu | ||
And "Move right" "link" in the "<format> database name" "activity" should be visible | ||
And "Move left" "link" in the "<format> database name" "activity" should not be visible | ||
And I am on "<format> Course 2" course homepage with editing mode on | ||
And I open "<format> wiki name" actions menu | ||
And "Move right" "link" in the "<format> wiki name" "activity" should not be visible | ||
And "Move left" "link" in the "<format> wiki name" "activity" should be visible | ||
|
||
Examples: | ||
| format | | ||
| Topics | | ||
| Weekly | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters