chore: improve enrollment documentation

This commit is contained in:
Rotimi Best
2026-06-10 02:56:00 +01:00
parent bb88847570
commit ab25b8e5d7
33 changed files with 1442 additions and 728 deletions
+7 -4
View File
@@ -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);
}