Skip to content

Commit

Permalink
more suitable solution & fixes to course withdrawal
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoerlitz committed Aug 16, 2023
1 parent 11ef549 commit 29413f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/controllers/course/CourseInformationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function getCourseTrainingInformationByUUID(request: Request, response: Re
{
association: User.associations.training_sessions,
through: {
as: 'single_user_through',
as: "training_session_belongs_to_users",
attributes: ["passed", "log_id"],
where: {
user_id: user.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ async function getPlanned(request: Request, response: Response) {
where: {
[Op.or]: {
mentor_id: user.id,
cpt_examiner_id: user.id
cpt_examiner_id: user.id,
},
},
include: [
TrainingSession.associations.course,
TrainingSession.associations.training_type,
{
association: TrainingSession.associations.training_session_belongs_to_users,
attributes: ['passed']
}
]
attributes: ["passed"],
},
],
});

/*
Expand All @@ -98,7 +98,7 @@ async function getPlanned(request: Request, response: Response) {
}

return hasOneNonPassed;
})
});

response.send(trainingSession);
}
Expand Down
12 changes: 11 additions & 1 deletion src/controllers/training-session/TrainingSessionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ async function getByUUID(request: Request, response: Response) {
return;
}

response.send(session);
const requestingUserPassed = await TrainingSessionBelongsToUsers.findOne({
where: {
user_id: user.id,
training_session_id: session.id,
},
});

response.send({
...session.toJSON(),
user_passed: requestingUserPassed == null ? null : requestingUserPassed.passed,
});
}

async function withdrawFromSessionByUUID(request: Request, response: Response) {
Expand Down

0 comments on commit 29413f1

Please sign in to comment.