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

[#12508] Give respondents a way to reset a rubric question submission #13145

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
23df598
Functional reset choices button in rubrics edit question
NeoHW Jul 14, 2024
c5ad013
Alert warning created for reset
NeoHW Jul 14, 2024
0ca6127
Make button separated from rubric table
NeoHW Jul 14, 2024
e652b97
Fix linting issues of extra whitespace
NeoHW Jul 15, 2024
f33bfb7
Add reset choices comfirmation component
NeoHW Jul 15, 2024
45f993e
Remove spaces
NeoHW Jul 15, 2024
abaf2cb
Merge branch 'master' into ENH/12508/reset-rubrics-question
NeoHW Jul 15, 2024
8484f5d
Fix linting issues
NeoHW Jul 15, 2024
bd72730
Fix snap test
NeoHW Jul 15, 2024
425889c
Fix linting test
NeoHW Jul 15, 2024
ad15b9b
Merge branch 'master' into ENH/12508/reset-rubrics-question
domoberzin Jul 23, 2024
a895576
Merge branch 'master' into ENH/12508/reset-rubrics-question
domoberzin Jul 28, 2024
396d312
Merge branch 'master' into ENH/12508/reset-rubrics-question
mingyuanc Jul 30, 2024
2e252ab
Reset button to use Modal Service warning
NeoHW Jul 30, 2024
e771541
Clean up commented code
NeoHW Jul 30, 2024
cc68133
Remove unused component files
NeoHW Jul 30, 2024
8317884
Update snapshot
NeoHW Jul 30, 2024
8ddb566
Fix linting issues
NeoHW Jul 30, 2024
f17053e
Merge branch 'master' into ENH/12508/reset-rubrics-question
domoberzin Jul 31, 2024
383064a
Disable reset choices button past submission date
NeoHW Jul 31, 2024
28fa3be
Standardise coloring to btn-warning for reset choices
NeoHW Jul 31, 2024
a7078ad
Fix lint
NeoHW Jul 31, 2024
9bc4ca0
Update snapshots
NeoHW Jul 31, 2024
159ca8b
Merge remote-tracking branch 'refs/remotes/origin/ENH/12508/reset-rub…
NeoHW Jul 31, 2024
bace018
retrigger checks
NeoHW Jul 31, 2024
cd9a2f1
retrigger checks
NeoHW Jul 31, 2024
8fa52b0
Merge branch 'master' into ENH/12508/reset-rubrics-question
domoberzin Aug 2, 2024
554337d
Merge branch 'master' into ENH/12508/reset-rubrics-question
domoberzin Aug 5, 2024
9450ea5
Merge branch 'master' into ENH/12508/reset-rubrics-question
NeoHW Aug 26, 2024
06fbe15
retrigger checks
NeoHW Aug 28, 2024
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
Original file line number Diff line number Diff line change
@@ -1,49 +1,64 @@
<table class="table table-bordered desktop-view" [attr.aria-label]="getAriaLabel()">
<thead>
<tr>
<td></td>
<th *ngFor="let choice of questionDetails.rubricChoices" scope="col">{{ choice }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let rubricDescriptionRow of questionDetails.rubricDescriptions; let i = index;"
[ngClass]="{ 'row-answered': i < responseDetails.answer.length && responseDetails.answer[i] !== RUBRIC_ANSWER_NOT_CHOSEN }">
<th class="fw-normal" scope="row">{{ questionDetails.rubricSubQuestions[i] }}</th>
<td *ngFor="let rubricDescriptionCell of rubricDescriptionRow; let j = index;" class="text-secondary answer-cell" (click)="selectAnswer(i, j)">
<input
type="radio"
[disabled]="isDisabled"
[name]="getInputId(id, i, j, 'desktop')"
[id]="getInputId(id, i, j, 'desktop')"
[checked]="i < responseDetails.answer.length && responseDetails.answer[i] === j"
/>
<label [for]="getInputId(id, i, j, 'desktop')" (click)="$event.stopPropagation()">
{{ rubricDescriptionCell }}
</label>
</td>
</tr>
</tbody>
</table>
<div class="mobile-view" [attr.aria-label]="getAriaLabel()">
<div class="card" *ngFor="let rubricDescriptionRow of questionDetails.rubricDescriptions; let i = index;">
<div class="card-header bg-light">
{{ questionDetails.rubricSubQuestions[i] }}
</div>
<div class="card-body"
[ngClass]="{ 'row-answered': i < responseDetails.answer.length && responseDetails.answer[i] !== RUBRIC_ANSWER_NOT_CHOSEN }">
<div *ngFor="let rubricDescriptionCell of rubricDescriptionRow; let j = index;">
<label>
<input
type="radio"
[disabled]="isDisabled"
(click)="selectAnswer(i, j)"
[name]="getInputId(id, i, j, 'mobile')"
[checked]="i < responseDetails.answer.length && responseDetails.answer[i] === j"
[attr.aria-label]="getAriaLabelForChoice(questionDetails.rubricChoices[j], rubricDescriptionCell, questionDetails.rubricSubQuestions[i])"
>
{{ getChoiceWithDescription(questionDetails.rubricChoices[j], rubricDescriptionCell) }}
</label>
<div>
<div class="table-container">
<table class="table table-bordered desktop-view" [attr.aria-label]="getAriaLabel()">
<thead>
<tr>
<td></td>
<th *ngFor="let choice of questionDetails.rubricChoices" scope="col">{{ choice }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let rubricDescriptionRow of questionDetails.rubricDescriptions; let i = index;"
[ngClass]="{ 'row-answered': i < responseDetails.answer.length && responseDetails.answer[i] !== RUBRIC_ANSWER_NOT_CHOSEN }">
<th class="fw-normal" scope="row">{{ questionDetails.rubricSubQuestions[i] }}</th>
<td *ngFor="let rubricDescriptionCell of rubricDescriptionRow; let j = index;" class="text-secondary answer-cell" (click)="selectAnswer(i, j)">
<input
type="radio"
[disabled]="isDisabled"
[name]="getInputId(id, i, j, 'desktop')"
[id]="getInputId(id, i, j, 'desktop')"
[checked]="i < responseDetails.answer.length && responseDetails.answer[i] === j"
/>
<label [for]="getInputId(id, i, j, 'desktop')" (click)="$event.stopPropagation()">
{{ rubricDescriptionCell }}
</label>
</td>
</tr>
</tbody>
</table>
<div class="mobile-view" [attr.aria-label]="getAriaLabel()">
<div class="card" *ngFor="let rubricDescriptionRow of questionDetails.rubricDescriptions; let i = index;">
<div class="card-header bg-light">
{{ questionDetails.rubricSubQuestions[i] }}
</div>
<div class="card-body"
[ngClass]="{ 'row-answered': i < responseDetails.answer.length && responseDetails.answer[i] !== RUBRIC_ANSWER_NOT_CHOSEN }">
<div *ngFor="let rubricDescriptionCell of rubricDescriptionRow; let j = index;">
<label>
<input
type="radio"
[disabled]="isDisabled"
(click)="selectAnswer(i, j)"
[name]="getInputId(id, i, j, 'mobile')"
[checked]="i < responseDetails.answer.length && responseDetails.answer[i] === j"
[attr.aria-label]="getAriaLabelForChoice(questionDetails.rubricChoices[j], rubricDescriptionCell, questionDetails.rubricSubQuestions[i])"
>
{{ getChoiceWithDescription(questionDetails.rubricChoices[j], rubricDescriptionCell) }}
</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="button-container">
<button
NeoHW marked this conversation as resolved.
Show resolved Hide resolved
type="button"
class="btn btn-warning"
title="Reset choices"
id="btn-reset"
name="button-reset"
ngbTooltip="Reset current choices"
[disabled]="isDisabled"
(click)="resetHandler()">
Reset choices
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@
display: none;
}
}

.table-container {
margin-bottom: 1.25em;
}

.button-container {
display: flex;
justify-content: flex-end;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Component, Input } from '@angular/core';
import { QuestionEditAnswerFormComponent } from './question-edit-answer-form';
import { SimpleModalService } from '../../../../services/simple-modal.service';
import {
FeedbackRubricQuestionDetails, FeedbackRubricResponseDetails,
} from '../../../../types/api-output';
import {
DEFAULT_RUBRIC_QUESTION_DETAILS, DEFAULT_RUBRIC_RESPONSE_DETAILS,
} from '../../../../types/default-question-structs';
import { RUBRIC_ANSWER_NOT_CHOSEN } from '../../../../types/feedback-response-details';
import { SimpleModalType } from '../../simple-modal/simple-modal-type';

/**
* The rubric question submission form for a recipient.
Expand All @@ -30,7 +32,7 @@ export class RubricQuestionEditAnswerFormComponent extends QuestionEditAnswerFor
// constant
readonly RUBRIC_ANSWER_NOT_CHOSEN: number = RUBRIC_ANSWER_NOT_CHOSEN;

constructor() {
constructor(private simpleModalService: SimpleModalService) {
super(DEFAULT_RUBRIC_QUESTION_DETAILS(), DEFAULT_RUBRIC_RESPONSE_DETAILS());
}

Expand Down Expand Up @@ -71,4 +73,20 @@ export class RubricQuestionEditAnswerFormComponent extends QuestionEditAnswerFor
getInputId(id: string, row: number, col: number, platform: string): string {
return `${id}-row${row}-col${col}-${platform}`;
}

resetHandler(): void {
this.simpleModalService.openConfirmationModal(
'Reset Choices?',
SimpleModalType.WARNING,
'Are you sure you want to reset your choices? This action cannot be reverted',
).result.then(() => {
this.resetRubricAnswer();
}, () => {});
}

resetRubricAnswer(): void {
const resettedAnswer: number[] =
Array(this.questionDetails.rubricSubQuestions.length).fill(RUBRIC_ANSWER_NOT_CHOSEN);
this.triggerResponseDetailsChange('answer', resettedAnswer);
}
}
Loading
Loading