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 tabs role pattern to question set #144

Merged
merged 3 commits into from
Jan 6, 2025
Merged
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
23 changes: 20 additions & 3 deletions js/questionset.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
unansweredText: 'Unanswered',
answeredText: 'Answered',
currentQuestionText: 'Current question',
navigationLabel: 'Questions'
navigationLabel: 'Questions',
questionSetInstruction: 'Choose question to display'
},
endGame: {
showResultPage: true,
Expand Down Expand Up @@ -301,9 +302,15 @@ H5P.QuestionSet = function (options, contentId, contentData) {
((params.introPage.showIntroPage && params.noOfQuestionAnswered === 0) ? 'hidden' : ''),
});

const tabIDs = Array.from({length: params.questions.length}, () => H5P.createUUID());
const tabPanelIDs = Array.from({length: params.questions.length}, () => H5P.createUUID());

for (let i=0; i<params.questions.length; i++) {
$('<div>', {
class: 'question-container',
role: 'tabpanel',
id: tabPanelIDs[i],
'aria-labelledby': tabIDs[i],
appendTo: self.$questionsContainer
});
}
Expand All @@ -323,6 +330,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
if (params.progressType == "dots") {
self.$dotsContainer = $('<ul>', {
class: 'dots-container',
role: 'tablist',
'aria-label': params.texts.questionSetInstruction,
appendTo: self.$progressBar
});

Expand All @@ -332,6 +341,9 @@ H5P.QuestionSet = function (options, contentId, contentData) {
html: '<a href="#" class= "progress-dot unanswered ' +
(params.disableBackwardsNavigation ? 'disabled' : '') +
'" ' +
'id="' +
tabIDs[i] +
'" ' +
'aria-label=' +
'"' +
params.texts.jumpToQuestion.replace("%d", i + 1).replace("%total", params.questions.length) +
Expand All @@ -340,7 +352,11 @@ H5P.QuestionSet = function (options, contentId, contentData) {
'" ' +
'tabindex="-1" ' +
(params.disableBackwardsNavigation ? 'aria-disabled="true"' : '') +
'></a>',
' aria-controls="' +
tabPanelIDs[i] +
'" ' +
'aria-selected="false" ' +
'role="tab"></a>',
appendTo: self.$dotsContainer
})
}
Expand Down Expand Up @@ -704,7 +720,8 @@ H5P.QuestionSet = function (options, contentId, contentData) {
var disabledTabindex = params.disableBackwardsNavigation && !showingSolutions;
$el.toggleClass('current', isCurrent)
.attr('aria-label', label)
.attr('tabindex', isCurrent && !disabledTabindex ? 0 : -1);
.attr('tabindex', isCurrent && !disabledTabindex ? 0 : -1)
.attr('aria-selected', isCurrent && !disabledTabindex);
};

var _displayEndGame = function () {
Expand Down
6 changes: 5 additions & 1 deletion language/.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
6 changes: 5 additions & 1 deletion language/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
4 changes: 4 additions & 0 deletions language/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion language/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
6 changes: 5 additions & 1 deletion language/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
6 changes: 5 additions & 1 deletion language/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
4 changes: 4 additions & 0 deletions language/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigační popisek pro čtecí zařízení",
"default": "Otázky"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions language/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Spørgsmål"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions language/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Beschriftung für Vorlesewerkzeuge",
"default": "Fragen"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions language/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Ετικέτα πλοήγησης για αναγνώστες",
"default": "Ερωτήσεις"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions language/es-mx.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Etiqueta de navegación para lectores de pantalla",
"default": "Preguntas"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions language/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Etiqueta de navegación para lectores de pantalla",
"default": "Preguntas"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion language/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
4 changes: 4 additions & 0 deletions language/eu.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Irakurgailuentzako nabigazio etiketa",
"default": "Galderak"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion language/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
6 changes: 5 additions & 1 deletion language/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
5 changes: 4 additions & 1 deletion language/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Texte de navigation pour la synthèse vocale",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -151,7 +155,6 @@
"description": "Ce titre sera affiché à la fin du quiz quand l'utilisateur aura répondu à toutes les questions."
},
{

"label": "Score announcer",
"description": "Cette vignette sera utilisée pour annoncer la note finale à l'utilisateur sur l'écran de fin",
"default": "Vous avez obtenu @finals sur @totals points"
Expand Down
6 changes: 5 additions & 1 deletion language/ga.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
4 changes: 4 additions & 0 deletions language/gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Etiqueta de navegación para lectores de pantalla",
"default": "Preguntas"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
4 changes: 4 additions & 0 deletions language/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "תווית ניווט להקראה",
"default": "שאלות"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down
6 changes: 5 additions & 1 deletion language/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
6 changes: 5 additions & 1 deletion language/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
{
"label": "Navigation label for readspeakers",
"default": "Questions"
},
{
"label": "Instruction for navigating question set with screenreader",
"default": "Choose question to display"
}
]
},
Expand Down Expand Up @@ -275,4 +279,4 @@
]
}
]
}
}
Loading
Loading