Skip to content

Commit 7f02637

Browse files
author
Juan Ibarra - Open LMS
committed
INT-15938: Fix on view full names on hsuforum depending on capability
1 parent 65ccd13 commit 7f02637

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

lib.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7522,7 +7522,9 @@ function hsuforum_cm_info_view(cm_info $cm) {
75227522
$out = '';
75237523

75247524
if (empty($config->hiderecentposts) && $forum->showrecent) {
7525-
$out .= hsuforum_recent_activity($cm->get_course(), true, 0, $forum->id, false);
7525+
$context = context_module::instance($cm->id);
7526+
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
7527+
$out .= hsuforum_recent_activity($cm->get_course(), $viewfullnames, 0, $forum->id, false);
75267528
}
75277529

75287530
if ($unread = hsuforum_count_forum_unread_posts($cm, $cm->get_course())) {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This file is part of Moodle - http://moodle.org/
2+
#
3+
# Moodle is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation, either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# Moodle is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15+
#
16+
# Tests for showing the correct name when config values are set
17+
#
18+
# @package mod_hsuforum
19+
# @author Juan Ibarra <juan.ibarra@openlms.net>
20+
# @copyright Copyright (c) 2020 Open LMS (https://www.openlms.net)
21+
# @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22+
23+
@mod @mod_hsuforum
24+
Feature: Recent forum posts summary
25+
As a student or teacher
26+
I see my name shown in the respect viewfullname capability
27+
28+
Background:
29+
Given the following config values are set as admin:
30+
| fullnamedisplay | firstname lastname |
31+
| alternativefullnameformat | lastname firstname |
32+
Given the following "users" exist:
33+
| username | firstname | lastname | email |
34+
| teacher1 | Teacher | 1 | teacher1@example.com |
35+
| student1 | Student | 1 | student1@example.com |
36+
And the following "courses" exist:
37+
| fullname | shortname | category |
38+
| Course 1 | C1 | 0 |
39+
And the following "course enrolments" exist:
40+
| user | course | role |
41+
| teacher1 | C1 | editingteacher |
42+
| student1 | C1 | student |
43+
And the following "activities" exist:
44+
| activity | name | intro | course | idnumber | groupmode |
45+
| hsuforum | Test forum name | Test forum | C1 | hsuforum | 0 |
46+
And I log in as "student1"
47+
And I am on "Course 1" course homepage
48+
And I wait until the page is ready
49+
And I follow "Test forum name"
50+
And I add a new discussion to "Test forum name" Open Forum with:
51+
| Subject | Forum discussion 1 |
52+
| Message | How awesome is this forum discussion? |
53+
And I log out
54+
55+
@javascript
56+
Scenario: Check that the links for Open forums options exists and can be activated
57+
And I log in as "teacher1"
58+
And I am on "Course 1" course homepage
59+
Then "//div[contains(@class, 'hsuforum-recent')]//h5[contains(text(), '1 Student')]" "xpath_element" should exist
60+
And I click on "//div[contains(@class, 'hsuforum-recent')]//a" "xpath_element"
61+
Then "//div[contains(@class, 'hsuforum-thread-author')]//a[contains(text(), '1 Student')]" "xpath_element" should exist
62+
And I log out
63+
And I log in as "student1"
64+
And I am on "Course 1" course homepage
65+
Then "//div[contains(@class, 'activityinstance')]//h5[contains(text(), 'Student 1')]" "xpath_element" should exist
66+
And I click on "//div[contains(@class, 'hsuforum-recent')]//a" "xpath_element"
67+
Then "//div[contains(@class, 'hsuforum-thread-author')]//a[contains(text(), 'Student 1')]" "xpath_element" should exist

0 commit comments

Comments
 (0)