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

New: Added correctness classes to progress bars and arialabels to drawer buttons #225

Merged
merged 6 commits into from
Jun 12, 2024
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
12 changes: 10 additions & 2 deletions js/PageLevelProgressIndicatorView.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,17 @@ class PageLevelProgressIndicatorView extends Backbone.View {

checkCompletion() {
const percentage = this.setPercentageComplete();
oliverfoster marked this conversation as resolved.
Show resolved Hide resolved
const isComplete = (percentage === 100);
const canShowMarking = Boolean(this.model.get('_canShowMarking'));
const isCorrect = (canShowMarking && isComplete && this.model.get('_isCorrect') === true);
const isPartlyCorrect = (canShowMarking && isComplete && this.model.get('_isCorrect') === false && this.model.get('_isAtLeastOneCorrectSelection'));
const isIncorrect = (canShowMarking && isComplete && this.model.get('_isCorrect') === false && !this.model.get('_isAtLeastOneCorrectSelection'));
this.$el
.toggleClass('is-complete', percentage === 100)
.toggleClass('is-incomplete', percentage !== 100);
.toggleClass('is-complete', isComplete)
.toggleClass('is-incomplete', !isComplete)
.toggleClass('is-correct', isCorrect)
.toggleClass('is-partially-correct', isPartlyCorrect)
.toggleClass('is-incorrect', isIncorrect);
}

}
Expand Down
10 changes: 10 additions & 0 deletions templates/pageLevelProgressItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ export default function PageLevelProgressItem(props) {
_isLocked,
_isVisible,
_isComplete,
_isCorrect,
_isAtLeastOneCorrectSelection,
_canShowMarking,
title,
altTitle,
_id,
_type,
_children
} = props;

const isCorrect = (_canShowMarking && _isComplete && _isCorrect === true);
const isPartlyCorrect = (_canShowMarking && _isComplete && _isCorrect === false && _isAtLeastOneCorrectSelection);
const isIncorrect = (_canShowMarking && _isComplete && _isCorrect === false && !_isAtLeastOneCorrectSelection);

const indicatorSeat = React.createRef();
useEffect(() => {
if (_isOptional) return;
Expand Down Expand Up @@ -57,6 +64,9 @@ export default function PageLevelProgressItem(props) {
_isOptional && `${_globals._extensions._pageLevelProgress.optionalContent}.`,
!_isOptional && _isComplete && `${_globals._accessibility._ariaLabels.complete}.`,
!_isOptional && !_isComplete && `${_globals._accessibility._ariaLabels.incomplete}.`,
isCorrect && `${_globals._accessibility._ariaLabels.answeredCorrectly}.`,
isPartlyCorrect && `${_globals._accessibility._ariaLabels.answeredPartlyCorrect ?? _globals._accessibility._ariaLabels.answeredIncorrectly}.`,
isIncorrect && `${_globals._accessibility._ariaLabels.answeredIncorrectly}.`,
compile(a11y.normalize(altTitle || title))
])}
>
Expand Down