Skip to content
Snippets Groups Projects
Commit 15dcbcd6 authored by Kathrin Osswald's avatar Kathrin Osswald
Browse files

Setting to choose if switched role information should be displayed beneath course header

parent eacb3abd
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ Changes
### Unreleased
* 2017-03-15 - Setting to choose if switched role information should be displayed beneath course header.
* 2017-03-13 - Setting to be able to upload a favicon.
* 2017-03-10 - Setting to be able to display the title for the first course section (section 0) again.
* 2017-03-09 - Placed course edit on / off button in the course header again like it was displayed before theme_boost.
......
......@@ -61,6 +61,10 @@ This setting is already available in the Moodle core theme Boost. For more infor
This setting is already available in the Moodle core theme Boost. For more information how to use it, please have a look at the official Moodle documentation: http://docs.moodle.org/en/Boost_theme
#### Position of switch role information
With this setting you can choose the place where the information to which role a user has switched is being displayed. If not checked (default value), the role information will be displayed right beneath the user\'s name in the user menu (like in theme Boost). If checked, this information - together with a link to switch back - will be displayed beneath the course, as this functionality is course related.
### 3. Tab "Layout Settings"
#### Footer Layout
......
......@@ -91,6 +91,76 @@ class core_renderer extends \theme_boost\output\core_renderer {
ORIGINAL END */
}
/**
* Override to dispaly switched role information beneath the course header instead of the user menu.
* We change this because the switch role function is course related and therefore it should be placed in the course context.
*
* Wrapper for header elements.
*
* @return string HTML to display the main header.
*/
public function full_header() {
/* MODIFICATION START */
global $PAGE, $USER, $COURSE;
/* MODIFICATION END */
/* ORIGINAL START
global $PAGE;
ORIGINAL END */
$html = html_writer::start_tag('header', array('id' => 'page-header', 'class' => 'row'));
$html .= html_writer::start_div('col-xs-12 p-a-1');
$html .= html_writer::start_div('card');
$html .= html_writer::start_div('card-block');
$html .= html_writer::div($this->context_header_settings_menu(), 'pull-xs-right context-header-settings-menu');
$html .= $this->context_header();
$pageheadingbutton = $this->page_heading_button();
if (empty($PAGE->layout_options['nonavbar'])) {
$html .= html_writer::start_div('clearfix', array('id' => 'page-navbar'));
$html .= html_writer::tag('div', $this->navbar(), array('class' => 'breadcrumb-nav'));
$html .= html_writer::div($pageheadingbutton, 'breadcrumb-button');
$html .= html_writer::end_div();
} else if ($pageheadingbutton) {
$html .= html_writer::div($pageheadingbutton, 'breadcrumb-button nonavbar');
}
$html .= html_writer::tag('div', $this->course_header(), array('id' => 'course-header'));
$html .= html_writer::end_div();
$html .= html_writer::end_div();
$html .= html_writer::end_div();
$html .= html_writer::end_tag('header');
/* MODIFICATION START */
/* Only use this if setting 'showswitchedroleincourse' is active. */
if (get_config('theme_boost_campus', 'showswitchedroleincourse') === 'yes') {
$opts = \user_get_user_navigation_info($USER, $this->page);
// Role is switched.
if (!empty($opts->metadata['asotherrole'])) {
// Get the role name switched to.
$role = $opts->metadata['rolename'];
// Get the URL to switch back (normal role).
$url = new moodle_url('/course/switchrole.php', array('id' => $COURSE->id, 'sesskey' => sesskey(), 'switchrole' => 0,
'returnurl' => $this->page->url->out_as_local_url(false)));
$html .= html_writer::start_tag('div', array('class' => 'switched-role-infobox alert alert-info'));
$html .= html_writer::start_tag('div', array());
$html .= get_string('switchedroleto', 'theme_boost_campus');
// Give this a span to be able to address via CSS
$html .= html_writer::tag('span', $role, array('class' => 'switched-role'));
$html .= html_writer::end_tag('div');
// Return to normal role link
$html .= html_writer::start_tag('div', array('class' => 'switched-role-back col-6'));
$html .= html_writer::empty_tag('img', array('src' => $this->pix_url('a/logout', 'moodle')));
$html .= html_writer::tag('a', get_string('switchrolereturn', 'core'), array('class' => 'switched-role-backlink', 'href' => $url));
$html .= html_writer::end_tag('div'); // Return to normal role link end
$html .= html_writer::end_tag('div');
}
}
/* MODIFICATION END */
return $html;
}
/**
* Override to display course settings on every course site for permanent access
*
......
......@@ -49,3 +49,7 @@ $string['region-side-pre'] = 'Right';
$string['section0titlesetting'] = 'Section 0: Title';
$string['section0titlesetting_desc'] = 'This setting can change the behaviour Moodle displays the title for the first course section. Moodle does not display it as long as the default title for this section is set. As soon as a user changes the title, it will appear. With this setting (option is checked), you can achieve a consistent behaviour by always showing the title for section 0.';
$string['showswitchedroleincoursesetting'] = 'Position of switch role information';
$string['showswitchedroleincoursesetting_desc'] = 'With this setting you can choose the place where the information to which role a user has switched is being displayed. If not checked (default value), the role information will be displayed right beneath the user\'s name in the user menu (like in theme Boost). If checked, this information - together with a link to switch back - will be displayed beneath the course, as this functionality is course related.';
$string['switchedroleto'] = 'You are viewing this course currently with the role:';
......@@ -73,6 +73,7 @@ function theme_boost_campus_get_pre_scss($theme) {
'brandcolor' => ['brand-primary'],
/* MODIFICATION START */
'section0title' => ['section0title'],
'showswitchedroleincourse' => ['showswitchedroleincourse'],
/* MODIFICATION END */
];
......
......@@ -7,6 +7,31 @@
color: $gray-dark;
}
/*------------------------------------
User menu
-------------------------------------*/
/* Don't display switched role information in the user menu
* if setting 'showswitchedroleincourse' is active */
@if $showswitchedroleincourse == 'yes' {
.userswitchedrole .usermenu {
.usertext {
float: inherit;
text-align: inherit;
margin-right: inherit;
height: inherit;
}
span.meta.role {
display: none;
}
.avatar img {
margin-left: 1rem;
margin-right: .5rem;
}
}
}
/*------------------------------------
Nav drawer menu
-------------------------------------*/
......@@ -136,6 +161,34 @@
}
}
/*------------------------------------
Course header
-------------------------------------*/
/*
* If set in showswitchedroleincourse, the switched role information will be displayed
* in the course header instead of ben the user name.
*/
.switched-role-infobox {
span.switched-role {
font-weight: bold;
padding-left: 0.5em;
}
.switched-role-back {
padding-top: 10px;
}
.switched-role-backlink {
padding-left: 0.5em;
vertical-align: middle;
}
}
/*------------------------------------
Course content
-------------------------------------*/
......
......@@ -137,6 +137,15 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Setting to display information of a switched role in the course header.
$setting = new admin_setting_configcheckbox('theme_boost_campus/showswitchedroleincourse',
get_string('showswitchedroleincoursesetting', 'theme_boost_campus', null, true),
get_string('showswitchedroleincoursesetting_desc', 'theme_boost_campus', null, true), 'no', 'yes', 'no'); // Overriding default values
// yes = 1 and no = 0 because of the use of empty() in theme_boost_campus_get_pre_scss() (lib.php). Default 0 value would
// not write the variable to scss that could cause the scss to crash if used in that file.
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Add tab to settings page.
$settings->add($page);
}
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'theme_boost_campus';
$plugin->version = '2017031300';
$plugin->version = '2017031500';
$plugin->release = 'v3.2-r1';
$plugin->requires = '2016070700';
$plugin->maturity = MATURITY_STABLE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment