Skip to content

Commit

Permalink
Fix examination question hide button accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
VirmasaloA committed Sep 3, 2024
1 parent 59bdc54 commit 56e91af
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ <h2 class="participation-heading">
>
<span [hidden]="showEvaluation">{{ 'i18n_comments_open' | translate }}</span>
<span [hidden]="!showEvaluation">{{ 'i18n_comments_hide' | translate }}</span>
<i [hidden]="showEvaluation" class="bi bi-chevron-right ms-2" alt="hide evaluation"></i>
<i [hidden]="!showEvaluation" class="bi bi-chevron-down ms-2" alt="show evaluation"></i>
<i [hidden]="showEvaluation" class="bi bi-chevron-right ms-2" alt=""></i>
<i [hidden]="!showEvaluation" class="bi bi-chevron-down ms-2" alt=""></i>
</button>
</div>
</div>
Expand Down
12 changes: 2 additions & 10 deletions ui/src/app/exam/editor/sections/section-question.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,8 @@
>
<span [hidden]="sectionQuestion.expanded">{{ 'i18n_show_more' | translate }}</span>
<span [hidden]="!sectionQuestion.expanded">{{ 'i18n_hide' | translate }}</span>
<i
[hidden]="sectionQuestion.expanded"
class="bi bi-chevron-right ms-2"
alt="hide evaluation"
></i>
<i
[hidden]="!sectionQuestion.expanded"
class="bi bi-chevron-down ms-2"
alt="show evaluation"
></i>
<i [hidden]="sectionQuestion.expanded" class="bi bi-chevron-right ms-2" alt=""></i>
<i [hidden]="!sectionQuestion.expanded" class="bi bi-chevron-down ms-2" alt=""></i>
</button>
}
</div>
Expand Down
33 changes: 20 additions & 13 deletions ui/src/app/examination/question/examination-question.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,27 @@
</div>
}
</div>
<!-- Expand button -->
<div class="col-auto order-2">
<button
tabindex="0"
class="pointer section-box-title arrow border-none background-none"
[attr.aria-label]="
(expanded ? ('i18n_collapse' | translate) : ('i18n_expand' | translate)) +
' ' +
('i18n_question' | translate) +
' ' +
questionTitle
"
[attr.aria-expanded]="expanded"
(click)="expanded = !expanded"
(keydown.enter)="expanded = !expanded"
>
<i [ngClass]="expanded ? 'bi-chevron-down' : 'bi-chevron-right'"></i>
</button>
</div>
<!-- question text -->
<div class="col mt-3">
<div class="col mt-3 order-1">
@if (sq.question.type !== 'ClozeTestQuestion') {
@if (expanded) {
<div class="section-box-title" [xmMathJax]="sq.question.question"></div>
Expand All @@ -32,18 +51,6 @@
</div>
}
</div>
<!-- Expand button -->
<div class="col-auto">
<div
tabindex="0"
class="pointer section-box-title arrow"
[attr.aria-label]="expanded ? ('i18n_collapse' | translate) : ('i18n_expand' | translate)"
(click)="expanded = !expanded"
(keydown.enter)="expanded = !expanded"
>
<i [ngClass]="expanded ? 'bi-chevron-down' : 'bi-chevron-right'"></i>
</div>
</div>
</div>
<!-- instruction -->
@if (sq.answerInstructions && expanded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export class ExaminationQuestionComponent implements OnInit, AfterViewInit {
const { answer } = this.sq.clozeTestAnswer;
this.clozeAnswer = JSON.parse(answer);
}
this.questionTitle = this.removeParagraphTags(this.sq.question.question);
}

removeParagraphTags(input: string): string {
return input.replace(/<\/?p>/g, '');
}

ngAfterViewInit() {
Expand Down

0 comments on commit 56e91af

Please sign in to comment.