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

Setting to show a hint when a user is guest accessing a course.

parent 61c615f3
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ Changes
### Unreleased
* 2018-02-19 - Setting to show a hint when a user is guest accessing a course.
* 2018-02-14 - Improved icon positions in the course category tree.
* 2018-02-13 - Cleaned up post.scss.
* 2018-02-12 - Setting to expand nav drawer menu to full page width on small screens.
......
......@@ -122,14 +122,20 @@ This setting can change the behaviour Moodle displays the title for the first co
With this setting you can add an additional course edit on / off button to the course header for faster accessibility. This the same way as it was displayed before theme_boost.
#### Position of switch role information
#### Course related hints
##### 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.
#### Show hint in hidden courses
##### Show hint in hidden courses
With this setting a hint will appear in the course header as long as the visibility of the course is hidden. This helps to identify the visibility state of a course at a glance without the need for looking at the course settings.
##### Show hint guest for access
With this setting a hint will appear in the course header when a user is accessing it with the guest access feature. If the course provides an active self enrolment, a link to that page is also presented to the user.
#### Course settings
##### In course settings menu
......
......@@ -235,6 +235,21 @@ class core_renderer extends \theme_boost\output\core_renderer {
}
// MODIFICATION END.
// MODIFICATION START:
// If the setting showhintcourseguestaccess is set, a hint for users that view the course with guest access is shown.
if (get_config('theme_boost_campus', 'showhintcourseguestaccess') == 'yes'
&& is_guest(\context_course::instance($COURSE->id), $USER->id)
&& $PAGE->has_set_url()
&& $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$html .= html_writer::start_tag('div', array('class' => 'course-guestaccess-infobox alert alert-warning'));
$html .= html_writer::tag('i', null, array('class' => 'fa fa-exclamation-circle fa-3x fa-pull-left'));
$html .= get_string('showhintcourseguestaccessgeneral', 'theme_boost_campus',
array('role' => role_get_name(get_guest_role())));
$html .= theme_boost_campus_get_course_guest_access_hint($COURSE->id);
$html .= html_writer::end_tag('div');
}
// MODIFICATION END.
// MODIFICATION START.
// Only use this if setting 'showswitchedroleincourse' is active.
if (get_config('theme_boost_campus', 'showswitchedroleincourse') === 'yes') {
......
......@@ -70,6 +70,8 @@ $string['section0titlesetting_desc'] = 'This setting can change the behaviour Mo
// ...Course edit button.
$string['courseeditbuttonsetting'] = 'Course edit button';
$string['courseeditbuttonsetting_desc'] = 'With this setting you can add an additional course edit on / off button to the course header for faster accessibility of this often used function.';
// ...Course related hints.
$string['coursehintsheadingsetting'] = 'Course related hints.';
// ...Switch role information.
$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.';
......@@ -77,6 +79,9 @@ $string['switchedroleto'] = 'You are viewing this course currently with the role
// ...Show hint for hidden course.
$string['showhintcoursehiddensetting'] = 'Show hint in hidden courses';
$string['showhintcoursehiddensetting_desc'] = 'With this setting a hint will appear in the course header as long as the visibility of the course is hidden. This helps to identify the visibility state of a course at a glance without the need for looking at the course settings.';
// ... Show hint for guest access.
$string['showhintcoursguestaccesssetting'] = 'Show hint guest for access';
$string['showhintcourseguestaccesssetting_desc'] = 'With this setting a hint will appear in the course header when a user is accessing it with the guest access feature. If the course provides an active self enrolment, a link to that page is also presented to the user.';
// ...Course settings.
$string['coursesettingsheadingsetting'] = 'Course settings';
// ...Show course settings within the course.
......@@ -181,6 +186,8 @@ Please note: This is an all or nothing setting. It is only possible to display o
// ADDITIONAL STRINGS (IN ALPHABETICAL ORDER).
$string['cachedef_imagearea'] = 'Cache for imagearea items';
$string['showhintcourseguestaccessgeneral'] = 'You are currently viewing this course as <strong>{$a->role}</strong>.';
$string['showhintcourseguestaccesslink'] = 'To have full access to the course, you can <a href="{$a->url}">self enrol into this course</a>.';
$string['showhintcoursehiddengeneral'] = 'This course is currently <strong>hidden</strong>. Only enrolled teachers can access this course when hidden.';
$string['showhintcoursehiddensettingslink'] = 'You can change the visibility in the <a href="{$a->url}">course settings</a>.';
$string['switchroleto'] = 'Switch role to';
......@@ -358,3 +358,25 @@ function theme_boost_campus_get_incourse_activity_settings() {
}
return $node;
}
function theme_boost_campus_get_course_guest_access_hint($courseid) {
global $CFG;
require_once($CFG->dirroot . '/enrol/self/lib.php');
$html = '';
$instances = enrol_get_instances($courseid, true);
$plugins = enrol_get_plugins(true);
foreach ($instances as $instance) {
if (!isset($plugins[$instance->enrol])) {
continue;
}
$plugin = $plugins[$instance->enrol];
if ($plugin->show_enrolme_link($instance)) {
$html = html_writer::tag('div', get_string('showhintcourseguestaccesslink',
'theme_boost_campus', array('url' => $CFG->wwwroot . '/enrol/index.php?id=' . $courseid)));
break;
}
}
return $html;
}
......@@ -862,7 +862,8 @@ a[href^="mailto"]::before {
/* Setting to show a hint for hidden courses. */
/* Because the Font Awesome icon is set to fa-3x, we need a minimum size for the container. */
.course-hidden-infobox,
.switched-role-infobox {
.switched-role-infobox,
.course-guestaccess-infobox {
min-height: 5rem;
}
......
......@@ -235,6 +235,12 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Settings title for grouping course settings related aspects together. We don't need a description here.
$name = 'theme_boost_campus/coursehintsheading';
$title = get_string('coursehintsheadingsetting', 'theme_boost_campus', null, true);
$setting = new admin_setting_heading($name, $title, null);
$page->add($setting);
// Setting to display information of a switched role in the course header.
$name = 'theme_boost_campus/showswitchedroleincourse';
$title = get_string('showswitchedroleincoursesetting', 'theme_boost_campus', null, true);
......@@ -257,6 +263,17 @@ if ($ADMIN->fulltree) {
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Setting to display a hint to the guest accessing of a course.
$name = 'theme_boost_campus/showhintcourseguestaccess';
$title = get_string('showhintcoursguestaccesssetting', 'theme_boost_campus', null, true);
$description = get_string('showhintcourseguestaccesssetting_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);
// 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);
......
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'theme_boost_campus';
$plugin->version = 2018021401;
$plugin->version = 2018021600;
$plugin->release = 'v3.3-r3';
$plugin->requires = 2017111300;
$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