Skip to content

Commit

Permalink
feat: use confirmation modal when passing or deleting test attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
satikaj committed Jun 6, 2024
1 parent 9bc48b0 commit 3fb25bb
Showing 1 changed file with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import {Component, OnInit, Input} from '@angular/core';
import {Task, ScormComment, User, UserService, TestAttemptService} from 'src/app/api/models/doubtfire-model';
import {Component, Input, Inject} from '@angular/core';
import {confirmationModal} from 'src/app/ajs-upgraded-providers';
import {
Task,
ScormComment,
User,
UserService,
TestAttemptService,
} from 'src/app/api/models/doubtfire-model';

@Component({
selector: 'f-scorm-comment',
templateUrl: './scorm-comment.component.html',
styleUrls: ['./scorm-comment.component.scss'],
})
export class ScormCommentComponent implements OnInit {
export class ScormCommentComponent {
@Input() task: Task;
@Input() comment: ScormComment;

Expand All @@ -15,12 +22,11 @@ export class ScormCommentComponent implements OnInit {
constructor(
private userService: UserService,
private testAttemptService: TestAttemptService,
@Inject(confirmationModal) private confirmationModal: any,
) {
this.user = this.userService.currentUser;
}

ngOnInit() {}

get canOverridePass(): boolean {
return this.user.isStaff && !this.comment.testAttempt.successStatus;
}
Expand All @@ -33,10 +39,22 @@ export class ScormCommentComponent implements OnInit {
}

passScormAttempt() {
this.testAttemptService.overrideSuccessStatus(this.comment.testAttempt.id, true);
this.confirmationModal.show(
'Pass Test Attempt',
'Are you sure you want to pass this test attempt? This action will override the success status of this test attempt to a pass.',
() => {
this.testAttemptService.overrideSuccessStatus(this.comment.testAttempt.id, true);
},
);
}

deleteScormAttempt() {
this.testAttemptService.deleteAttempt(this.comment.testAttempt.id);
this.confirmationModal.show(
'Delete Test Attempt',
'Are you sure you want to delete this test attempt? This action is final and will delete information associated with this test attempt.',
() => {
this.testAttemptService.deleteAttempt(this.comment.testAttempt.id);
},
);
}
}

0 comments on commit 3fb25bb

Please sign in to comment.