chore: improve enrollment documentation
This commit is contained in:
@@ -631,7 +631,12 @@ export async function enrollInCourse(
|
||||
}
|
||||
|
||||
const courseMetadata = (courseWithRelations.metadata as { allowNewStudent?: boolean } | null) ?? null;
|
||||
if (courseMetadata?.allowNewStudent === false) {
|
||||
const isInternalEnrollmentOnly =
|
||||
(org.settings as { internalEnrollmentOnly?: boolean } | null)?.internalEnrollmentOnly ?? false;
|
||||
|
||||
const orgMemberId = await getOrganizationMemberIdByOrgAndProfile(org.id, user.id);
|
||||
|
||||
if (courseMetadata?.allowNewStudent === false && !(isInternalEnrollmentOnly && orgMemberId)) {
|
||||
throw new AppError('This course is not accepting new students', ErrorCodes.VALIDATION_ERROR, 400);
|
||||
}
|
||||
|
||||
@@ -649,8 +654,6 @@ export async function enrollInCourse(
|
||||
};
|
||||
}
|
||||
|
||||
const orgMemberId = await getOrganizationMemberIdByOrgAndProfile(org.id, user.id);
|
||||
|
||||
if (!orgMemberId) {
|
||||
await createOrganizationMember({
|
||||
organizationId: org.id,
|
||||
@@ -950,7 +953,7 @@ export async function acceptStudentInvite(token: string, user: TAuthUser, contex
|
||||
throw new AppError('This invite is not valid for student enrollment', ErrorCodes.UNAUTHORIZED, 403);
|
||||
}
|
||||
|
||||
if (course.status !== 'ACTIVE' || !course.isPublished) {
|
||||
if (course.status !== 'ACTIVE') {
|
||||
throw new AppError('This course is not available for enrollment', ErrorCodes.VALIDATION_ERROR, 400);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user