Skip to content

Commit

Permalink
feat/#166 [update api userExam]
Browse files Browse the repository at this point in the history
  • Loading branch information
DungNguyen2003 committed Apr 24, 2023
1 parent aced730 commit 963e748
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/apis/v1/userExam/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,11 @@ export const submitTheExam = async (input: SubmitTheExamDto, userEmail: string)
throw new HttpException(403, 'not allowed', ErrorCodes.BAD_REQUEST.CODE);
}

await calculateScore(userExam[0], userExam[0]?.user_answer_id);
const score = await calculateScore(userExam[0], userExam[0]?.user_answer_id);
const data = await UserExamModel.find({ _id });
logger.info(`Submit the exam successfully`);

return 'OK';
return { user_exam_id: data[0]?._id, score, is_completed: data[0]?.is_completed };
} catch (error) {
logger.error(`Error while submit the exam: ${error}`);
throw new HttpException(400, error, ErrorCodes.BAD_REQUEST.CODE);
Expand Down

0 comments on commit 963e748

Please sign in to comment.