Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h3 class="for-accessibility" [id]="'multi-team-member-selector-question-' + que
</ion-item>
</ng-container>
</ion-list>

<ng-container *ngIf="review?.comment">
<ion-item class="feedback-title ion-no-padding" lines="none">
<ion-icon class="ion-padding-horizontal" name="eye" size="small"></ion-icon>
Expand Down Expand Up @@ -57,13 +57,13 @@ <h3 class="for-accessibility" [id]="'multi-team-member-selector-question-' + que
[ngClass]="{'item-bottom-border': i !== question.teamMembers.length - 1 }">
<ion-label class="white-space-normal body-2 black">
{{ teamMember.userName }}
<p *ngIf="submission.answer.includes(teamMember.key)">
<p *ngIf="submission?.answer?.includes(teamMember.key)">
<ion-chip class="label orange" i18n>Learner's answer</ion-chip>
</p>
</ion-label>
<ion-checkbox color="success"
[attr.aria-label]="teamMember.userName"
[checked]="review.answer ? review.answer.includes(teamMember.key) : false"
[checked]="review?.answer?.includes(teamMember.key)"
[value]="teamMember.key"
slot="start"
(ionChange)="onChange(teamMember.key, 'answer')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ export class ActivityDesktopPage {

if (!event.autoSave) {
if (hasSubmssion === true) {
this.notificationsService.presentToast($localize`Duplicate submission detected. Your submission is already in our system.`, {
color: 'success',
icon: 'checkmark-circle'
});
this.notificationsService.assessmentSubmittedToast({ isDuplicated: true });
} else {
this.notificationsService.assessmentSubmittedToast();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class AssessmentMobilePage implements OnInit {
this.assessmentService.submission$.subscribe(res => this.submission = res);
this.assessmentService.review$.subscribe(res => this.review = res);
this.route.params.subscribe(params => {
const assessmentId = +params.id;
this.action = this.route.snapshot.data.action;
this.fromPage = this.route.snapshot.data.from;
if (!this.fromPage) {
Expand All @@ -57,7 +58,7 @@ export class AssessmentMobilePage implements OnInit {
this.activityId = +params.activityId || 0;
this.contextId = +params.contextId;
this.submissionId = +params.submissionId;
this.assessmentService.getAssessment(+params.id, this.action, this.activityId, this.contextId, this.submissionId);
this.assessmentService.getAssessment(assessmentId, this.action, this.activityId, this.contextId, this.submissionId);
});
}

Expand Down Expand Up @@ -106,7 +107,17 @@ export class AssessmentMobilePage implements OnInit {
this.savingText$.next('Saving...');

try {
if (this.action === 'assessment') {
let hasSubmission = false;
const { submission } = await this.assessmentService.fetchAssessment(
event.assessmentId,
this.action,
this.activityId,
event.contextId,
event.submissionId,
).toPromise();


if (this.action === 'assessment' && submission.status === 'in progress') {
const saved = await this.assessmentService.submitAssessment(
event.submissionId,
event.assessmentId,
Expand All @@ -119,7 +130,7 @@ export class AssessmentMobilePage implements OnInit {
console.error('Asmt submission error:', saved);
throw new Error("Error submitting assessment");
}
} else if (this.action === 'review') {
} else if (this.action === 'review' && submission.status === 'pending review') {
const saved = await this.assessmentService.submitReview(
event.assessmentId,
this.review.id,
Expand All @@ -134,6 +145,8 @@ export class AssessmentMobilePage implements OnInit {
}

this.reviewService.getReviews();
} else {
hasSubmission = true;
}

// [CORE-5876] - Fastfeedback is now added for reviewer
Expand All @@ -143,9 +156,18 @@ export class AssessmentMobilePage implements OnInit {

this.savingText$.next($localize `Last saved ${this.utils.getFormatedCurrentTime()}`);
if (!event.autoSave) {
this.notificationsService.assessmentSubmittedToast();
// get the latest activity tasks and refresh the assessment submission data
this.activityService.getActivity(this.activityId);
// show toast message
if (hasSubmission === true) {
this.notificationsService.assessmentSubmittedToast({ isDuplicated: true });
} else {
this.notificationsService.assessmentSubmittedToast({ isReview: this.action === 'review'});
}

if (this.action === 'assessment') {
// get the latest activity tasks and refresh the assessment submission data
this.activityService.getActivity(this.activityId);
}

this.btnDisabled$.next(false);
this.saving = false;
return this.assessmentService.getAssessment(this.assessment.id, this.action, this.activityId, this.contextId, this.submissionId);
Expand Down
56 changes: 36 additions & 20 deletions projects/v3/src/app/pages/review-desktop/review-desktop.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,45 @@ export class ReviewDesktopPage implements OnInit {
this.btnDisabled$.next(true);
this.savingText$.next('Saving...');
try {
const res = await this.assessmentService.submitReview(
this.assessment.id,
this.review.id,
this.submission.id,
event.answers
).toPromise();

// [CORE-5876] - Fastfeedback is now added for reviewer
if (this.assessment.pulseCheck === true && event.autoSave === false) {
await this.assessmentService.pullFastFeedback();
}
const { submission } = await this.assessmentService
.fetchAssessment(
event.assessmentId,
"review",
null,
this.currentReview.contextId,
this.submission.id
)
.toPromise();

this.assessmentService.getAssessment(this.assessment.id, 'review', 0, this.currentReview.contextId, this.submission.id);
this.reviewService.getReviews();
if (submission.status === 'pending review') {
const res = await this.assessmentService.submitReview(
this.assessment.id,
this.review.id,
this.submission.id,
event.answers
).toPromise();

// [CORE-5876] - Fastfeedback is now added for reviewer
if (this.assessment.pulseCheck === true && event.autoSave === false) {
await this.assessmentService.pullFastFeedback();
}

this.assessmentService.getAssessment(this.assessment.id, 'review', 0, this.currentReview.contextId, this.submission.id);
this.reviewService.getReviews();

await this.notificationsService.getTodoItems().toPromise(); // update notifications list

await this.notificationsService.getTodoItems().toPromise(); // update notifications list
// fail gracefully: Review submission API may sometimes fail silently
if (res?.data?.submitReview === false) {
this.savingText$.next($localize`Save failed.`);
this.btnDisabled$.next(false);
this.loading = false;
return;
}

// fail gracefully: Review submission API may sometimes fail silently
if (res?.data?.submitReview === false) {
this.savingText$.next($localize`Save failed.`);
this.btnDisabled$.next(false);
this.loading = false;
return;
this.notificationsService.assessmentSubmittedToast({ isReview: true });
} else {
this.notificationsService.assessmentSubmittedToast({ isDuplicated: true });
}

this.loading = false;
Expand Down
17 changes: 15 additions & 2 deletions projects/v3/src/app/services/notifications.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,23 @@ export class NotificationsService {
* @return {Promise<void>}
*/
assessmentSubmittedToast(option?: {
isFail: boolean;
isDuplicated?: boolean;
isFail?: boolean;
isReview?: boolean;
label?: string;
}): void | Promise<void> {
if (!this.connection.isOnline) {
return alert('You are offline, please check your internet connection and try again.');
}

if (option?.isDuplicated === true) {
return this.presentToast($localize`Duplicated submission detected. Your submission is already in our system.`, {
color: 'success',
icon: 'checkmark-circle'
});
}

// fail message
if (option?.isFail === true) {
if (option?.label) {
return this.presentToast(option.label, {
Expand All @@ -253,7 +263,10 @@ export class NotificationsService {
icon: 'close-circle'
});
}
return this.presentToast($localize`Assessment Submitted.`, {

// success by default
const message = option?.isReview === true ? $localize`Review Submitted.` : $localize`Assessment Submitted.`;
return this.presentToast(message, {
color: 'success',
icon: 'checkmark-circle'
});
Expand Down