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

Setting to move the 'Switch role to...' menu item to the course settings.

parent 770685ad
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ Changes
### Unreleased
* 2017-09-01 - Setting to move the 'Switch role to...' menu item to the course settings.
* 2017-08-28 - Expose navigation node properties in the boost flat navigation (Backport of MDL-59425).
* 2017-08-10 - Setting to be able to place the course context menu within the course beneath the page header.
* 2017-07-14 - Setting to place the link to the homepage always on top of the nav drawer.
......
......@@ -121,11 +121,18 @@ With this setting you can add an additional course edit on / off button to the c
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.
#### In course settings menu
#### Course settings
##### In course settings menu
With this setting you can change the displaying of the course context menu. In Boost, there is a popup context menu right next to the cog icon and clicking on the "More..." menu item will lead the user to another page with all course settings. By enabling this setting the settings will occur directly beneath the course header.
Please note that this change does not affect users who have switched off javascript in their browsers - they will still get the behaviour from Moodle core with a popup course context menu.
##### Move "Switch role to..." to the course settings
With this setting you can move the "Switch role to..." link as a new tab from the user menu to the in-course course menu. The role switching is a feature which is used in course context and thus it is better to place it in the course settings menu than in the user menu.
Please note that this setting won't have any effect if you do not activate the "In course settings menu" above.
### 4. Tab "Footer Layout Settings"
#### Footer blocks
......
......@@ -72,10 +72,17 @@ $string['courseeditbuttonsetting_desc'] = 'With this setting you can add an addi
$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:';
// ...Course settings.
$string['coursesettingsheading'] = 'Course settings';
// ...Show course settings within the course.
$string['showsettingsincoursesetting'] = 'In course settings menu';
$string['showsettingsincoursesetting_desc'] = 'With this setting you can change the displaying of the course context menu. In Boost, there is a popup context menu right next to the cog icon and clicking on the "More..." menu item will lead the user to another page with all course settings. By enabling this setting the settings will occur directly beneath the course header.<br/>
Please note that this change does not affect users who have switched off javascript in their browsers - they will still get the behaviour from Moodle core with a popup course context menu.';
// ...Show switch role to link within the in-course course settings.
$string['incoursesettingsswitchtorolesetting'] = 'Move "Switch role to..." to the course settings';
$string['incoursesettingsswitchtorolesetting_desc'] = 'With this setting you can move the "Switch role to..." link as a new tab from the user menu to the in-course course menu. The role switching is a feature which is used in course context and thus it is better to place it in the course settings menu than in the user menu. <br/>
Please note that this setting won\'t have any effect if you do not activate the "In course settings menu" above.';
// Footer layout settings.
$string['footerlayoutsettings'] = 'Footer Layout Settings';
......@@ -155,3 +162,4 @@ $string['darknavbarsetting_desc'] = 'By checking this setting you can invert the
// ADDITIONAL STRINGS (IN ALPHABETICAL ORDER).
$string['cachedef_badgearea'] = 'Cache for badgearea items';
$string['switchroleto'] = 'Switch role to';
......@@ -63,18 +63,6 @@ if (get_config('theme_boost_campus', 'catchctrlarrowdown') == true) {
$catchshortcuts[] = 'ctrlarrowdown';
}
// MODIFICATION END.
// MODIFICATION START: Setting 'showsettingsincourse'.
// Initialize node variable.
$node = false;
// If the setting 'showsettingsincourse' is enabled.
if (get_config('theme_boost_campus', 'showsettingsincourse') == 'yes') {
// Only search for the courseadmin node if we are within a course or a module context.
if ($PAGE->context->contextlevel == CONTEXT_COURSE || $PAGE->context->contextlevel == CONTEXT_MODULE) {
// Get the course context menu.
$node = $PAGE->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);
}
}
// MODIFICATION END.
$templatecontext = [
'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]),
......@@ -87,13 +75,15 @@ $templatecontext = [
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
// MODIFICATION START: Add Boost Campus realated values to the template context.
'catchshortcuts' => json_encode($catchshortcuts),
'node' => $node
// MODIFICATION END.
];
// MODIDFICATION START.
// Use the returned value from theme_boost_campus_get_modified_flatnav_defaulthomepageontop as the template context.
$templatecontext['flatnavigation'] = theme_boost_campus_process_flatnav($PAGE->flatnav);
// Add the returned value from theme_boost_campus_get_incourse_settings to the template context.
$templatecontext['node'] = theme_boost_campus_get_incourse_settings();
// Render colums2.mustache from boost_campus.
echo $OUTPUT->render_from_template('theme_boost_campus/columns2', $templatecontext);
// MODIFICATION END.
......
......@@ -95,7 +95,8 @@ function theme_boost_campus_get_pre_scss($theme) {
'darknavbar' => ['darknavbar'],
'footerblocks' => ['footerblocks'],
'badgeareaitemsmaxheight' => ['badgeareaitemsmaxheight'],
'showsettingsincourse' => ['showsettingsincourse']
'showsettingsincourse' => ['showsettingsincourse'],
'incoursesettingsswitchtorole' => ['incoursesettingsswitchtorole']
// MODIFICATION END.
];
......
......@@ -237,3 +237,52 @@ function theme_boost_campus_set_node_on_top(flat_navigation $flatnav, $nodename,
// Return the modified changes.
return $flatnav;
}
/**
* Provides the node for the in-course course settings.
*
* @return navigation_node.
*/
function theme_boost_campus_get_incourse_settings() {
global $COURSE, $PAGE;
// Initialize the node with false to prevent problems on pages that do not have a courseadmin node.
$node = false;
// If setting showsettingsincourse is enabled.
if (get_config('theme_boost_campus', 'showsettingsincourse') == 'yes') {
// Only search for the courseadmin node if we are within a course or a module context.
if ($PAGE->context->contextlevel == CONTEXT_COURSE || $PAGE->context->contextlevel == CONTEXT_MODULE) {
// Get the courseadmin node for the current page.
$node = $PAGE->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);
// If the setting 'incoursesettingsswitchtorole' is enabled add these to the $node.
if (get_config('theme_boost_campus', 'incoursesettingsswitchtorole') == 'yes' && !is_role_switched($COURSE->id)) {
// Build switch role link
// We could only access the existing menu item by creating the user menu and traversing it.
// So we decided to create this node from scratch with the values copied from Moodle core.
$roles = get_switchable_roles($PAGE->context);
if (is_array($roles) && (count($roles) > 0)) {
// Define the properties for a new tab.
$properties = array('text' => get_string('switchroleto', 'theme_boost_campus'),
'type' => navigation_node::TYPE_CONTAINER,
'key' => 'switchroletotab');
// Create the node.
$switchroletabnode = new navigation_node($properties);
// Add the tab to the course administration node.
$node->add_node($switchroletabnode);
// Add the available roles as children nodes to the tab content.
foreach ($roles as $key => $role) {
$properties = array('action' => new moodle_url('/course/switchrole.php',
array('id' => $COURSE->id,
'switchrole' => $key,
'returnurl' => $PAGE->url->out_as_local_url(false),
'sesskey' => sesskey())),
'type' => navigation_node::TYPE_CUSTOM,
'text' => $role);
$switchroletabnode->add_node(new navigation_node($properties));
}
}
}
}
}
return $node;
}
......@@ -793,6 +793,27 @@ a[href^="mailto"]::before {
}
}
/* Setting to move 'Switch role to...' menu item to the course settings. */
@if variable-exists(incoursesettingsswitchtorole) {
@if $incoursesettingsswitchtorole == 'yes' {
/* Hide the switch role to menu item within the user menu */
.usermenu .dropdown-menu a[data-title*="switchroleto"],
.usermenu .dropdown-menu a[data-title*="switchrolereturn"] {
display: none;
}
/* As the last menu item is missing, we have to modify the dropdown menu container. */
.dropdown-menu.dropdown-menu-right {
padding-bottom: 0;
border-bottom: none;
}
/* We have to add a border for the users who do not have a switch role menu item due to their capabilities. */
.dropdown-menu.dropdown-menu-right a:last-child {
border-bottom: 1px solid $gray-lighter;
}
}
}
/*------------------------------------
Special: Local Plugins
-------------------------------------*/
......
......@@ -231,7 +231,13 @@ 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.
// Settings title for grouping course settings related aspects together. We don't need a description here.
$name = 'theme_boost_campus/coursesettingsheading';
$title = get_string('coursesettingsheadingsetting', 'theme_boost_campus', null, true);
$setting = new admin_setting_heading($name, $title, null);
$page->add($setting);
// Setting to display the course settings page as a panel within the course.
$name = 'theme_boost_campus/showsettingsincourse';
$title = get_string('showsettingsincoursesetting', 'theme_boost_campus', null, true);
$description = get_string('showsettingsincoursesetting_desc', 'theme_boost_campus', null, true);
......@@ -242,6 +248,17 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Setting to display the switch role to link as a separate tab within the in-course settings panel.
$name = 'theme_boost_campus/incoursesettingsswitchtorole';
$title = get_string('incoursesettingsswitchtorolesetting', 'theme_boost_campus', null, true);
$description = get_string('incoursesettingsswitchtorolesetting_desc', 'theme_boost_campus', null, true);
$setting = new admin_setting_configcheckbox($name, $title, $description, '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.
// See MDL-58376.
$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 = 2017081000;
$plugin->version = 2017090100;
$plugin->release = 'v3.2-r1';
$plugin->requires = 2016120503.05;
$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