Merge branch 'MDL-72689-master' of https://github.com/sharidas/moodle

This commit is contained in:
Shamim Rezaie
2021-10-11 20:11:44 +11:00
4 changed files with 44 additions and 5 deletions
+7 -2
View File
@@ -33,6 +33,7 @@ class primary extends view {
* Initialise the primary navigation node
*/
public function initialise(): void {
global $CFG;
if (during_initial_install() || $this->initialised) {
return;
}
@@ -46,9 +47,13 @@ class primary extends view {
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
} else if ($homepage === HOMEPAGE_MY) {
$this->add(get_string('myhome'), new \moodle_url('/my/'), self::TYPE_SYSTEM,
null, 'home', new \pix_icon('i/home', ''));
null, 'myhome', new \pix_icon('i/dashboard', ''));
$this->rootnodes['home'] = $this->add(get_string('sitehome'), new \moodle_url('/'),
self::TYPE_SETTING, null, 'myhome', new \pix_icon('i/dashboard', ''));
self::TYPE_SETTING, null, 'home', new \pix_icon('i/home', ''));
if (!empty($CFG->defaulthomepage) && ($CFG->defaulthomepage == HOMEPAGE_MY)) {
// We need to stop automatic redirection.
$this->rootnodes['home']->action->param('redirect', '0');
}
}
}
+2 -2
View File
@@ -62,8 +62,8 @@ class primary_test extends \advanced_testcase {
public function test_setting_initialise_provider() {
return [
'Testing as a guest user' => ['guest', ['courses']],
'Testing as an admin' => ['admin', ['home', 'myhome', 'courses', 'siteadminnode']],
'Testing as a regular user' => ['user', ['home', 'myhome', 'courses']]
'Testing as an admin' => ['admin', ['myhome', 'home', 'courses', 'siteadminnode']],
'Testing as a regular user' => ['user', ['myhome', 'home', 'courses']]
];
}
-1
View File
@@ -93,7 +93,6 @@ $PAGE->has_secondary_navigation_setter(false);
if (!isguestuser()) { // Skip default home page for guests
if (get_home_page() != HOMEPAGE_MY) {
$PAGE->set_primary_active_tab('myhome');
if (optional_param('setdefaulthome', false, PARAM_BOOL)) {
set_user_preference('user_home_page_preference', HOMEPAGE_MY);
} else if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_USER) {
@@ -71,3 +71,38 @@ Feature: Set the site home page and dashboard as the default home page
| preference | breadcrumb |
| Site | Home |
| Dashboard | Dashboard |
@javascript @theme_boost
Scenario Outline: Admin sets defaulthomepage to 0,1 and verify the landing page and site home link
Given I log in as "admin"
And the following config values are set as admin:
| defaulthomepage | <defaulthomepageset> |
And I am on homepage
And I should see "<homepage>" in the "//a[contains(@class,'nav-link active') and contains(., '<homepage>')]" "xpath_element"
And I should see "<sitehome>" in the "<linkelement>" "xpath_element"
Examples:
| defaulthomepageset | homepage | sitehome | linkelement |
| 0 | Home | Home | //a[contains(@class, 'nav-link active') and contains(@tabindex, 0) and not(contains(@href, 'redirect=0'))] |
| 1 | Dashboard | Site home | //a[contains(@class, 'nav-link') and contains(@tabindex, -1) and (contains(@href, 'redirect=0'))] |
@javascript @theme_boost
Scenario Outline: Admin sets defaulthomepage to 2 and verify the landing page based on user preference set
Given I log in as "admin"
And I navigate to "Appearance > Navigation" in site administration
And I set the field "Home page for users" to "User preference"
And I press "Save changes"
And I follow "Preferences" in the user menu
And I follow "Home page"
And I set the field "Home page" to "<userpreference>"
And I press "Save changes"
And the following config values are set as admin:
| defaulthomepage | 2 |
And I log out
And I log in as "admin"
And I should see "<homepage>" in the "//a[contains(@class,'nav-link active') and contains(., '<homepage>')]" "xpath_element"
Examples:
| userpreference | homepage |
| Site | Home |
| Dashboard | Dashboard |