refactor: reorder searchInstructors endpoint and fix role code to uppercase INSTRUCTOR, add lesson completion tracking on quiz pass
This commit is contained in:
parent
8e57cb124a
commit
24c37df4ef
3 changed files with 39 additions and 17 deletions
|
|
@ -357,7 +357,7 @@ export class CoursesInstructorService {
|
|||
{ email: { contains: input.query, mode: 'insensitive' } },
|
||||
{ username: { contains: input.query, mode: 'insensitive' } },
|
||||
],
|
||||
role: { code: 'instructor' }
|
||||
role: { code: 'INSTRUCTOR' }
|
||||
},
|
||||
include: {
|
||||
profile: true
|
||||
|
|
@ -407,7 +407,7 @@ export class CoursesInstructorService {
|
|||
{ email: addinstructorCourse.email_or_username },
|
||||
{ username: addinstructorCourse.email_or_username },
|
||||
],
|
||||
role: { code: 'instructor' }
|
||||
role: { code: 'INSTRUCTOR' }
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1169,6 +1169,28 @@ export class CoursesStudentService {
|
|||
},
|
||||
});
|
||||
|
||||
// If passed, upsert lesson_progress to mark lesson as completed
|
||||
if (isPassed) {
|
||||
await prisma.lessonProgress.upsert({
|
||||
where: {
|
||||
user_id_lesson_id: {
|
||||
user_id: decoded.id,
|
||||
lesson_id,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
user_id: decoded.id,
|
||||
lesson_id,
|
||||
is_completed: true,
|
||||
completed_at: now,
|
||||
},
|
||||
update: {
|
||||
is_completed: true,
|
||||
completed_at: now,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
message: isPassed ? 'Quiz passed!' : 'Quiz completed',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue