WeBWorK Main Forum

Inserts of HTML code in problems for Accessibility Screen Readers?

Inserts of HTML code in problems for Accessibility Screen Readers?

by tim Payer -
Number of replies: 7
One of the Accessibility team members has prompted me about adding a line of HTML code to one of our sample webwork assignment problems. They are asking if a label such as

<h2>Table of Probabilities for Problems 6.1b – 6.1d</h2>

as a second "header" that can be added to label a Data Table placed midway in the problem page. Keep in mind that, yes, the Data Table already has a header, and a Caption. But they reason that adding an additional label such as the one above will help the user of the screen reader to jump between successive points in the problem and thus make the navigation through the problem much easier.

So, I am asking is this even something that is possible? I have never inserted HTML code within Webwork and I suspect that I can not do so. But perhaps there is a similar segment of code within PERL that would flag the screen reader? Please advise what the best course of action is here.

Note that they are prepared for the answer of "Webwork Can not manage that", but I thought I would try and accommodate their request with a prompt to those that know better than I.

Thanks for any feedback, Tim
In reply to tim Payer

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by Alex Jordan -
Imho it's not ideal if the problem code gets into specific output formats, like HTML. Even if HTML is the predominant output mode. For example, you can end up making a problem that you come to realize can't really/easily be made equivalently for PDF hardcopy. And there are other output formats too...

But one option is that you can directly add HTML using MODES(). Like:

TEXT(MODES(HTML=>'<h2>...</h2>'));

or
BEGIN_TEXT
\{MODES(HTML=>'<h2>...</h2>');\}
END_TEXT

or
BEGIN_PGML
[@ MODES(HTML=>'<h2>...</h2>'); @]*
END_PGML

or
$myh2 = MODES(HTML=>'<h2>...</h2>');
and use $myh2 later.

Another option would be to write a macro for this purpose that handles all output modes in sensible ways. For example, headers.pl could be a macro library file with defining a command with syntax like header('Table of Probabilities for Problems 6.1b – 6.1d', 2);
(Except in this case you either want to avoid those explicit numbers, or reference the problem number from the environment variables.)

Just as aside, but I question if putting an h2 in a place like this is really in the best interests of the screen reader user. Where would they jump to next if they are jumping waypoints like this? Is there any content immediately following the table? If so, the label could mislead the person to think there is only a table there and nothing else. Unless you put yet another header immediately following the table.
In reply to Alex Jordan

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by tim Payer -
Thanks Alex.

I understand your concern about inserting this, but in this case there are a number of entry cells beyond this table. In this case it gives the reader the ability to jump back to the table to determine which scenario to use from assorted probabilities before jumping ahead to the next entry cell.

The ideal scenario would be to use unicode in the popup menus for these selections, then the table could be discarded and this would not be an issue.

But am I correct that unicode is only available in version 2.15? We are Webwork subscribers and are using V 2.13.

Thanks for the many choices and fast feedback!

Tim
In reply to tim Payer

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by Michael Gage -
"Of course webwork can manage that." :-)!wink
##############################################################
#
# Text
#
#

TEXT("<h2>Table of Probabilities for Problems 6.1b – 6.1d</h2>");

Context()->texStrings;
BEGIN_TEXT

\{TEXT("<h2>Table of Probabilities for Problems 6.1b – 6.1d</h2>")," "\}

END_TEXT

BEGIN_PGML
In pgml use @ signs:
[@ "<h2>Table of Probabilities for Problems 6.1b – 6.1d</h2>" @]*
END_PGML
Context()->normalStrings;

I've probably forgotten some of the more clever ways to do it. This is perl after all TIMTOWTDIT.



In reply to Michael Gage

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by Michael Gage -
And Alex is right -- it's a good idea to put MODES() around this so that it doesn't ruin the pdf output.
In reply to Michael Gage

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by tim Payer -
Thank you for all scenarios to accomplish this.

MODES() are new to me, I will give it a shot!

Tim
In reply to tim Payer

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by Alex Jordan -
I forgot there's an already-existing way if you are using PGML.

Start a line with n octothorpes to make a heading of level n. Like:

BEGIN_PGML
##Table of Probabilities

[@ DataTable(...) @]*

END_PGML


(DataTable() is the table-making tool from niceTables.pl.)
In reply to Alex Jordan

Re: Inserts of HTML code in problems for Accessibility Screen Readers?

by Alex Jordan -
I should have explained better. PGML markup will translate that thing (n octothorpes at the start of a line) into an hn header tag in HTML.

And it does something reasonable to make a "header" for LaTeX output too.

Of the options that have been presented, this is what I'd recommend. It's a tool that is already built, and it doesn't make you write output-specific code into the PG file.