Skip to content

Commit

Permalink
feat/#166 [fix result response of api userExam]
Browse files Browse the repository at this point in the history
  • Loading branch information
DungNguyen2003 committed Apr 21, 2023
1 parent f974b42 commit 569ffe8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/apis/v1/exam/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const getExamById = async (id: string, userRank: string, userEmail: strin
title: 1,
description: 1,
is_approved: 1,
school_year: 1,
author: {
_id: '$author._id',
fullname: '$author.fullname',
Expand Down
18 changes: 18 additions & 0 deletions src/apis/v1/userExam/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ export const getUserExamByOwner = async (userEmail: string, userExamId: string)
as: 'author',
},
},
{
$lookup: {
from: 'exam',
localField: 'original_exam',
foreignField: '_id',
as: 'exam',
},
},
{
$lookup: {
from: 'user',
localField: 'exam.author',
foreignField: '_id',
as: 'author_exam',
},
},
{
$lookup: {
from: 'subject',
Expand Down Expand Up @@ -319,6 +335,7 @@ export const getUserExamByOwner = async (userEmail: string, userExamId: string)
'questions.author': 0,
'user_answers.is_deleted': 0,
'user_answers.deleted_at': 0,
exam: 0,
},
},
];
Expand Down Expand Up @@ -357,6 +374,7 @@ export const getUserExamByOwner = async (userEmail: string, userExamId: string)
_id: question._id,
};
}),
author_exam: hideUserInfoIfRequired(userExam[0]?.author_exam[0]),
author: hideUserInfoIfRequired(userExam[0]?.author),
};
} catch (error) {
Expand Down

0 comments on commit 569ffe8

Please sign in to comment.