-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/SAIG-KMITL/edusaig-api into dev
- Loading branch information
Showing
40 changed files
with
2,201 additions
and
215 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { ExamAttemptStatus } from 'src/shared/enums'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { PaginatedResponse } from 'src/shared/pagination/dtos/paginate-response.dto'; | ||
import { UserResponseDto } from 'src/user/dtos/user-response.dto'; | ||
import { ExamAttempt } from '../exam-attempt.entity'; | ||
import { PretestResponseDto } from 'src/pretest/dtos/pretest-response.dto'; | ||
|
||
export class ExamAttemptPretestResponseDto { | ||
@ApiProperty({ | ||
description: 'Exam Attempy ID', | ||
type: String, | ||
example: '123e4567-e89b-12d3-a456-426614174000', | ||
}) | ||
id: string; | ||
|
||
@ApiProperty({ | ||
description: 'Pretest Data', | ||
type: PretestResponseDto, | ||
example: { | ||
id: '123e4567-e89b-12d3-a456-426614174000', | ||
title: 'Exam title', | ||
description: 'Exam description', | ||
timeLimit: 20, | ||
passingScore: 3, | ||
maxAttempts: 1, | ||
createdAt: '2024-11-26T11:10:00.257Z', | ||
updatedAt: '2024-11-26T11:10:00.257Z', | ||
}, | ||
}) | ||
pretest: PretestResponseDto; | ||
|
||
@ApiProperty({ | ||
description: 'User Data', | ||
type: String, | ||
example: { | ||
id: '389d1065-b898-4249-9d3d-e17e100336a7', | ||
username: 'johndoe', | ||
fullname: 'John Doe', | ||
role: 'student', | ||
email: 'johndoe@gmail.com', | ||
profileKey: null, | ||
}, | ||
}) | ||
user: UserResponseDto; | ||
|
||
@ApiProperty({ | ||
description: 'Score', | ||
type: String, | ||
example: 0, | ||
}) | ||
score: number; | ||
|
||
@ApiProperty({ | ||
description: 'Exam attempt status', | ||
type: String, | ||
example: ExamAttemptStatus.IN_PROGRESS, | ||
enum: ExamAttemptStatus, | ||
}) | ||
status: ExamAttemptStatus; | ||
|
||
@ApiProperty({ | ||
description: 'Exam attempt start at', | ||
type: Date, | ||
example: new Date(), | ||
}) | ||
startedAt: Date; | ||
|
||
@ApiProperty({ | ||
description: 'Exam attempt submit at', | ||
type: Date, | ||
example: new Date(), | ||
}) | ||
submittedAt: Date; | ||
|
||
constructor(examAttempt: ExamAttempt) { | ||
this.id = examAttempt.id; | ||
this.pretest = examAttempt.pretest; | ||
this.user = examAttempt.user; | ||
this.score = examAttempt.score; | ||
this.status = examAttempt.status; | ||
this.startedAt = examAttempt.startedAt; | ||
this.submittedAt = examAttempt.submittedAt; | ||
} | ||
} | ||
|
||
export class PaginatedExamAttemptPretestResponseDto extends PaginatedResponse( | ||
ExamAttemptPretestResponseDto, | ||
) { | ||
constructor( | ||
examAttempt: ExamAttempt[], | ||
total: number, | ||
pageSize: number, | ||
currentPage: number, | ||
) { | ||
const examAttemptDtos = examAttempt.map( | ||
(examAttempt) => new ExamAttemptPretestResponseDto(examAttempt), | ||
); | ||
super(examAttemptDtos, total, pageSize, currentPage); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import { OmitType, PartialType } from '@nestjs/swagger'; | ||
import { CreateExamAttemptDto } from './create-exam-attempt.dto'; | ||
import { | ||
CreateExamAttemptDto, | ||
CreateExamAttemptPretestDto, | ||
} from './create-exam-attempt.dto'; | ||
|
||
export class UpdateExamAttemptDto extends PartialType( | ||
OmitType(CreateExamAttemptDto, ['examId'] as const), | ||
) {} | ||
|
||
export class UpdateExamAttemptPretestDto extends PartialType( | ||
OmitType(CreateExamAttemptPretestDto, ['pretestId'] as const), | ||
) {} |
Oops, something went wrong.