From e50831318e8a09180fb6649366611cd2a8cf0878 Mon Sep 17 00:00:00 2001
From: Julien Boulen <julien.boulen@univ-rennes2.fr>
Date: Tue, 10 Jan 2023 11:16:31 +0100
Subject: [PATCH] MDL-76313 forum: improve accessibility on subscribers page

- add header on table of subscribers
- remove one redundant header
---
 mod/forum/renderer.php                                |  7 +++++++
 mod/forum/subscribers.php                             |  1 -
 .../behat/forum_subscriptions_mode_behaviour.feature  | 11 +++++------
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/mod/forum/renderer.php b/mod/forum/renderer.php
index 0e104f58b19..f138603644d 100644
--- a/mod/forum/renderer.php
+++ b/mod/forum/renderer.php
@@ -134,6 +134,13 @@ class mod_forum_renderer extends plugin_renderer_base {
             $strparams->count = count($users);
             $output .= $this->output->heading(get_string("subscriberstowithcount", "forum", $strparams));
             $table = new html_table();
+            $table->id = 'subscribers-table';
+            $table->head = array();
+            $table->head[] = get_string('pictureofuser');
+            $table->head[] = get_string('fullname');
+            if ($canviewemail) {
+                $table->head[] = get_string('email');
+            }
             $table->cellpadding = 5;
             $table->cellspacing = 5;
             $table->tablealign = 'center';
diff --git a/mod/forum/subscribers.php b/mod/forum/subscribers.php
index 408b281c80d..2ad51ff3e3d 100644
--- a/mod/forum/subscribers.php
+++ b/mod/forum/subscribers.php
@@ -121,7 +121,6 @@ if ($edit === 1 && !\mod_forum\subscriptions::is_forcesubscribed($forum)) {
     echo $OUTPUT->heading(get_string('managesubscriptionson', 'forum'), 2);
     echo $forumoutput->subscriber_selection_form($existingselector, $subscriberselector);
 } else {
-    echo $OUTPUT->heading(get_string('subscribers', 'forum'), 2);
     $subscribers = \mod_forum\subscriptions::fetch_subscribed_users($forum, $currentgroup, $context);
     if (\mod_forum\subscriptions::is_forcesubscribed($forum)) {
         $subscribers = mod_forum_filter_hidden_users($cm, $context, $subscribers);
diff --git a/mod/forum/tests/behat/forum_subscriptions_mode_behaviour.feature b/mod/forum/tests/behat/forum_subscriptions_mode_behaviour.feature
index a936964c6fe..22243710750 100644
--- a/mod/forum/tests/behat/forum_subscriptions_mode_behaviour.feature
+++ b/mod/forum/tests/behat/forum_subscriptions_mode_behaviour.feature
@@ -32,9 +32,8 @@ Feature: Changes to the subscription mode of a forum can change subcribers of a
     When I select "Auto subscription" from the "Subscription mode" singleselect
     Then I should not see "There are no subscribers yet for this forum"
     And I navigate to "Subscriptions" in current page administration
-    And I should see "Student 1"
-    And I should see "student.1@example.com"
-    And I should see "Student 2"
-    And I should see "student.2@example.com"
-    And I should see "Teacher Tom"
-    And I should see "teacher@example.com"
+    And the following should exist in the "subscribers-table" table:
+      | Full name | Email address |
+      | Student 1 | student.1@example.com |
+      | Student 2 | student.2@example.com |
+      | Teacher Tom | teacher@example.com |