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 feature to provide additional attributes to form elements #444

Open
taniwallach opened this issue Dec 14, 2019 · 2 comments
Open

Add feature to provide additional attributes to form elements #444

taniwallach opened this issue Dec 14, 2019 · 2 comments

Comments

@taniwallach
Copy link
Member

I would be desirable to add a feature to provide additional additional attributes to form elements such as input boxes for multiple purposes:

  1. Better "aria-label" values for accessibility purposes to override the default automatically set values.
    - See the discussion thread at http://webwork.maa.org/moodle/mod/forum/discuss.php?d=4694
  2. Providing CSS styling code to be attached (to achieve results such as nice formatting of limits of integration, without dependence of the element id).
    - See http://webwork.maa.org/moodle/mod/forum/discuss.php?d=4462
@taniwallach
Copy link
Member Author

Another use would be adding additional class names to an object. Might help MathQuill bypass a specific input element. See: openwebwork/webwork2#1071 (comment)

@taniwallach
Copy link
Member Author

This idea remains of interest, and it seem that there is some infrastructure in place which could be extended to implement the feature. Unfortunately, I have not had time to work on implementing anything yet.

I discovered (thanks to a forum post by Ping-Shun Chan at https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4877#p14660) that NAMED_ANS_RULE (in macros/PGbasicmacros.pl) has existing support for a hash of options, and can handle an option called aria_label to provide a better aria label. It seems that getting all the standard methods to receive and pass on such an options hash would facilitate proving the sort of features envisioned.

The discussion at https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4694 seems to also raise the idea of adding "hidden labels" in addition to the aria-labels based on information provided in the options.

Support for the options hash and for a provided value of an aria_label option seems somewhat incomplete:

  • NAMED_ANS_RULE supports it.
  • So do NAMED_ANS_RULE_EXTENSION, NAMED_ANS_BOX, NAMED_ANS_ARRAY_EXTENSION
  • So does ans_matrix in lib/Value/AnswerChecker.pm which is the underlying function for ans_array and named_ans_array.)
  • For some reason NAMED_ANS_RADIO_EXTENSION seems to handle that option and only uses a default when it is not set, but NAMED_ANS_RADIO and NAMED_ANS_RADIO_BUTTONS do not seem to handle such an option.
  • NAMED_ANS_CHECKBOX, NAMED_ANS_CHECKBOX_OPTION
    However, neither labeled_ans_rule nor ans_rule seems to be able to pass on such options.

Regarding the idea to use this feature specifically to add CSS styling code - an alternate approach was found using DIV/SPAN elements and CSS selectors and which seems to do pretty well. See: https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4767 but ignore the first sample file with an older version of the code in the later posts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant