MDL-85497 user: ask for confirmation before page is reset.
This commit is contained in:
@@ -39,6 +39,7 @@ $string['managepages'] = 'Manage pages';
|
||||
$string['reseteveryonesdashboard'] = 'Reset Dashboard for all users';
|
||||
$string['reseteveryonesprofile'] = 'Reset profile for all users';
|
||||
$string['resetpage'] = 'Reset page to default';
|
||||
$string['resetpageconfirm'] = 'Are you sure you want to reset the page to default?';
|
||||
$string['reseterror'] = 'There was an error resetting your page';
|
||||
$string['privacy:metadata:core_my:preference:user_home_page_preference'] = 'The user home page preference.';
|
||||
|
||||
|
||||
+8
-3
@@ -152,8 +152,6 @@ if (empty($CFG->forcedefaultmymoodle) && $PAGE->user_allowed_editing()) {
|
||||
$params = array('edit' => !$edit);
|
||||
|
||||
$resetbutton = '';
|
||||
$resetstring = get_string('resetpage', 'my');
|
||||
$reseturl = new moodle_url("$CFG->wwwroot/my/index.php", array('edit' => 1, 'reset' => 1));
|
||||
|
||||
if (!$currentpage->userid) {
|
||||
// viewing a system page -- let the user customise it
|
||||
@@ -163,7 +161,14 @@ if (empty($CFG->forcedefaultmymoodle) && $PAGE->user_allowed_editing()) {
|
||||
$editstring = get_string('updatemymoodleon');
|
||||
} else {
|
||||
$editstring = get_string('updatemymoodleoff');
|
||||
$resetbutton = $OUTPUT->single_button($reseturl, $resetstring);
|
||||
$resetbutton = $OUTPUT->single_button(
|
||||
new moodle_url('/my/index.php', ['edit' => 1, 'reset' => 1]),
|
||||
get_string('resetpage', 'my'),
|
||||
options: [
|
||||
'data-modal' => 'confirmation',
|
||||
'data-modal-content-str' => json_encode(['resetpageconfirm', 'my']),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
$url = new moodle_url("$CFG->wwwroot/my/index.php", $params);
|
||||
|
||||
@@ -8,24 +8,21 @@ Feature: Reset dashboard page to default
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 2 | student2@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "student1"
|
||||
|
||||
@javascript
|
||||
Scenario: Add blocks to page and reset
|
||||
When I turn editing mode on
|
||||
When I log in as "student1"
|
||||
And I turn editing mode on
|
||||
And I add the "Latest announcements" block
|
||||
And I add the "Comments" block
|
||||
And I press "Reset page to default"
|
||||
Then I should not see "Latest announcements"
|
||||
And I should see "Timeline"
|
||||
And I should see "Calendar"
|
||||
And I should not see "Upcoming events"
|
||||
And I should not see "Comments"
|
||||
And I click on "Yes" "button" in the "Confirm" "dialogue"
|
||||
Then "Latest announcements" "block" should not exist
|
||||
And "Timeline" "block" should exist
|
||||
And "Calendar" "block" should exist
|
||||
And I should not see "Reset page to default"
|
||||
|
||||
+16
-2
@@ -180,10 +180,24 @@ if ($PAGE->user_allowed_editing()) {
|
||||
$params['edit'] = 1;
|
||||
} else if (empty($edit)) {
|
||||
$editstring = get_string('updatemymoodleon');
|
||||
$resetbutton = $OUTPUT->single_button($reseturl, $resetstring);
|
||||
$resetbutton = $OUTPUT->single_button(
|
||||
$reseturl,
|
||||
$resetstring,
|
||||
options: [
|
||||
'data-modal' => 'confirmation',
|
||||
'data-modal-content-str' => json_encode(['resetpageconfirm', 'my']),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
$editstring = get_string('updatemymoodleoff');
|
||||
$resetbutton = $OUTPUT->single_button($reseturl, $resetstring);
|
||||
$resetbutton = $OUTPUT->single_button(
|
||||
$reseturl,
|
||||
$resetstring,
|
||||
options: [
|
||||
'data-modal' => 'confirmation',
|
||||
'data-modal-content-str' => json_encode(['resetpageconfirm', 'my']),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
$url = new moodle_url("$CFG->wwwroot/user/profile.php", $params);
|
||||
|
||||
@@ -4,23 +4,12 @@ Feature: Reset my profile page to default
|
||||
As a user
|
||||
I need to reset my profile page
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| student2 | Student | 2 | student2@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| student2 | C1 | student |
|
||||
And I log in as "admin"
|
||||
And I follow "View profile"
|
||||
|
||||
@javascript
|
||||
Scenario: Add blocks to page and reset
|
||||
When I turn editing mode on
|
||||
When I log in as "admin"
|
||||
And I follow "View profile"
|
||||
And I turn editing mode on
|
||||
And I add the "Latest announcements" block
|
||||
And I press "Reset page to default"
|
||||
Then I should not see "Latest announcements"
|
||||
And I click on "Yes" "button" in the "Confirm" "dialogue"
|
||||
Then "Latest announcements" "block" should not exist
|
||||
|
||||
Reference in New Issue
Block a user