Commit 9db3651b by Matjaz Gregoric

Omit info about attempts used when attempts unlimited.

When the number of attempts is unlimited, we were hiding the "You have
used X out of Y attempts" text, which becomes "You have used X out of
null attempts" when attempts are unlimited.

The text was hidden, but it was still read out by the screen reader.
Do not include the text in the DOM when attempts are unlimited at all.
parent 71f2e4f0
......@@ -290,26 +290,32 @@ function DragAndDropTemplates(configuration) {
};
var submitAnswerTemplate = function(ctx) {
var attemptsUsedId = "attempts-used-"+configuration.url_name;
var attemptsUsedDisplay = (ctx.max_attempts && ctx.max_attempts > 0) ? 'inline': 'none';
var submitButtonProperties = {
disabled: ctx.disable_submit_button || ctx.submit_spinner,
attributes: {}
};
var attemptsUsedInfo = null;
if (ctx.max_attempts && ctx.max_attempts > 0) {
var attemptsUsedId = "attempts-used-" + configuration.url_name;
submitButtonProperties.attributes["aria-describedby"] = attemptsUsedId;
var attemptsUsedTemplate = gettext("You have used {used} of {total} attempts.");
var attemptsUsedText = attemptsUsedTemplate.
replace("{used}", ctx.attempts).replace("{total}", ctx.max_attempts);
attemptsUsedInfo = h("span.attempts-used", {id: attemptsUsedId}, attemptsUsedText);
}
return (
h("div.action-toolbar-item.submit-answer", {}, [
h(
"button.btn-brand.submit-answer-button",
{
disabled: ctx.disable_submit_button || ctx.submit_spinner,
attributes: {"aria-describedby": attemptsUsedId}},
submitButtonProperties,
[
(ctx.submit_spinner ? h("span.fa.fa-spin.fa-spinner") : null),
gettext("Submit")
]
),
h(
"span.attempts-used#"+attemptsUsedId, {style: {display: attemptsUsedDisplay}},
gettext("You have used {used} of {total} attempts.")
.replace("{used}", ctx.attempts).replace("{total}", ctx.max_attempts)
)
attemptsUsedInfo
])
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment