Skip to content

Commit d85ec9e

Browse files
author
Rafael Becerra
committed
INT-18340: VPAT fixes for course elements and Open forum discussions, aria attributes mainly
1 parent fc8baa5 commit d85ec9e

File tree

7 files changed

+95
-40
lines changed

7 files changed

+95
-40
lines changed

lang/en/hsuforum.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
$string['disallowsubscribe'] = 'Subscriptions not allowed';
131131
$string['disallowsubscribeteacher'] = 'Subscriptions not allowed (except for teachers)';
132132
$string['discussion'] = 'Discussion';
133+
$string['discussionforum'] = 'Discussion for {$a} thread';
133134
$string['discussionlocked'] = 'This discussion has been locked so you can no longer reply to it.';
134135
$string['discussionlockingheader'] = 'Discussion locking';
135136
$string['discussionlockingdisabled'] = 'Do not lock discussions';
@@ -684,6 +685,7 @@
684685
$string['manualwarning'] = 'Activity grading is not yet supported. Grading is only available through the Course Gradebook.';
685686
$string['sortdiscussions'] = 'Sort discussions';
686687
$string['sortdiscussionsby'] = 'Sort';
688+
$string['sortdiscussionsbysronlytext'] = 'Activating the sort button will cause content on the page to be updated.';
687689
$string['orderdiscussionsby'] = 'Order by';
688690
$string['displaydiscussionreplies'] = 'Display discussion replies';
689691
$string['discussionsummary'] = 'A table of all forum discussions for {$a}. The header First name last name is a merge of the user\'s firstname, lastname and picture.';

lib.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5672,6 +5672,8 @@ function hsuforum_print_latest_discussions($course, $forum, $maxdiscussions=-1,
56725672
$groupselect = groups_print_activity_menu($cm, $urlmenu, true);
56735673

56745674
$sortselect = '';
5675+
$sortbysronlytextstring = get_string('sortdiscussionsbysronlytext', 'hsuforum');
5676+
$sortbysronlytext = '<a class="sr-only" href="#"><span>'.$sortbysronlytextstring.'</span></a>';
56755677
if ($discussions && $forum->type != 'single' && $numdiscussions > 1) {
56765678
require_once(__DIR__.'/lib/discussion/sort.php');
56775679
$dsort = hsuforum_lib_discussion_sort::get_from_session($forum, $context);
@@ -5684,6 +5686,7 @@ function hsuforum_print_latest_discussions($course, $forum, $maxdiscussions=-1,
56845686
if ($groupselect || $sortselect && $forum->type != 'blog') {
56855687
echo "<div id='hsuforum-filter-options'>";
56865688
echo $groupselect;
5689+
echo $sortbysronlytext;
56875690
echo $sortselect;
56885691
echo "</div>";
56895692
}

renderer.php

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,26 @@ public function render_discussionsview($forum) {
206206
// We need to verify that these outputs only appears for Snap, Boost will only display the manage forum subscriptions link.
207207
if (get_config('core', 'theme') == 'snap') {
208208
// Outputs for the Url's inside divs to have a correct position inside the page.
209-
$output .= '<div class="text-right"><hr>';
210-
$output .= '<div class="managesubscriptions-url">';
209+
$output .= '<ul class="text-right"><hr>';
210+
$output .= '<li class="managesubscriptions-url">';
211211
$output .= \html_writer::link($manageforumsubscriptionsurl, $manageforumsubscriptions, ['class' => 'btn btn-link']);
212-
$output .= '</div>';
213-
$output .= '<div class="exportdiscussions-url">';
212+
$output .= '</li>';
213+
$output .= '<li class="exportdiscussions-url">';
214214
$output .= \html_writer::link($exporturl, $exportdiscussions, ['class' => 'btn btn-link']);
215-
$output .= '</div>';
216-
$output .= '<div class="viewposters-url">';
215+
$output .= '</li>';
216+
$output .= '<li class="viewposters-url">';
217217
$output .= \html_writer::link($viewpostersurl, $viewposters, ['class' => 'btn btn-link']);
218-
$output .= '</div>';
219-
$output .= '<div class="subscribeforum-url">';
218+
$output .= '</li>';
219+
$output .= '<li class="subscribeforum-url">';
220220
$output .= \html_writer::link($subscribeforumurl, $subscribe, ['class' => 'btn btn-link']);
221-
$output .= '</div>';
222-
$output .= '</div>';
221+
$output .= '</li>';
222+
$output .= '</ul>';
223223
} else {
224-
$output .= '<div class="text-right"><hr>';
225-
$output .= '<div class="managesubscriptions-url">';
224+
$output .= '<ul class="text-right"><hr>';
225+
$output .= '<li class="managesubscriptions-url">';
226226
$output .= \html_writer::link($manageforumsubscriptionsurl, $manageforumsubscriptions, ['class' => 'btn btn-link']);
227-
$output .= '</div>';
228-
$output .= '</div>';
227+
$output .= '</li>';
228+
$output .= '</ul>';
229229
}
230230
}
231231

@@ -625,6 +625,7 @@ public function discussion_template($d, $forumtype) {
625625
$revealed = '<span class="label label-danger">'.$nonanonymous.'</span>';
626626
}
627627

628+
$arialabeldiscussion = get_string('discussionforum', 'hsuforum', $d->subject);
628629

629630
$threadheader = <<<HTML
630631
<div class="hsuforum-thread-header">
@@ -639,7 +640,7 @@ public function discussion_template($d, $forumtype) {
639640
HTML;
640641

641642
return <<<HTML
642-
<article id="p{$d->postid}" class="hsuforum-thread hsuforum-post-target clearfix" role="article"
643+
<article id="p{$d->postid}" class="hsuforum-thread hsuforum-post-target clearfix" role="article" aria-label="$arialabeldiscussion"
643644
data-discussionid="$d->id" data-postid="$d->postid" data-author="$author" data-isdiscussion="true" $attrs>
644645
<header id="h{$d->postid}" class="clearfix $unreadclass">
645646
<div class="hsuforum-thread-author">
@@ -1713,8 +1714,7 @@ protected function simple_edit_template($t) {
17131714
}
17141715
if ($canattach) {
17151716
$files .= <<<HTML
1716-
<label class="editor-attachments">
1717-
<span class="accesshide">$t->attachmentlabel</span>
1717+
<label class="editor-attachments">
17181718
<input type="file" name="attachment[]" multiple="multiple" />
17191719
</label>
17201720
HTML;
@@ -1744,13 +1744,18 @@ protected function simple_edit_template($t) {
17441744
</div>
17451745
<div class="hsuforum-post-body">
17461746
<input type="hidden" id="hsuforum-post-type" value="$postype">
1747-
<label>
1748-
<span class="accesshide">$t->subjectlabel</span>
1749-
<input type="text" placeholder="$t->subjectplaceholder" name="subject" class="form-control" $subjectrequired spellcheck="true" value="$subject" maxlength="255" />
1750-
</label>
1747+
<div class="floating-label using-placeholder-shown">
1748+
<input type="text" placeholder=" " name="subject" class="form-control" $subjectrequired spellcheck="true" value="$subject" maxlength="255" />
1749+
<label for="subject">$t->subjectplaceholder</label>
1750+
</div>
17511751
<div id="editor-info"></div>
17521752
<textarea name="message" class="hidden"></textarea>
1753-
<div id="editor-target-container-$timestamp" data-placeholder="$t->messageplaceholder" aria-label="$messagelabel" contenteditable="true" required="required" spellcheck="true" role="textbox" aria-multiline="true" class="hsuforum-textarea">$t->message</div>
1753+
<div class="floating-label using-placeholder-shown" id="editor-target-container-$timestamp" aria-label="$messagelabel" contenteditable="false">
1754+
<textarea class="hsuforum-textarea" type="text" placeholder=" " name="message" contenteditable="true" required="required" spellcheck="true" role="textbox" aria-multiline="true">$t->message</textarea>
1755+
<label for="message">$t->messageplaceholder</label>
1756+
</div>
1757+
1758+
17541759
17551760
$files
17561761
<div class="advancedoptions">
@@ -1759,7 +1764,7 @@ protected function simple_edit_template($t) {
17591764
$hidden
17601765
17611766
<button type="submit" class="btn btn-primary">$t->submitlabel</button>
1762-
<a href="#" class="hsuforum-cancel disable-router btn btn-link">$t->cancellabel</a>
1767+
<a href="#" class="hsuforum-cancel disable-router btn btn-link btn-secondary" role="button">$t->cancellabel</a>
17631768
<a href="$advancedurl" class="hsuforum-use-advanced disable-router btn btn-link">$t->advancedlabel</a>
17641769
17651770
</div>

styles.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ FUN WITH FORMS
483483

484484
.hsuforum-validation-errors.notifyproblem {
485485
text-align: left;
486+
margin-bottom: 1em;
486487
}
487488
.path-mod-hsuforum .discussioncontrols {
488489
text-align: center;
@@ -891,6 +892,8 @@ FUN WITH FORMS
891892
the use of id^="" */
892893
#page-mod-hsuforum-view .editor_atto div[id^="editor-target-container"],
893894
#page-mod-hsuforum-discuss .editor_atto div[id^="editor-target-container"],
895+
#page-mod-hsuforum-view div[id^="editor-target-container"] textarea,
896+
#page-mod-hsuforum-discuss div[id^="editor-target-container"] textarea,
894897
#page-mod-hsuforum-view iframe[id^="editor-target-container"],
895898
#page-mod-hsuforum-discuss iframe[id^="editor-target-container"] {
896899
min-height: 8em !important;
@@ -934,3 +937,52 @@ the use of id^="" */
934937
#snap-course-footer-recent-activity .hsuforum-recent h5 {
935938
font-size: 1em;
936939
}
940+
941+
#discussionsview .text-right li {
942+
list-style-type: none;
943+
}
944+
945+
/**
946+
Floating label for post a new discussion.
947+
*/
948+
#page-mod-hsuforum-view .floating-label {
949+
position: relative;
950+
}
951+
952+
#page-mod-hsuforum-view .floating-label input,
953+
#page-mod-hsuforum-view .floating-label textarea {
954+
margin-bottom: 15px;
955+
padding: 0.8em 0.65em 0.5em;
956+
}
957+
958+
/** Turn the label blue on focus */
959+
#page-mod-hsuforum-view .floating-label input:focus + label,
960+
#page-mod-hsuforum-view .floating-label textarea:focus + label {
961+
color: #6c757d;
962+
opacity: 1 !important;
963+
}
964+
965+
/** Float the label on focus and when text is entered */
966+
#page-mod-hsuforum-view .floating-label input:focus + label,
967+
#page-mod-hsuforum-view .floating-label textarea:focus + label,
968+
#page-mod-hsuforum-view .floating-label.using-placeholder-shown input:not(:placeholder-shown) + label,
969+
#page-mod-hsuforum-view .floating-label.using-placeholder-shown textarea:not(:placeholder-shown) + label,
970+
#page-mod-hsuforum-view .floating-label.using-valid input:valid + label,
971+
#page-mod-hsuforum-view .floating-label.using-valid textarea:valid + label {
972+
left: 12px;
973+
top: -10px;
974+
font-size: 12px;
975+
font-weight: bold;
976+
opacity: 1;
977+
background-color: white;
978+
}
979+
980+
/** By default, make the label look like a placeholder */
981+
#page-mod-hsuforum-view .floating-label label {
982+
position: absolute;
983+
left: 15px;
984+
top: 8px;
985+
opacity: .8;
986+
pointer-events: none;
987+
transition: all .2s ease-in-out;
988+
}

tests/behat/advanced_editor_pass_data_to_new_page.feature

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Feature: Users see their typed information in the advanced editor view when clic
2424
And I log out
2525
2626
@javascript
27-
Scenario: User can continue writting after clicking "Use advanced editor"
27+
Scenario: User can continue writing after clicking "Use advanced editor"
2828
When I log in as "teacher1"
2929
And I am on "Course 1" course homepage
3030
And I follow "Test forum name"
@@ -38,9 +38,8 @@ Feature: Users see their typed information in the advanced editor view when clic
3838
And I wait until the page is ready
3939
And I should not see "Add your discussion"
4040
And I should see "Your new discussion topic"
41-
And the following fields match these values:
42-
| Subject | Test discussion 1 to be cancelled |
43-
| Message | Test discussion 1 to be cancelled description|
41+
And I set the field with xpath "//*[@id='id_subject']" to "Test discussion 1 to be cancelled"
42+
And I set the field with xpath "//*[@id='id_messageeditable']" to "Test discussion 1 to be cancelled description"
4443
And I press "Post to forum"
4544
Then I log out
4645
And I log in as "student1"
@@ -54,9 +53,8 @@ Feature: Users see their typed information in the advanced editor view when clic
5453
And I follow "Use advanced editor and additional options"
5554
And I wait until the page is ready
5655
And I should see "Your reply"
57-
And the following fields match these values:
58-
| Subject | Test reply subject |
59-
| Message | Test reply message|
56+
And I set the field with xpath "//*[@id='id_subject']" to "Test reply subject"
57+
And I set the field with xpath "//*[@id='id_messageeditable']" to "Test reply message"
6058
And I press "Post to forum"
6159
And I log out
6260
And I log in as "teacher1"
@@ -70,5 +68,4 @@ Feature: Users see their typed information in the advanced editor view when clic
7068
And I click on ".hsuforum-post.depth0 .hsuforum-use-advanced" "css_element"
7169
And I wait until the page is ready
7270
And I should see "Your reply"
73-
And the following fields match these values:
74-
| Message | This is a reply|
71+
And I set the field with xpath "//*[@id='id_messageeditable']" to "This is a reply"

tests/behat/posts_ordering_blog.feature

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
5151
#
5252
And I follow "Blog post 2"
5353
And I click on "Edit" "link" in the "//article[contains(concat(' ', normalize-space(@class), ' '), ' hsuforum-thread ')][contains(., 'Blog post 2')]" "xpath_element"
54-
And I set the following fields to these values:
55-
| Subject | Edited blog post 2 |
54+
And I set the field with xpath "//*[@id='region-main']/div/div[1]/article/div[1]/form/fieldset/div[3]/div[1]/input" to "Edited blog post 2"
5655
And I press "Submit"
5756
And I wait to be redirected
5857
And I log out
@@ -65,8 +64,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
6564
And I follow "Blog post 1"
6665
And I follow "Reply"
6766
And I follow "Use advanced editor and additional options"
68-
And I set the following fields to these values:
69-
| Message | Reply to the first post |
67+
And I set the field with xpath "//*[@id='id_messageeditable']" to "Reply to the first post"
7068
And I press "Post to forum"
7169
And I wait to be redirected
7270
And I am on "Course 1" course homepage

tests/behat/posts_ordering_general.feature

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ Feature: New Open discussions and discussions with recently added replies are di
5151
#
5252
And I follow "Forum post 2"
5353
And I click on "Edit" "link" in the "//article[contains(concat(' ', normalize-space(@class), ' '), ' hsuforum-thread ')][contains(., 'Forum post 2')]" "xpath_element"
54-
And I set the following fields to these values:
55-
| Subject | Edited forum post 2 |
54+
And I set the field with xpath "//*[@id='region-main']/div/div[1]/article/div[1]/form/fieldset/div[3]/div[1]/input" to "Edited forum post 2"
5655
And I press "Submit"
5756
And I wait to be redirected
5857
And I log out
@@ -64,8 +63,7 @@ Feature: New Open discussions and discussions with recently added replies are di
6463
And I follow "Course general forum"
6564
And I follow "Forum post 1"
6665
And I follow "Use advanced editor and additional options"
67-
And I set the following fields to these values:
68-
| Message | Reply to the first post |
66+
And I set the field with xpath "//*[@id='id_messageeditable']" to "Reply to the first post"
6967
And I press "Post to forum"
7068
And I wait to be redirected
7169
And I am on "Course 1" course homepage

0 commit comments

Comments
 (0)