Add aria labels to PGML and unify their use. - #1493
Draft
somiaj wants to merge 1 commit into
Draft
Conversation
Update the `generate_aria_label` method to be given an input label.
If the input label is defined and doesn't contain `%s`, return
the label. If the input label is undefined (or blank) generate
a default label based on the problem number, answer number, and
part number. If the input label contains `%s`, replace it with
the default generated label and return the result.
Update answer rules to more uniformly accept the `aria_label`
option and use the `generate_aria_label` method. This required
updating some and adding the option to others.
Update macros that use the `generate_aria_label` method to take
advantage of the new method. The parserRadioButtons and
parserCheckboxList will append "option X" to the end of the
generated label. Matrix arrays will append "col N row M" to
the end of the generated label.
Update PGML to accept the `aria_label` option in answer blanks
to customize the label, "[_]{$answer}{aria_label => '%s label'}".
The biggest change was in parserRadioMultiAnswer which allows
a new option `ariaLabels` which is the labels to send to the
associated answer rules. Update its internal `generate_aria_label`
function to match the changes to the one in PGbasicmacros. In
addition the "subpart X" is only added to the label if there are
more than one subparts, and the "part Y" will use the label of
the part if `displayLabels` is set, otherwise it uses the number
of the part.
somiaj
marked this pull request as draft
August 9, 2026 00:52
Contributor
Author
|
@drgrice1 One thing I was unsure about was parserPopUp when the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update the
generate_aria_labelmethod to be given an input label. If the input label is defined and doesn't contain%s, return the label. If the input label is undefined (or blank) generate a default label based on the problem number, answer number, and part number. If the input label contains%s, replace it with the default generated label and return the result.Update answer rules to more uniformly accept the
aria_labeloption and use thegenerate_aria_labelmethod. This required updating some and adding the option to others.Update macros that use the
generate_aria_labelmethod to take advantage of the new method. The parserRadioButtons and parserCheckboxList will append "option X" to the end of the generated label. Matrix arrays will append "col N row M" to the end of the generated label.Update PGML to accept the
aria_labeloption in answer blanks to customize the label, "[_]{$answer}{aria_label => '%s label'}".The biggest change was in parserRadioMultiAnswer which allows a new option
ariaLabelswhich is the labels to send to the associated answer rules. Update its internalgenerate_aria_labelfunction to match the changes to the one in PGbasicmacros. In addition the "subpart X" is only added to the label if there are more than one subparts, and the "part Y" will use the label of the part ifdisplayLabelsis set, otherwise it uses the number of the part.This is a more general approach and replacement of #1489. Due to the discussion I am calling the option
aria_labelto match what was already in the code,labelis not a correct name, andaccessibility_labelis just longer and would require making the code better deal with that.aria_labelwas already in use and is now just being used more uniformly.aria_labelcan be used in PGML or sent directly to variousans_ruleorans_arraycalls.I went with @dpvc suggestion of allowing a single
%ssprintf option to include the default generated label as part of the custom label. To not get any errors fromsprintf, I went with just regex find/replace of the first instance of%sin the string.Here is a problem I was using to test various different checkers and macros. Edit it to remove the
aria_labeloption to check out default generated labels or remove%sto see any effects.