Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lupari committed Sep 27, 2024
1 parent 1bbfe03 commit 142ba21
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
4; /*
/*
* Copyright (c) 2018 The members of the EXAM Consortium (https://confluence.csc.fi/display/EXAM/Konsortio-organisaatio)
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by the European Commission - subsequent
Expand Down
9 changes: 0 additions & 9 deletions ui/src/app/calendar/calendar-title-resolver.service.ts

This file was deleted.

This file was deleted.

5 changes: 1 addition & 4 deletions ui/src/app/examination/examination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,5 @@ export class ExaminationComponent implements OnInit, OnDestroy {
throw Error('invalid index');
};

private onUnload = (event: BeforeUnloadEvent) => {
event.preventDefault();
return (event.returnValue = '');
};
private onUnload = (event: BeforeUnloadEvent) => event.preventDefault();
}
5 changes: 2 additions & 3 deletions ui/src/app/facility/rooms/room-mass-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ export class MultiRoomComponent implements OnInit {
this.toast.error(this.translate.instant('i18n_select_room_error'));
return;
}
outOfService
? this.roomService.openExceptionDialog(this.addExceptions, true, allExceptions)
: this.roomService.openExceptionDialog(this.addExceptions, false, allExceptions);
if (outOfService) this.roomService.openExceptionDialog(this.addExceptions, true, allExceptions);
else this.roomService.openExceptionDialog(this.addExceptions, false, allExceptions);
};

selectAll = () => {
Expand Down
5 changes: 1 addition & 4 deletions ui/src/app/question/basequestion/question.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,5 @@ export class QuestionComponent implements OnInit, OnDestroy, CanComponentDeactiv
}
};

private onUnload = (event: BeforeUnloadEvent) => {
event.preventDefault();
return this.questionForm?.dirty ? (event.returnValue = '') : null;
};
private onUnload = (event: BeforeUnloadEvent) => event.preventDefault();
}
5 changes: 1 addition & 4 deletions ui/src/app/question/examquestion/exam-question.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,5 @@ export class ExamQuestionComponent implements OnInit, OnDestroy {
window.addEventListener('beforeunload', this.onUnload);
});

private onUnload = (event: BeforeUnloadEvent) => {
event.preventDefault();
return this.questionForm?.dirty ? (event.returnValue = '') : null;
};
private onUnload = (event: BeforeUnloadEvent) => event.preventDefault();
}
6 changes: 3 additions & 3 deletions ui/src/app/review/assessment/feedback/feedback.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ export class FeedbackComponent implements OnInit {
if (!attachment) {
return;
}
this.collaborative && attachment.externalId
? this.Attachment.downloadCollaborativeAttachment(attachment.externalId, attachment.fileName)
: this.Attachment.downloadFeedbackAttachment(this.exam);
if (this.collaborative && attachment.externalId)
this.Attachment.downloadCollaborativeAttachment(attachment.externalId, attachment.fileName);
else this.Attachment.downloadFeedbackAttachment(this.exam);
};

removeFeedbackAttachment = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { NgbCollapse } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import type { Exam, ExamParticipation, ExamSectionQuestion } from 'src/app/exam/exam.model';
import type { ExaminationQuestion } from 'src/app/examination/examination.model';
import { AssessmentService } from 'src/app/review/assessment/assessment.service';
import type { ReviewQuestion } from 'src/app/review/review.model';
import { AttachmentService } from 'src/app/shared/attachment/attachment.service';
Expand Down Expand Up @@ -118,8 +117,8 @@ export class EssayQuestionComponent implements OnInit {

insertEssayScore = () => {
if (this.collaborative) {
return this.Assessment.saveCollaborativeEssayScore$(
this.sectionQuestion as ExaminationQuestion,
this.Assessment.saveCollaborativeEssayScore$(
this.sectionQuestion,
this.id,
this.ref,
this.participation._rev as string,
Expand All @@ -128,8 +127,9 @@ export class EssayQuestionComponent implements OnInit {
this.scored.emit(resp.rev);
});
} else {
return this.Assessment.saveEssayScore$(this.sectionQuestion as ExaminationQuestion).subscribe(() => {
this.toast.info(this.translate.instant('i18n_graded')), this.scored.emit();
this.Assessment.saveEssayScore$(this.sectionQuestion).subscribe(() => {
this.toast.info(this.translate.instant('i18n_graded'));
this.scored.emit();
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { forkJoin } from 'rxjs';
import { catchError, forkJoin, Observable, of, tap } from 'rxjs';
import { AssessmentService } from 'src/app/review/assessment/assessment.service';
import { QuestionFlowComponent } from 'src/app/review/questions/flow/question-flow.component';
import { QuestionReviewService } from 'src/app/review/questions/question-review.service';
Expand Down Expand Up @@ -115,7 +115,7 @@ export class QuestionAssessmentComponent implements OnInit {
isFinalized = (review: QuestionReview) => this.QuestionReview.isFinalized(review);

saveAssessments = (answers: ReviewQuestion[]) =>
forkJoin(answers.map(this.saveEvaluation)).subscribe(() => (this.reviews = [...this.reviews]));
forkJoin(answers.map(this.saveEvaluation$)).subscribe(() => (this.reviews = [...this.reviews]));

downloadQuestionAttachment = () => this.Attachment.downloadQuestionAttachment(this.selectedReview.question);

Expand All @@ -130,10 +130,12 @@ export class QuestionAssessmentComponent implements OnInit {
this.lockedAnswers = this.selectedReview.answers.filter(this.isLocked);
};

private saveEvaluation = (answer: ReviewQuestion) => {
return new Promise<void>((resolve) => {
answer.essayAnswer.evaluatedScore = answer.essayAnswer.temporaryScore;
this.Assessment.saveEssayScore$(answer).subscribe(() => {
private saveEvaluation$ = (answer: ReviewQuestion): Observable<void> => {
// TODO: this looks shady with rollback and all, whatabout smth like
// const tempAnswer: ReviewQuestion = {...answer, essayAnswer: {... answer.essayAnswer, evaluatedScore: answer.essayAnswer.temporaryScore}};
answer.essayAnswer.evaluatedScore = answer.essayAnswer.temporaryScore;
return this.Assessment.saveEssayScore$(answer).pipe(
tap(() => {
this.toast.info(this.translate.instant('i18n_graded'));
if (this.assessedAnswers.indexOf(answer) === -1) {
this.unassessedAnswers.splice(this.unassessedAnswers.indexOf(answer), 1);
Expand All @@ -152,15 +154,14 @@ export class QuestionAssessmentComponent implements OnInit {
}
}
}
resolve();
}),
(err: string) => {
// Roll back
answer.essayAnswer.evaluatedScore = answer.essayAnswer.temporaryScore;
this.toast.error(err);
resolve();
};
});
catchError((err) => {
// Roll back
answer.essayAnswer.evaluatedScore = answer.essayAnswer.temporaryScore;
this.toast.error(err);
return of();
}),
);
};

private isLocked = (answer: ReviewQuestion) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/file/file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class FileService {
ia[i] = byteString.charCodeAt(i);
}
blob = new Blob([ia], { type: contentType });
} catch (e) {
} catch {
// Maybe this isn't base64, try plaintext approaches
const text = contentType === 'application/json' ? JSON.stringify(data, null, 2) : data;
blob = new Blob([text], { type: contentType });
Expand Down

0 comments on commit 142ba21

Please sign in to comment.