Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hidden span labels for help links. #2630

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/WeBWorK/ConfigValues.pm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ sub getConfigValues ($ce) {
},
{
var => 'perProblemLangAndDirSettingMode',
doc => x('Mode in which the LANG and DIR settings for a single problem are determined.'),
doc => x('Mode in which the LANG and DIR settings for a single problem are determined'),
doc2 => x(
'<p>Mode in which the LANG and DIR settings for a single problem are determined.</p><p>The '
. 'system will set the LANGuage attribute to either a value determined from the problem, a '
Expand Down Expand Up @@ -331,7 +331,7 @@ sub getConfigValues ($ce) {
},
{
var => 'mail{achievementEmailFrom}',
doc => x('Email address to use when sending Achievement notifications.'),
doc => x('Email address to use when sending Achievement notifications'),
doc2 => x(
'This email address will be used as the sender for achievement notifications. '
. 'Achievement notifications will not be sent unless this is set.'
Expand Down Expand Up @@ -481,7 +481,7 @@ sub getConfigValues ($ce) {
},
{
var => 'pg{options}{showCorrectOnRandomize}',
doc => x('Show the correct answer to the current problem before re-randomization.'),
doc => x('Show the correct answer to the current problem before re-randomization'),
doc2 => x(
'Show the correct answer to the current problem on the last attempt before a new version is '
. 'requested.'
Expand Down Expand Up @@ -648,7 +648,7 @@ sub getConfigValues ($ce) {
},
{
var => 'pg{specialPGEnvironmentVars}{entryAssist}',
doc => x('Assist with the student answer entry process.'),
doc => x('Assist with the student answer entry process'),
doc2 => x(
'<p>MathQuill renders students answers in real-time as they type on the keyboard.</p><p>MathView '
. 'allows students to choose from a variety of common math structures (such as fractions and '
Expand Down Expand Up @@ -849,7 +849,7 @@ sub getConfigValues ($ce) {
},
{
var => 'feedback_by_section',
doc => x('Feedback by Section.'),
doc => x('Feedback by Section'),
doc2 => x(
'By default, feedback is always sent to all users specified to receive feedback. This '
. 'variable sets the system to only email feedback to users who have the same section as '
Expand Down
18 changes: 12 additions & 6 deletions lib/WeBWorK/ContentGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -957,10 +957,11 @@ This method outputs a link that opens a modal dialog containing the results of r
HelpFiles template. The template file that is rendered is $name.html. If that file does not
exist, then nothing is output.

The optional argument $args is a hash that may contain the keys label, label_size, or class.
$args->{label} is the displayed label, $args->{label_size} is a font awesome size class and is
only used if $args->{label} is not set, and $args->{class} is added to the html class attribute
if defined.
The optional argument $args is a hash that may contain the keys label, label_size, help_label,
or class. $args->{label} is the displayed label. $args->{label_size} is a font awesome size class
and is only used if $args->{label} is not set. $args->{help_label} is the hidden description of
the help button, "help_label help.", which defaults to the page title, and is only used if
$args->{label} is not set. $args->{class} is added to the html class attribute if defined.

=cut

Expand All @@ -972,11 +973,16 @@ sub helpMacro ($c, $name, $args = {}) {
'i',
class => 'icon fa-solid fa-circle-question ' . ($args->{label_size} // ''),
'aria-hidden' => 'true',
data => { alt => ' ? ' },
''
);
)
. $c->tag(
'span',
class => 'visually-hidden',
$c->maketext('[_1] help.', $args->{help_label} // $c->page_title)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to point out why I like my approach better. The reason is mainly the change here. My approach uses the help page layout title which already is translated and includes "help", and doesn't add a new optional argument to the helpMacro method. So there is no need to go through all of the helpMacro calls and add this help_label argument. For example, the set detail page help title is "Set Detail Help", and that title is used for the help link to that help. I also moved the html generated here via the tag method into the help_macro.html.ep template which is cleaner because you can just use the i and span html tags directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't consider using those titles, and agree since they are already there they should be used. I think this also makes sense since in another view point, these are links to those headers, which should line up. Now that I understand the difference, I to like your approach better.

);
delete $args->{label};
delete $args->{label_size};
delete $args->{help_label};

return $c->include("HelpFiles/$name", name => $name, label => $label, args => $args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
% }
% my $number_of_additional_users = $c->param('number_of_additional_users') || 0;
%
<h2><%= maketext('Add Course') %> <%= $c->helpMacro('AdminAddCourse') %></h2>
<h2>
<%= maketext('Add Course') %>
<%= $c->helpMacro('AdminAddCourse', { help_label => maketext('Add Course') }) %>
</h2>
%
<%= form_for current_route, method => 'POST', begin =%>
<%= $c->hidden_authen_fields =%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Archive Course') %> <%= $c->helpMacro('AdminArchiveCourse') %></h2>
<h2>
<%= maketext('Archive Course') %>
<%= $c->helpMacro('AdminArchiveCourse', { help_label => maketext('Archive Course') }) %>
</h2>
% # Report on databases
<h3 class="my-3"><%= maketext('Report on database structure for course [_1]:', $archive_courseID) %></h3>
% if (@$upgrade_report) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Archive Course') %> <%= $c->helpMacro('AdminArchiveCourse') %></h2>
<h2>
<%= maketext('Archive Course') %>
<%= $c->helpMacro('AdminArchiveCourse', { help_label => maketext('Archive Course') }) %>
</h2>
%
% if (@$courseIDs) {
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Delete Course') %> <%= $c->helpMacro('AdminDeleteCourse') %></h2>
<h2>
<%= maketext('Delete Course') %>
<%= $c->helpMacro('AdminDeleteCourse', { help_label => maketext('Delete Course') }) %>
</h2>
<p>
<%== maketext(
'Are you sure you want to delete the course [_1]? All course files and data will be destroyed. '
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Delete Course') %> <%= $c->helpMacro('AdminDeleteCourse') %></h2>
<h2>
<%= maketext('Delete Course') %>
<%= $c->helpMacro('AdminDeleteCourse', { help_label => maketext('Delete Course') }) %>
</h2>
%
% if (@$courseIDs) {
<%= form_for current_route, method => 'POST', begin =%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Editing location [_1]', $locationID) %> <%= $c->helpMacro('AdminManageLocations') %></h2>
<h2>
<%= maketext('Editing location [_1]', $locationID) %>
<%= $c->helpMacro('AdminManageLocations', { help_label => maketext('Manage Locations') }) %>
</h2>
<p>
<%= maketext(
'Edit the current value of the location description, if desired, then add and select addresses to delete, '
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Hide Courses') %> <%= $c->helpMacro('AdminHideCourses') %></h2>
<h2>
<%= maketext('Hide Courses') %>
<%= $c->helpMacro('AdminHideCourses', { help_label => maketext('Hide Courses') }) %>
</h2>
<p>
<%= maketext(
'Select the course(s) you want to hide (or unhide) and then click "Hide Courses" (or "Unhide Courses"). '
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Manage Locations') %> <%= $c->helpMacro('AdminManageLocations') %></h2>
<h2>
<%= maketext('Manage Locations') %>
<%= $c->helpMacro('AdminManageLocations', { help_label => maketext('Manage Locations') }) %>
</h2>
<p><strong><%= maketext('Currently defined locations are listed below.') %></strong></p>
<%= form_for current_route, method => 'POST', begin =%>
% my @locationIDs = map { $_->location_id } @$locations;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Manage LTI Course Map') %> <%= $c->helpMacro('AdminManageLTICourseMap') %></h2>
<h2>
<%= maketext('Manage LTI Course Map') %>
<%= $c->helpMacro('AdminManageLTICourseMap', { help_label => maketext('Manage LTI Course Map') }) %>
</h2>
<%= form_for current_route, method => 'POST', begin =%>
<%= $c->hidden_authen_fields =%>
<%= $c->hidden_fields('subDisplay') =%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Rename Course') %> <%= $c->helpMacro('AdminRenameCourse') %></h2>
<h2>
<%= maketext('Rename Course') %>
<%= $c->helpMacro('AdminRenameCourse', { help_label => maketext('Rename Course') }) %>
</h2>
% # Report on databases
<h3 class="my-3"><%= maketext('Report on database structure for course [_1]:', $rename_oldCourseID) %></h3>
% if (@$upgrade_report) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Rename Course') %> <%= $c->helpMacro('AdminRenameCourse') %></h2>
<h2>
<%= maketext('Rename Course') %>
<%= $c->helpMacro('AdminRenameCourse', { help_label => maketext('Rename Course') }) %>
</h2>
<%= form_for current_route, method => 'POST', begin =%>
<%= $c->hidden_authen_fields =%>
<%= $c->hidden_fields('subDisplay') =%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
% use WeBWorK::Utils::CourseManagement qw(listCourses);
%
<h2><%= maketext('Rename Course') %> <%= $c->helpMacro('AdminRenameCourse') %></h2>
<h2>
<%= maketext('Rename Course') %>
<%= $c->helpMacro('AdminRenameCourse', { help_label => maketext('Rename Course') }) %>
</h2>
%
% my @courseIDs = sort { lc($a) cmp lc($b) } grep { $_ ne stash('courseID') } listCourses($ce);
%
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Unarchive Course') %> <%= $c->helpMacro('AdminUnarchiveCourse') %></h2>
<h2>
<%= maketext('Unarchive Course') %>
<%= $c->helpMacro('AdminUnarchiveCourse', { help_label => maketext('Unarchive Course') }) %>
</h2>
<%= form_for current_route, method => 'POST', begin =%>
<div class="row mb-2">
<%= label_for new_courseID => maketext('Unarchive [_1] to course:', $unarchive_courseID),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
% use WeBWorK::Utils::CourseManagement qw(listArchivedCourses);
%
<h2><%= maketext('Unarchive Course') %> <%= $c->helpMacro('AdminUnarchiveCourse') %></h2>
<h2>
<%= maketext('Unarchive Course') %>
<%= $c->helpMacro('AdminUnarchiveCourse', { help_label => maketext('Unarchive Course') }) %>
</h2>
%
% # Find courses which have been archived.
% my @courseIDs = sort { lc($a) cmp lc($b) } listArchivedCourses($ce);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<h2><%= maketext('Upgrade Courses') %> <%= $c->helpMacro('AdminUpgradeCourses') %></h2>
<h2>
<%= maketext('Upgrade Courses') %>
<%= $c->helpMacro('AdminUpgradeCourses', { help_label => maketext('Upgrade Courses') }) %>
</h2>
<%= form_for current_route, method => 'POST', begin =%>
<% my $checkALLs = begin =%>
% if ($extra_database_tables_exist) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
%
% my @courseIDs = sort { lc($a) cmp lc($b) } listCourses($ce);
%
<h2><%= maketext('Upgrade Courses') %> <%= $c->helpMacro('AdminUpgradeCourses') %></h2>
<h2>
<%= maketext('Upgrade Courses') %>
<%= $c->helpMacro('AdminUpgradeCourses', { help_label => maketext('Upgrade Courses') }) %>
</h2>
<div class="mb-2"><%= maketext('Update the checked directories?') %></div>
<%= form_for current_route, method => 'POST', id => 'courselist', name => 'courselist', begin =%>
<div class="mb-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
</div>
<div>
<%= link_to '#', data => { bs_toggle => 'modal', bs_target => "#$configObject->{name}_help_modal" }, begin =%>
<i class="icon fas fa-question-circle" aria-hidden="true" data-alt="help"></i>
<i class="icon fas fa-question-circle" aria-hidden="true"></i>
<span class="visually-hidden">
<%= maketext('[_1] help.', $configObject->{doc}) %>
</span>
<% end =%>
<% content_for 'modal-dialog-area', begin =%>
<div class="modal fade" id="<%= "$configObject->{name}_help_modal" %>" tabindex="-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</label>
</div>
% }
<%= $c->helpMacro('Levels') =%>
<%= $c->helpMacro('Levels', { help_label => 'Levels' }) =%>
</div>
</div>
</div>
Expand Down