Skip to content

Commit 877925e

Browse files
committed
fix moodle-an-hochschulen#98-further-hints-on-hidden-courses
1 parent b5a84c5 commit 877925e

7 files changed

+126
-20
lines changed

lang/en/theme_boost_union.php

+4
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,10 @@
933933
$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.';
934934
$string['showhintcoursehiddengeneral'] = 'This course is currently <strong>hidden</strong>. Only enrolled teachers can access this course when hidden.';
935935
$string['showhintcoursehiddensettingslink'] = 'You can change the visibility in the <a href="{$a->url}">course settings</a>.';
936+
// ... ... Setting: Show hint that notifications don't work within forums for hidden courses.
937+
$string['showhintforumnotificationssetting'] = 'Show hint regarding notifications in hidden courses';
938+
$string['showhintforumnotificationssetting_desc'] = 'When a course is hidden notifications within a forum are not send to students. To clarify this a hint will appear on forums within a hidden course to help the teachers understand this circumstance.';
939+
$string['showhintforumnotifications'] = 'This course is currently <strong>hidden</strong>. Please note that this means that <strong>students will not be notified</strong> online or by email of any messages you post in this forum.';
936940
// ... ... Setting: Show hint for guest access.
937941
$string['showhintcoursguestaccesssetting'] = 'Show hint for guest access';
938942
$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.';

locallib.php

+32-11
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,47 @@ function theme_boost_union_get_course_related_hints() {
4040
// Initialize HTML code.
4141
$html = '';
4242

43-
// If the setting showhintcoursehidden is set and the visibility of the course is hidden and
43+
// If the setting showhintcoursehidden is set and the visibility of the course is hidden
4444
// a hint for the visibility will be shown.
4545
if (get_config('theme_boost_union', 'showhintcoursehidden') == THEME_BOOST_UNION_SETTING_SELECT_YES
4646
&& has_capability('theme/boost_union:viewhintinhiddencourse', \context_course::instance($COURSE->id))
4747
&& $PAGE->has_set_url()
48-
&& $PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)
4948
&& $COURSE->visible == false) {
5049

51-
// Prepare template context.
52-
$templatecontext = ['courseid' => $COURSE->id];
50+
// The hint will only be shown when the course is viewed.
51+
if ($PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
52+
// Prepare template context.
53+
$templatecontext = ['courseid' => $COURSE->id];
5354

54-
// If the user has the capability to change the course settings, an additional link to the course settings is shown.
55-
if (has_capability('moodle/course:update', context_course::instance($COURSE->id))) {
56-
$templatecontext['showcoursesettingslink'] = true;
57-
} else {
58-
$templatecontext['showcoursesettingslink'] = false;
55+
// If the user has the capability to change the course settings, an additional link to the course settings is shown.
56+
if (has_capability('moodle/course:update', context_course::instance($COURSE->id))) {
57+
$templatecontext['showcoursesettingslink'] = true;
58+
} else {
59+
$templatecontext['showcoursesettingslink'] = false;
60+
}
61+
62+
// Render template and add it to HTML code.
63+
$html .= $OUTPUT->render_from_template('theme_boost_union/course-hint-hidden', $templatecontext);
5964
}
6065

61-
// Render template and add it to HTML code.
62-
$html .= $OUTPUT->render_from_template('theme_boost_union/course-hint-hidden', $templatecontext);
66+
// If the setting showhintcoursehiddennotifications is set too and we view a forum (e.g. announcement) within a hidden
67+
// course a hint will be shown that no notifications via forums will be sent out to students.
68+
if (get_config('theme_boost_union', 'showhintforumnotifications') == THEME_BOOST_UNION_SETTING_SELECT_YES
69+
&& $PAGE->url->compare(new moodle_url('/mod/forum/view.php'), URL_MATCH_BASE)) {
70+
71+
// Prepare template context.
72+
$templatecontext = ['courseid' => $COURSE->id];
73+
74+
// If the user has the capability to change the course settings, an additional link to the course settings is shown.
75+
if (has_capability('moodle/course:update', context_course::instance($COURSE->id))) {
76+
$templatecontext['showcoursesettingslink'] = true;
77+
} else {
78+
$templatecontext['showcoursesettingslink'] = false;
79+
}
80+
81+
// Render template and add it to HTML code.
82+
$html .= $OUTPUT->render_from_template('theme_boost_union/course-hint-hidden-forum-notifications', $templatecontext);
83+
}
6384
}
6485

6586
// If the setting showhintcourseguestaccess is set and the user is accessing the course with guest access,

settings.php

+9
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,15 @@
25272527
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
25282528
$tab->add($setting);
25292529

2530+
// Setting: Show hint at forums within hidden courses that notifications are not send.
2531+
$name = 'theme_boost_union/showhintforumnotifications';
2532+
$title = get_string('showhintforumnotificationssetting', 'theme_boost_union', null, true);
2533+
$description = get_string('showhintforumnotificationssetting_desc', 'theme_boost_union', null, true);
2534+
$setting = new admin_setting_configselect($name, $title, $description, THEME_BOOST_UNION_SETTING_SELECT_NO, $yesnooption);
2535+
$tab->add($setting);
2536+
$page->hide_if('theme_boost_union/showhintforumnotifications', 'theme_boost_union/showhintcoursehidden', 'neq',
2537+
THEME_BOOST_UNION_SETTING_SELECT_YES);
2538+
25302539
// Setting: Show hint guest for access.
25312540
$name = 'theme_boost_union/showhintcourseguestaccess';
25322541
$title = get_string('showhintcoursguestaccesssetting', 'theme_boost_union', null, true);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{{!
2+
This file is part of Moodle - http://moodle.org/
3+
4+
Moodle is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
Moodle is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
}}
17+
{{!
18+
@template theme_boost_union/course-hint-hidden-forum-notifications
19+
20+
Boost Union template for outputting the hidden course hint on forum pages.
21+
22+
Context variables required for this template:
23+
* courseid - The course ID
24+
* showhintforumnotifications - The info text shown at forum pages inside hidden courses
25+
* showcoursesettingslink - The fact if a link to the course settings should be shown or not
26+
27+
Example context (json):
28+
{
29+
"courseid": "123",
30+
"showcoursesettingslink": true,
31+
"showhintforumnotifications": "This course is currently <strong>hidden</strong>. Please note that this means that <strong>students will not be notified</strong> online or by email of any messages you post in this forum."
32+
}
33+
}}
34+
<div class="course-hint-hidden alert alert-warning">
35+
<div class="media">
36+
<div class="mr-3 icon-size-5"><i class="fa fa-exclamation-circle fa-3x"></i></div>
37+
<div class="media-body align-self-center">
38+
{{#str}} showhintforumnotifications, theme_boost_union {{/str}}
39+
{{#showcoursesettingslink}}
40+
<br />{{#str}} showhintcoursehiddensettingslink, theme_boost_union, { "url": "{{config.wwwroot}}/course/edit.php?id={{courseid}}" } {{/str}}
41+
{{/showcoursesettingslink}}
42+
</div>
43+
</div>
44+
</div>

templates/course-hint-hidden.mustache

+2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
2222
Context variables required for this template:
2323
* courseid - The course ID
24+
* showhintcoursehiddengeneral - The info text shown on hidden courses below the course title,
2425
* showcoursesettingslink - The fact if a link to the course settings should be shown or not
2526
2627
Example context (json):
2728
{
2829
"courseid": "123",
30+
"showhintcoursehiddengeneral: "This course is currently <strong>hidden</strong>. Only enrolled teachers can access this course when hidden.",
2931
"showcoursesettingslink": true
3032
}
3133
}}

tests/behat/theme_boost_union_functionalitysettings_courses.feature

+34-8
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
1616
| user | course | role |
1717
| teacher1 | C1 | editingteacher |
1818
| student1 | C1 | student |
19+
And the following "activity" exists:
20+
| course | C1 |
21+
| activity | forum |
22+
| idnumber | Announcements |
23+
| name | Announcements |
1924

2025
Scenario: Setting: Show hint for switched role - Enable the setting
2126
Given the following config values are set as admin:
22-
| config | value | plugin |
27+
| config | value | plugin |
2328
| showswitchedroleincourse | yes | theme_boost_union |
2429
When I log in as "teacher1"
2530
And I am on "Course 1" course homepage
@@ -32,7 +37,7 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
3237

3338
Scenario: Setting: Show hint in hidden courses - Enable the setting
3439
Given the following config values are set as admin:
35-
| config | value | plugin |
40+
| config | value | plugin |
3641
| showhintcoursehidden | yes | theme_boost_union |
3742
When I log in as "teacher1"
3843
And I am on "Course 1" course homepage
@@ -49,9 +54,30 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
4954
Then I should not see "This course is currently hidden. Only enrolled teachers can access this course when hidden."
5055
And ".course-hint-hidden" "css_element" should not exist
5156

57+
Scenario: Setting: Show hint at forums in hidden courses that notifications do not work - Enable the setting
58+
Given the following config values are set as admin:
59+
| config | value | plugin |
60+
| showhintcoursehidden | yes | theme_boost_union |
61+
| showhintforumnotifications | yes | theme_boost_union |
62+
When I log in as "teacher1"
63+
And I am on "Course 1" course homepage
64+
When I navigate to "Settings" in current page administration
65+
And I set the following fields to these values:
66+
| Course visibility | Hide |
67+
And I click on "Save and display" "button"
68+
When I am on the "Announcements" "forum activity" page
69+
Then I should see "This course is currently hidden. Please note that this means that students will not be notified online or by email of any messages you post in this forum." in the ".course-hint-hidden" "css_element"
70+
When I am on "Course 1" course homepage
71+
When I navigate to "Settings" in current page administration
72+
And I set the following fields to these values:
73+
| Course visibility | Show |
74+
And I click on "Save and display" "button"
75+
Then I should not see "This course is currently hidden. Please note that this means that students will not be notified online or by email of any messages you post in this forum."
76+
And ".course-hint-hidden" "css_element" should not exist
77+
5278
Scenario: Setting: Show hint guest for access - Enable the setting
5379
Given the following config values are set as admin:
54-
| config | value | plugin |
80+
| config | value | plugin |
5581
| showhintcourseguestaccess | yes | theme_boost_union |
5682
And the following "users" exist:
5783
| username |
@@ -93,7 +119,7 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
93119

94120
Scenario: Setting: Show hint for self enrolment without enrolment key - Enable the setting
95121
Given the following config values are set as admin:
96-
| config | value | plugin |
122+
| config | value | plugin |
97123
| showhintcourseselfenrol | yes | theme_boost_union |
98124
When I log in as "teacher1"
99125
And I am on "Course 1" course homepage
@@ -112,7 +138,7 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
112138

113139
Scenario: Setting: Show hint for self enrolment without enrolment key - Enable the setting and check that the call for action is shown
114140
Given the following config values are set as admin:
115-
| config | value | plugin |
141+
| config | value | plugin |
116142
| showhintcourseselfenrol | yes | theme_boost_union |
117143
And the following "users" exist:
118144
| username |
@@ -146,7 +172,7 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
146172

147173
Scenario: Setting: Show hint for self enrolment without an enrolment key - Enable the setting and check that it is hidden when new enrolments are disabled
148174
Given the following config values are set as admin:
149-
| config | value | plugin |
175+
| config | value | plugin |
150176
| showhintcourseselfenrol | yes | theme_boost_union |
151177
When I log in as "teacher1"
152178
And I am on "Course 1" course homepage
@@ -167,7 +193,7 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
167193

168194
Scenario: Setting: Show hint for self enrolment without an enrolment key - Enable the setting and check that it is hidden when a password is set
169195
Given the following config values are set as admin:
170-
| config | value | plugin |
196+
| config | value | plugin |
171197
| showhintcourseselfenrol | yes | theme_boost_union |
172198
When I log in as "teacher1"
173199
And I am on "Course 1" course homepage
@@ -188,7 +214,7 @@ Feature: Configuring the theme_boost_union plugin for the "Courses" tab on the "
188214

189215
Scenario: Setting: Show hint for self enrolment without an enrolment key - Enable the setting and check the hints depending on the configured start and / or end dates
190216
Given the following config values are set as admin:
191-
| config | value | plugin |
217+
| config | value | plugin |
192218
| showhintcourseselfenrol | yes | theme_boost_union |
193219
When I log in as "teacher1"
194220
And I am on "Course 1" course homepage

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
defined('MOODLE_INTERNAL') || die();
2626

2727
$plugin->component = 'theme_boost_union';
28-
$plugin->version = 2023102033;
28+
$plugin->version = 2023102034;
2929
$plugin->release = 'v4.3-r11';
3030
$plugin->requires = 2023100900;
3131
$plugin->supported = [403, 403];

0 commit comments

Comments
 (0)