Skip to content

Commit

Permalink
Merge branch 'MDL-73114-master' of https://github.com/bmbrands/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Jan 20, 2022
2 parents 67570f8 + 5e8b258 commit efd5ddb
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4255,7 +4255,7 @@ public function context_header($headerinfo = null, $headinglevel = 1) {
}

// The user context currently has images and buttons. Other contexts may follow.
if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) {
if ((isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) && $this->page->pagetype !== 'my-index') {
if (isset($headerinfo['user'])) {
$user = $headerinfo['user'];
} else {
Expand Down Expand Up @@ -4420,7 +4420,7 @@ public function full_header() {
$homepage = get_home_page();
$homepagetype = null;
// Add a special case since /my/courses is a part of the /my subsystem.
if ($homepage == HOMEPAGE_MY && $this->page->title !== get_string('mycourses')) {
if ($homepage == HOMEPAGE_MY || $homepage == HOMEPAGE_MYCOURSES) {
$homepagetype = 'my-index';
} else if ($homepage == HOMEPAGE_SITE) {
$homepagetype = 'site-index';
Expand Down
17 changes: 9 additions & 8 deletions lib/templates/full_header.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,19 @@
</div>
</div>
<div class="d-sm-flex align-items-center">
{{#contextheader}}
<div class="mr-auto">
{{{contextheader}}}
</div>
{{/contextheader}}
<div class="header-actions-container flex-shrink-0" data-region="header-actions-container">
{{^welcomemessage}}
{{#contextheader}}
<div class="mr-auto">
{{{contextheader}}}
</div>
{{/contextheader}}
{{/welcomemessage}}
{{> core/welcome }}
<div class="header-actions-container ml-auto" data-region="header-actions-container">
{{#headeractions}}
<div class="header-action ml-2">{{{.}}}</div>
{{/headeractions}}
</div>
</div>

{{> core/welcome }}
</div>
</header>
2 changes: 1 addition & 1 deletion my/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
$PAGE->blocks->add_region('content');
$PAGE->set_subpage($currentpage->id);
$PAGE->set_title($pagetitle);
$PAGE->set_heading($header);
$PAGE->set_heading($pagetitle);
$PAGE->has_secondary_navigation_setter(false);

if (!isguestuser()) { // Skip default home page for guests
Expand Down
8 changes: 1 addition & 7 deletions theme/boost/classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function context_header($headerinfo = null, $headinglevel = 1): string {
}

// The user context currently has images and buttons. Other contexts may follow.
if (isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) {
if ((isset($headerinfo['user']) || $context->contextlevel == CONTEXT_USER) && $this->page->pagetype !== 'my-index') {
if (isset($headerinfo['user'])) {
$user = $headerinfo['user'];
} else {
Expand Down Expand Up @@ -179,12 +179,6 @@ protected function render_context_header(\context_header $contextheader) {
$heading = $this->heading($contextheader->heading, $contextheader->headinglevel, 'h2');
}

$showheader = empty($this->page->layout_options['nocontextheader']);
if (!$showheader) {
// Return the heading wrapped in an sr-only element so it is only visible to screen-readers.
return html_writer::div($heading, 'sr-only');
}

// All the html stuff goes here.
$html = html_writer::start_div('page-context-header');

Expand Down
5 changes: 3 additions & 2 deletions theme/boost/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@
// My courses page.
'mycourses' => array(
'file' => 'drawers.php',
'regions' => array()
'regions' => array(),
'options' => array('nonavbar' => true),
),
// My dashboard page.
'mydashboard' => array(
'file' => 'drawers.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
'options' => array('nonavbar' => true, 'langmenu' => true, 'nocontextheader' => true),
'options' => array('nonavbar' => true, 'langmenu' => true),
),
// My public page.
'mypublic' => array(
Expand Down
35 changes: 35 additions & 0 deletions theme/boost/tests/behat/welcome_to_moodle.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@javascript @theme_boost
Feature: Welcome message on boost
To be welcome in moodle
As a User
I need to see a welcome message on the first page

Scenario: Login and be welcomed on the homepage
Given the following config values are set as admin:
| defaulthomepage | 0 |
When I log in as "admin"
Then I should not see "Acceptance test site" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"
And I should see "Acceptance test site" in the "page-header" "region"

Scenario: Login and be welcomed on the dashboard
Given the following config values are set as admin:
| defaulthomepage | 1 |
When I log in as "admin"
Then I should not see "Dashboard" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"
And I should see "Dashboard" in the "page-header" "region"

Scenario: Login and be welcomed on the my courses page
Given the following config values are set as admin:
| defaulthomepage | 3 |
When I log in as "admin"
Then I should not see "My courses" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"
And I should see "My courses" in the "page-header" "region"
2 changes: 1 addition & 1 deletion theme/classic/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
'file' => 'columns.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
'options' => array('nonavbar' => true, 'langmenu' => true, 'nocontextheader' => true),
'options' => array('langmenu' => true),
),
// My public page.
'mypublic' => array(
Expand Down
32 changes: 32 additions & 0 deletions theme/classic/tests/behat/welcome_to_classicmoodle.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@javascript @theme_classic
Feature: Welcome message on classic
To be welcome in moodle
As a User
I need to see a welcome message on the first page

Scenario: Login and be welcomed on the homepage
Given the following config values are set as admin:
| defaulthomepage | 0 |
When I log in as "admin"
Then I should see "Acceptance test site" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"

Scenario: Login and be welcomed on the dashboard
Given the following config values are set as admin:
| defaulthomepage | 1 |
When I log in as "admin"
Then I should see "Dashboard" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"

Scenario: Login and be welcomed on the my courses page
Given the following config values are set as admin:
| defaulthomepage | 3 |
When I log in as "admin"
Then I should see "My courses" in the "page-header" "region"
And I should see "Welcome, Admin!" in the "page-header" "region"
And I reload the page
And I should not see "Welcome, Admin!" in the "page-header" "region"

0 comments on commit efd5ddb

Please sign in to comment.