-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(MultipleChoiceComponents): Split MCStudentComponent to MCRad…
…ioStudentComponent and MCCheckoxStudentComponent (#1989)
- Loading branch information
1 parent
7f5ad05
commit 220c359
Showing
7 changed files
with
116 additions
and
72 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...leChoice/multiple-choice-checkbox-student/multiple-choice-checkbox-student.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@for (choice of choices; track choice.id) { | ||
<div> | ||
<mat-checkbox | ||
[(ngModel)]="choice.isChecked" | ||
(change)="updateStudentChoices.emit(choice.id)" | ||
[disabled]="isDisabled" | ||
[attr.aria-label]="choice.text" | ||
color="primary" | ||
> | ||
<span [innerHTML]="choice.text"></span> | ||
@if (choice.showFeedback) { | ||
<span | ||
[ngClass]="{ | ||
success: componentHasCorrectAnswer && choice.isCorrect, | ||
warn: componentHasCorrectAnswer && !choice.isCorrect, | ||
info: !componentHasCorrectAnswer | ||
}" | ||
>{{ choice.feedbackToShow }}</span | ||
> | ||
} | ||
</mat-checkbox> | ||
</div> | ||
} |
19 changes: 19 additions & 0 deletions
19
...ipleChoice/multiple-choice-checkbox-student/multiple-choice-checkbox-student.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { MatCheckboxModule } from '@angular/material/checkbox'; | ||
|
||
@Component({ | ||
imports: [CommonModule, FormsModule, MatCheckboxModule], | ||
selector: 'multiple-choice-checkbox-student', | ||
standalone: true, | ||
templateUrl: './multiple-choice-checkbox-student.component.html' | ||
}) | ||
export class MultipleChoiceCheckboxStudentComponent { | ||
@Input() choices: any[]; | ||
@Input() studentChoices: string[]; | ||
@Input() isDisabled: boolean; | ||
@Input() showFeedback: boolean; | ||
@Input() componentHasCorrectAnswer: boolean; | ||
@Output() updateStudentChoices = new EventEmitter<string>(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...multipleChoice/multiple-choice-radio-student/multiple-choice-radio-student.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<mat-radio-group [(ngModel)]="studentChoices" (ngModelChange)="studentChoicesChange.emit($event)"> | ||
@for (choice of choices; track choice.id) { | ||
<div> | ||
<mat-radio-button | ||
[attr.aria-label]="choice.text" | ||
color="primary" | ||
[value]="choice.id" | ||
[disabled]="isDisabled" | ||
> | ||
<span [innerHTML]="choice.text"></span> | ||
@if (showFeedback && choice.showFeedback) { | ||
<span | ||
[ngClass]="{ | ||
success: componentHasCorrectAnswer && choice.isCorrect, | ||
warn: componentHasCorrectAnswer && !choice.isCorrect, | ||
info: !componentHasCorrectAnswer | ||
}" | ||
>{{ choice.feedbackToShow }}</span | ||
> | ||
} | ||
</mat-radio-button> | ||
</div> | ||
} | ||
</mat-radio-group> |
19 changes: 19 additions & 0 deletions
19
...s/multipleChoice/multiple-choice-radio-student/multiple-choice-radio-student.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { MatRadioModule } from '@angular/material/radio'; | ||
|
||
@Component({ | ||
imports: [CommonModule, FormsModule, MatRadioModule], | ||
selector: 'multiple-choice-radio-student', | ||
standalone: true, | ||
templateUrl: './multiple-choice-radio-student.component.html' | ||
}) | ||
export class MultipleChoiceRadioStudentComponent { | ||
@Input() choices: any[]; | ||
@Input() studentChoices: string; | ||
@Input() isDisabled: boolean; | ||
@Input() showFeedback: boolean; | ||
@Input() componentHasCorrectAnswer: boolean; | ||
@Output() studentChoicesChange = new EventEmitter<string>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters