@hed-hog/lms 0.0.304 → 0.0.306
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +413 -401
- package/dist/certificate/certificate.controller.d.ts +90 -0
- package/dist/certificate/certificate.controller.d.ts.map +1 -0
- package/dist/certificate/certificate.controller.js +121 -0
- package/dist/certificate/certificate.controller.js.map +1 -0
- package/dist/certificate/certificate.module.d.ts +3 -0
- package/dist/certificate/certificate.module.d.ts.map +1 -0
- package/dist/certificate/certificate.module.js +26 -0
- package/dist/certificate/certificate.module.js.map +1 -0
- package/dist/certificate/certificate.service.d.ts +115 -0
- package/dist/certificate/certificate.service.d.ts.map +1 -0
- package/dist/certificate/certificate.service.js +343 -0
- package/dist/certificate/certificate.service.js.map +1 -0
- package/dist/certificate/dto/create-certificate-template.dto.d.ts +8 -0
- package/dist/certificate/dto/create-certificate-template.dto.d.ts.map +1 -0
- package/dist/certificate/dto/create-certificate-template.dto.js +44 -0
- package/dist/certificate/dto/create-certificate-template.dto.js.map +1 -0
- package/dist/certificate/dto/update-certificate-template.dto.d.ts +6 -0
- package/dist/certificate/dto/update-certificate-template.dto.d.ts.map +1 -0
- package/dist/certificate/dto/update-certificate-template.dto.js +9 -0
- package/dist/certificate/dto/update-certificate-template.dto.js.map +1 -0
- package/dist/class-group/class-group.controller.d.ts +305 -0
- package/dist/class-group/class-group.controller.d.ts.map +1 -0
- package/dist/class-group/class-group.controller.js +257 -0
- package/dist/class-group/class-group.controller.js.map +1 -0
- package/dist/class-group/class-group.module.d.ts +3 -0
- package/dist/class-group/class-group.module.d.ts.map +1 -0
- package/dist/class-group/class-group.module.js +25 -0
- package/dist/class-group/class-group.module.js.map +1 -0
- package/dist/class-group/class-group.service.d.ts +354 -0
- package/dist/class-group/class-group.service.d.ts.map +1 -0
- package/dist/class-group/class-group.service.js +1356 -0
- package/dist/class-group/class-group.service.js.map +1 -0
- package/dist/class-group/dto/create-class-group.dto.d.ts +33 -0
- package/dist/class-group/dto/create-class-group.dto.d.ts.map +1 -0
- package/dist/class-group/dto/create-class-group.dto.js +165 -0
- package/dist/class-group/dto/create-class-group.dto.js.map +1 -0
- package/dist/class-group/dto/create-session.dto.d.ts +22 -0
- package/dist/class-group/dto/create-session.dto.d.ts.map +1 -0
- package/dist/class-group/dto/create-session.dto.js +117 -0
- package/dist/class-group/dto/create-session.dto.js.map +1 -0
- package/dist/class-group/dto/enrollment.dto.d.ts +22 -0
- package/dist/class-group/dto/enrollment.dto.d.ts.map +1 -0
- package/dist/class-group/dto/enrollment.dto.js +89 -0
- package/dist/class-group/dto/enrollment.dto.js.map +1 -0
- package/dist/class-group/dto/update-class-group.dto.d.ts +6 -0
- package/dist/class-group/dto/update-class-group.dto.d.ts.map +1 -0
- package/dist/class-group/dto/update-class-group.dto.js +9 -0
- package/dist/class-group/dto/update-class-group.dto.js.map +1 -0
- package/dist/class-group/dto/update-session.dto.d.ts +7 -0
- package/dist/class-group/dto/update-session.dto.d.ts.map +1 -0
- package/dist/class-group/dto/update-session.dto.js +24 -0
- package/dist/class-group/dto/update-session.dto.js.map +1 -0
- package/dist/course/course-structure.controller.d.ts +127 -0
- package/dist/course/course-structure.controller.d.ts.map +1 -0
- package/dist/course/course-structure.controller.js +115 -0
- package/dist/course/course-structure.controller.js.map +1 -0
- package/dist/course/course-structure.service.d.ts +142 -0
- package/dist/course/course-structure.service.d.ts.map +1 -0
- package/dist/course/course-structure.service.js +445 -0
- package/dist/course/course-structure.service.js.map +1 -0
- package/dist/course/course.controller.d.ts +195 -0
- package/dist/course/course.controller.d.ts.map +1 -0
- package/dist/course/course.controller.js +104 -0
- package/dist/course/course.controller.js.map +1 -0
- package/dist/course/course.module.d.ts +3 -0
- package/dist/course/course.module.d.ts.map +1 -0
- package/dist/course/course.module.js +28 -0
- package/dist/course/course.module.js.map +1 -0
- package/dist/course/course.service.d.ts +215 -0
- package/dist/course/course.service.d.ts.map +1 -0
- package/dist/course/course.service.js +743 -0
- package/dist/course/course.service.js.map +1 -0
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts +24 -0
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts.map +1 -0
- package/dist/course/dto/create-course-structure-lesson.dto.js +118 -0
- package/dist/course/dto/create-course-structure-lesson.dto.js.map +1 -0
- package/dist/course/dto/create-course-structure-session.dto.d.ts +7 -0
- package/dist/course/dto/create-course-structure-session.dto.d.ts.map +1 -0
- package/dist/course/dto/create-course-structure-session.dto.js +40 -0
- package/dist/course/dto/create-course-structure-session.dto.js.map +1 -0
- package/dist/course/dto/create-course.dto.d.ts +26 -0
- package/dist/course/dto/create-course.dto.d.ts.map +1 -0
- package/dist/course/dto/create-course.dto.js +138 -0
- package/dist/course/dto/create-course.dto.js.map +1 -0
- package/dist/course/dto/update-course-structure-lesson.dto.d.ts +6 -0
- package/dist/course/dto/update-course-structure-lesson.dto.d.ts.map +1 -0
- package/dist/course/dto/update-course-structure-lesson.dto.js +9 -0
- package/dist/course/dto/update-course-structure-lesson.dto.js.map +1 -0
- package/dist/course/dto/update-course-structure-session.dto.d.ts +6 -0
- package/dist/course/dto/update-course-structure-session.dto.d.ts.map +1 -0
- package/dist/course/dto/update-course-structure-session.dto.js +9 -0
- package/dist/course/dto/update-course-structure-session.dto.js.map +1 -0
- package/dist/course/dto/update-course.dto.d.ts +6 -0
- package/dist/course/dto/update-course.dto.d.ts.map +1 -0
- package/dist/course/dto/update-course.dto.js +9 -0
- package/dist/course/dto/update-course.dto.js.map +1 -0
- package/dist/dashboard/dashboard.controller.d.ts +101 -0
- package/dist/dashboard/dashboard.controller.d.ts.map +1 -0
- package/dist/dashboard/dashboard.controller.js +40 -0
- package/dist/dashboard/dashboard.controller.js.map +1 -0
- package/dist/dashboard/dashboard.module.d.ts +3 -0
- package/dist/dashboard/dashboard.module.d.ts.map +1 -0
- package/dist/dashboard/dashboard.module.js +25 -0
- package/dist/dashboard/dashboard.module.js.map +1 -0
- package/dist/dashboard/dashboard.service.d.ts +130 -0
- package/dist/dashboard/dashboard.service.d.ts.map +1 -0
- package/dist/dashboard/dashboard.service.js +626 -0
- package/dist/dashboard/dashboard.service.js.map +1 -0
- package/dist/enterprise/dto/add-enterprise-class-group.dto.d.ts +4 -0
- package/dist/enterprise/dto/add-enterprise-class-group.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/add-enterprise-class-group.dto.js +22 -0
- package/dist/enterprise/dto/add-enterprise-class-group.dto.js.map +1 -0
- package/dist/enterprise/dto/add-enterprise-course.dto.d.ts +5 -0
- package/dist/enterprise/dto/add-enterprise-course.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/add-enterprise-course.dto.js +27 -0
- package/dist/enterprise/dto/add-enterprise-course.dto.js.map +1 -0
- package/dist/enterprise/dto/add-enterprise-student.dto.d.ts +5 -0
- package/dist/enterprise/dto/add-enterprise-student.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/add-enterprise-student.dto.js +27 -0
- package/dist/enterprise/dto/add-enterprise-student.dto.js.map +1 -0
- package/dist/enterprise/dto/add-enterprise-user.dto.d.ts +7 -0
- package/dist/enterprise/dto/add-enterprise-user.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/add-enterprise-user.dto.js +36 -0
- package/dist/enterprise/dto/add-enterprise-user.dto.js.map +1 -0
- package/dist/enterprise/dto/create-enterprise.dto.d.ts +10 -0
- package/dist/enterprise/dto/create-enterprise.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/create-enterprise.dto.js +54 -0
- package/dist/enterprise/dto/create-enterprise.dto.js.map +1 -0
- package/dist/enterprise/dto/update-enterprise-student.dto.d.ts +4 -0
- package/dist/enterprise/dto/update-enterprise-student.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/update-enterprise-student.dto.js +22 -0
- package/dist/enterprise/dto/update-enterprise-student.dto.js.map +1 -0
- package/dist/enterprise/dto/update-enterprise-user.dto.d.ts +5 -0
- package/dist/enterprise/dto/update-enterprise-user.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/update-enterprise-user.dto.js +27 -0
- package/dist/enterprise/dto/update-enterprise-user.dto.js.map +1 -0
- package/dist/enterprise/dto/update-enterprise.dto.d.ts +6 -0
- package/dist/enterprise/dto/update-enterprise.dto.d.ts.map +1 -0
- package/dist/enterprise/dto/update-enterprise.dto.js +9 -0
- package/dist/enterprise/dto/update-enterprise.dto.js.map +1 -0
- package/dist/enterprise/enterprise.controller.d.ts +269 -0
- package/dist/enterprise/enterprise.controller.d.ts.map +1 -0
- package/dist/enterprise/enterprise.controller.js +311 -0
- package/dist/enterprise/enterprise.controller.js.map +1 -0
- package/dist/enterprise/enterprise.module.d.ts +3 -0
- package/dist/enterprise/enterprise.module.d.ts.map +1 -0
- package/dist/enterprise/enterprise.module.js +25 -0
- package/dist/enterprise/enterprise.module.js.map +1 -0
- package/dist/enterprise/enterprise.service.d.ts +282 -0
- package/dist/enterprise/enterprise.service.d.ts.map +1 -0
- package/dist/enterprise/enterprise.service.js +627 -0
- package/dist/enterprise/enterprise.service.js.map +1 -0
- package/dist/evaluation/evaluation.controller.d.ts +56 -0
- package/dist/evaluation/evaluation.controller.d.ts.map +1 -0
- package/dist/evaluation/evaluation.controller.js +76 -0
- package/dist/evaluation/evaluation.controller.js.map +1 -0
- package/dist/evaluation/evaluation.module.d.ts +3 -0
- package/dist/evaluation/evaluation.module.d.ts.map +1 -0
- package/dist/evaluation/evaluation.module.js +25 -0
- package/dist/evaluation/evaluation.module.js.map +1 -0
- package/dist/evaluation/evaluation.service.d.ts +67 -0
- package/dist/evaluation/evaluation.service.d.ts.map +1 -0
- package/dist/evaluation/evaluation.service.js +378 -0
- package/dist/evaluation/evaluation.service.js.map +1 -0
- package/dist/exam/dto/create-exam-question.dto.d.ts +25 -0
- package/dist/exam/dto/create-exam-question.dto.d.ts.map +1 -0
- package/dist/exam/dto/create-exam-question.dto.js +117 -0
- package/dist/exam/dto/create-exam-question.dto.js.map +1 -0
- package/dist/exam/dto/create-exam.dto.d.ts +11 -0
- package/dist/exam/dto/create-exam.dto.d.ts.map +1 -0
- package/dist/exam/dto/create-exam.dto.js +63 -0
- package/dist/exam/dto/create-exam.dto.js.map +1 -0
- package/dist/exam/dto/reorder-exam-questions.dto.d.ts +4 -0
- package/dist/exam/dto/reorder-exam-questions.dto.d.ts.map +1 -0
- package/dist/exam/dto/reorder-exam-questions.dto.js +23 -0
- package/dist/exam/dto/reorder-exam-questions.dto.js.map +1 -0
- package/dist/exam/dto/save-exam-attempt-answers.dto.d.ts +14 -0
- package/dist/exam/dto/save-exam-attempt-answers.dto.d.ts.map +1 -0
- package/dist/exam/dto/save-exam-attempt-answers.dto.js +68 -0
- package/dist/exam/dto/save-exam-attempt-answers.dto.js.map +1 -0
- package/dist/exam/dto/start-exam-attempt.dto.d.ts +4 -0
- package/dist/exam/dto/start-exam-attempt.dto.d.ts.map +1 -0
- package/dist/exam/dto/start-exam-attempt.dto.js +23 -0
- package/dist/exam/dto/start-exam-attempt.dto.js.map +1 -0
- package/dist/exam/dto/submit-exam-attempt.dto.d.ts +5 -0
- package/dist/exam/dto/submit-exam-attempt.dto.d.ts.map +1 -0
- package/dist/exam/dto/submit-exam-attempt.dto.js +23 -0
- package/dist/exam/dto/submit-exam-attempt.dto.js.map +1 -0
- package/dist/exam/dto/update-exam-question.dto.d.ts +6 -0
- package/dist/exam/dto/update-exam-question.dto.d.ts.map +1 -0
- package/dist/exam/dto/update-exam-question.dto.js +9 -0
- package/dist/exam/dto/update-exam-question.dto.js.map +1 -0
- package/dist/exam/dto/update-exam.dto.d.ts +6 -0
- package/dist/exam/dto/update-exam.dto.d.ts.map +1 -0
- package/dist/exam/dto/update-exam.dto.js +9 -0
- package/dist/exam/dto/update-exam.dto.js.map +1 -0
- package/dist/exam/exam-attempt.controller.d.ts +273 -0
- package/dist/exam/exam-attempt.controller.d.ts.map +1 -0
- package/dist/exam/exam-attempt.controller.js +84 -0
- package/dist/exam/exam-attempt.controller.js.map +1 -0
- package/dist/exam/exam-attempt.service.d.ts +302 -0
- package/dist/exam/exam-attempt.service.d.ts.map +1 -0
- package/dist/exam/exam-attempt.service.js +776 -0
- package/dist/exam/exam-attempt.service.js.map +1 -0
- package/dist/exam/exam.controller.d.ts +162 -0
- package/dist/exam/exam.controller.d.ts.map +1 -0
- package/dist/exam/exam.controller.js +158 -0
- package/dist/exam/exam.controller.js.map +1 -0
- package/dist/exam/exam.module.d.ts +3 -0
- package/dist/exam/exam.module.d.ts.map +1 -0
- package/dist/exam/exam.module.js +27 -0
- package/dist/exam/exam.module.js.map +1 -0
- package/dist/exam/exam.service.d.ts +179 -0
- package/dist/exam/exam.service.d.ts.map +1 -0
- package/dist/exam/exam.service.js +597 -0
- package/dist/exam/exam.service.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/instructor/dto/create-instructor.dto.d.ts +10 -0
- package/dist/instructor/dto/create-instructor.dto.d.ts.map +1 -0
- package/dist/instructor/dto/create-instructor.dto.js +55 -0
- package/dist/instructor/dto/create-instructor.dto.js.map +1 -0
- package/dist/instructor/dto/update-instructor.dto.d.ts +9 -0
- package/dist/instructor/dto/update-instructor.dto.d.ts.map +1 -0
- package/dist/instructor/dto/update-instructor.dto.js +51 -0
- package/dist/instructor/dto/update-instructor.dto.js.map +1 -0
- package/dist/instructor/instructor.controller.d.ts +52 -0
- package/dist/instructor/instructor.controller.d.ts.map +1 -0
- package/dist/instructor/instructor.controller.js +98 -0
- package/dist/instructor/instructor.controller.js.map +1 -0
- package/dist/instructor/instructor.module.d.ts +3 -0
- package/dist/instructor/instructor.module.d.ts.map +1 -0
- package/dist/instructor/instructor.module.js +25 -0
- package/dist/instructor/instructor.module.js.map +1 -0
- package/dist/instructor/instructor.service.d.ts +79 -0
- package/dist/instructor/instructor.service.d.ts.map +1 -0
- package/dist/instructor/instructor.service.js +528 -0
- package/dist/instructor/instructor.service.js.map +1 -0
- package/dist/lms.module.d.ts.map +1 -1
- package/dist/lms.module.js +36 -4
- package/dist/lms.module.js.map +1 -1
- package/dist/reports/reports.controller.d.ts +69 -0
- package/dist/reports/reports.controller.d.ts.map +1 -0
- package/dist/reports/reports.controller.js +40 -0
- package/dist/reports/reports.controller.js.map +1 -0
- package/dist/reports/reports.module.d.ts +3 -0
- package/dist/reports/reports.module.d.ts.map +1 -0
- package/dist/reports/reports.module.js +25 -0
- package/dist/reports/reports.module.js.map +1 -0
- package/dist/reports/reports.service.d.ts +80 -0
- package/dist/reports/reports.service.d.ts.map +1 -0
- package/dist/reports/reports.service.js +366 -0
- package/dist/reports/reports.service.js.map +1 -0
- package/dist/training/dto/create-training.dto.d.ts +19 -0
- package/dist/training/dto/create-training.dto.d.ts.map +1 -0
- package/dist/training/dto/create-training.dto.js +98 -0
- package/dist/training/dto/create-training.dto.js.map +1 -0
- package/dist/training/dto/update-training.dto.d.ts +6 -0
- package/dist/training/dto/update-training.dto.d.ts.map +1 -0
- package/dist/training/dto/update-training.dto.js +9 -0
- package/dist/training/dto/update-training.dto.js.map +1 -0
- package/dist/training/training.controller.d.ts +195 -0
- package/dist/training/training.controller.d.ts.map +1 -0
- package/dist/training/training.controller.js +104 -0
- package/dist/training/training.controller.js.map +1 -0
- package/dist/training/training.module.d.ts +3 -0
- package/dist/training/training.module.d.ts.map +1 -0
- package/dist/training/training.module.js +25 -0
- package/dist/training/training.module.js.map +1 -0
- package/dist/training/training.service.d.ts +213 -0
- package/dist/training/training.service.d.ts.map +1 -0
- package/dist/training/training.service.js +497 -0
- package/dist/training/training.service.js.map +1 -0
- package/hedhog/data/dashboard.yaml +6 -0
- package/hedhog/data/dashboard_component.yaml +153 -0
- package/hedhog/data/dashboard_component_role.yaml +97 -0
- package/hedhog/data/dashboard_item.yaml +167 -0
- package/hedhog/data/dashboard_role.yaml +6 -0
- package/hedhog/data/instructor_qualification.yaml +16 -0
- package/hedhog/data/menu.yaml +129 -19
- package/hedhog/data/role.yaml +25 -1
- package/hedhog/data/route.yaml +867 -0
- package/hedhog/frontend/app/_components/class-form-sheet.tsx.ejs +1992 -0
- package/hedhog/frontend/app/_components/course-form-sheet.tsx.ejs +480 -0
- package/hedhog/frontend/app/_components/create-lms-instructor-sheet.tsx.ejs +591 -0
- package/hedhog/frontend/app/_components/create-lms-person-sheet.tsx.ejs +164 -0
- package/hedhog/frontend/app/_components/create-lms-student-person-sheet.tsx.ejs +120 -0
- package/hedhog/frontend/app/_components/lms-class-calendar.tsx.ejs +272 -0
- package/hedhog/frontend/app/_components/mobile-calendar.tsx.ejs +277 -0
- package/hedhog/frontend/app/_lib/editor/canvasInstance.ts.ejs +48 -0
- package/hedhog/frontend/app/_lib/editor/pctHelpers.ts.ejs +50 -0
- package/hedhog/frontend/app/_lib/editor/templateSerializer.ts.ejs +268 -0
- package/hedhog/frontend/app/_lib/editor/types.ts.ejs +94 -0
- package/hedhog/frontend/app/_lib/store/useTemplateStore.ts.ejs +284 -0
- package/hedhog/frontend/app/certificates/issued/page.tsx.ejs +638 -0
- package/hedhog/frontend/app/certificates/models/CanvasStage.tsx.ejs +916 -0
- package/hedhog/frontend/app/certificates/models/LeftPanel.tsx.ejs +200 -0
- package/hedhog/frontend/app/certificates/models/RightPanel.tsx.ejs +769 -0
- package/hedhog/frontend/app/certificates/models/TemplateEditorPage.tsx.ejs +104 -0
- package/hedhog/frontend/app/certificates/models/TopBar.tsx.ejs +354 -0
- package/hedhog/frontend/app/certificates/models/editor/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/certificates/models/page.tsx.ejs +883 -0
- package/hedhog/frontend/app/classes/[id]/_components/event-summary-popover.tsx.ejs +279 -0
- package/hedhog/frontend/app/classes/[id]/_components/quick-create-session-popover.tsx.ejs +1027 -0
- package/hedhog/frontend/app/classes/[id]/page.tsx.ejs +3130 -993
- package/hedhog/frontend/app/classes/page.tsx.ejs +2731 -759
- package/hedhog/frontend/app/courses/[id]/_components/CourseCertificateCard.tsx.ejs +80 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseClassificationCard.tsx.ejs +226 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseContentCard.tsx.ejs +71 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseDangerZoneCard.tsx.ejs +42 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseFlagsCard.tsx.ejs +111 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseMainInfoCard.tsx.ejs +113 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseMediaCard.tsx.ejs +215 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseMultiEntityPicker.tsx.ejs +236 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseRelationsCard.tsx.ejs +141 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseSectionCard.tsx.ejs +57 -0
- package/hedhog/frontend/app/courses/[id]/_components/CourseSummaryCard.tsx.ejs +60 -0
- package/hedhog/frontend/app/courses/[id]/_components/course-edit-types.ts.ejs +33 -0
- package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +933 -1103
- package/hedhog/frontend/app/courses/[id]/structure/page.tsx.ejs +699 -117
- package/hedhog/frontend/app/courses/page.tsx.ejs +1018 -1042
- package/hedhog/frontend/app/enterprise/[id]/page.tsx.ejs +317 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-activity-panel.tsx.ejs +88 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-admin-create-sheet.tsx.ejs +318 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-administrators-tab.tsx.ejs +332 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-class-create-sheet.tsx.ejs +58 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-classes-tab.tsx.ejs +390 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-company-identity-card.tsx.ejs +112 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-course-create-sheet.tsx.ejs +183 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-courses-tab.tsx.ejs +363 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-detail-constants.ts.ejs +88 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-detail-sheet.tsx.ejs +548 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-detail-utils.ts.ejs +33 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-mocks.ts.ejs +277 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-person-picker.ts.ejs +31 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-progress-bar.tsx.ejs +21 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-related-tab.tsx.ejs +224 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-sheet.tsx.ejs +397 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-student-create-sheet.tsx.ejs +167 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-students-tab.tsx.ejs +267 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-system-user-picker.ts.ejs +42 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-types.ts.ejs +96 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-user-create-sheet.tsx.ejs +207 -0
- package/hedhog/frontend/app/enterprise/_components/enterprise-user-distribution-chart.tsx.ejs +149 -0
- package/hedhog/frontend/app/enterprise/page.tsx.ejs +596 -0
- package/hedhog/frontend/app/evaluations/page.tsx.ejs +1250 -0
- package/hedhog/frontend/app/exams/[id]/attempt/page.tsx.ejs +642 -196
- package/hedhog/frontend/app/exams/[id]/page.tsx.ejs +11 -0
- package/hedhog/frontend/app/exams/[id]/questions/page.tsx.ejs +1316 -436
- package/hedhog/frontend/app/exams/page.tsx.ejs +799 -546
- package/hedhog/frontend/app/layout.tsx.ejs +5 -0
- package/hedhog/frontend/app/page.tsx.ejs +3 -1220
- package/hedhog/frontend/app/reports/courses/page.tsx.ejs +843 -0
- package/hedhog/frontend/app/reports/dashboard/page.tsx.ejs +890 -0
- package/hedhog/frontend/app/reports/page.tsx.ejs +802 -808
- package/hedhog/frontend/app/reports/students/page.tsx.ejs +772 -0
- package/hedhog/frontend/app/training/page.tsx.ejs +1873 -628
- package/hedhog/frontend/messages/en.json +1606 -111
- package/hedhog/frontend/messages/pt.json +1636 -134
- package/hedhog/frontend/widgets/active-classes-kpi.tsx.ejs +74 -0
- package/hedhog/frontend/widgets/active-courses-kpi.tsx.ejs +74 -0
- package/hedhog/frontend/widgets/approval-rate-kpi.tsx.ejs +81 -0
- package/hedhog/frontend/widgets/category-distribution-chart.tsx.ejs +119 -0
- package/hedhog/frontend/widgets/class-calendar.tsx.ejs +440 -0
- package/hedhog/frontend/widgets/completion-rate-kpi.tsx.ejs +81 -0
- package/hedhog/frontend/widgets/engagement-chart.tsx.ejs +120 -0
- package/hedhog/frontend/widgets/footer-summary.tsx.ejs +80 -0
- package/hedhog/frontend/widgets/issued-certificates-kpi.tsx.ejs +74 -0
- package/hedhog/frontend/widgets/latest-enrollments.tsx.ejs +166 -0
- package/hedhog/frontend/widgets/student-growth-chart.tsx.ejs +89 -0
- package/hedhog/frontend/widgets/top-courses-chart.tsx.ejs +104 -0
- package/hedhog/frontend/widgets/total-students-kpi.tsx.ejs +78 -0
- package/hedhog/frontend/widgets/upcoming-classes.tsx.ejs +152 -0
- package/hedhog/table/course.yaml +19 -1
- package/hedhog/table/course_class_group.yaml +8 -0
- package/hedhog/table/course_class_session.yaml +33 -0
- package/hedhog/table/course_instructor.yaml +27 -0
- package/hedhog/table/enterprise.yaml +29 -0
- package/hedhog/table/enterprise_class_group.yaml +20 -0
- package/hedhog/table/enterprise_course.yaml +23 -0
- package/hedhog/table/enterprise_student.yaml +24 -0
- package/hedhog/table/enterprise_user.yaml +35 -0
- package/hedhog/table/instructor_qualification.yaml +26 -0
- package/hedhog/table/instructor_qualification_assignment.yaml +22 -0
- package/hedhog/table/question.yaml +6 -0
- package/package.json +6 -6
- package/src/certificate/certificate.controller.ts +83 -0
- package/src/certificate/certificate.module.ts +13 -0
- package/src/certificate/certificate.service.ts +413 -0
- package/src/certificate/dto/create-certificate-template.dto.ts +25 -0
- package/src/certificate/dto/update-certificate-template.dto.ts +6 -0
- package/src/class-group/class-group.controller.ts +189 -0
- package/src/class-group/class-group.module.ts +12 -0
- package/src/class-group/class-group.service.ts +1802 -0
- package/src/class-group/dto/create-class-group.dto.ts +139 -0
- package/src/class-group/dto/create-session.dto.ts +102 -0
- package/src/class-group/dto/enrollment.dto.ts +70 -0
- package/src/class-group/dto/update-class-group.dto.ts +4 -0
- package/src/class-group/dto/update-session.dto.ts +9 -0
- package/src/course/course-structure.controller.ts +85 -0
- package/src/course/course-structure.service.ts +525 -0
- package/src/course/course.controller.ts +69 -0
- package/src/course/course.module.ts +15 -0
- package/src/course/course.service.ts +920 -0
- package/src/course/dto/create-course-structure-lesson.dto.ts +97 -0
- package/src/course/dto/create-course-structure-session.dto.ts +22 -0
- package/src/course/dto/create-course.dto.ts +111 -0
- package/src/course/dto/update-course-structure-lesson.dto.ts +6 -0
- package/src/course/dto/update-course-structure-session.dto.ts +6 -0
- package/src/course/dto/update-course.dto.ts +4 -0
- package/src/dashboard/dashboard.controller.ts +14 -0
- package/src/dashboard/dashboard.module.ts +12 -0
- package/src/dashboard/dashboard.service.ts +726 -0
- package/src/enterprise/dto/add-enterprise-class-group.dto.ts +7 -0
- package/src/enterprise/dto/add-enterprise-course.dto.ts +11 -0
- package/src/enterprise/dto/add-enterprise-student.dto.ts +16 -0
- package/src/enterprise/dto/add-enterprise-user.dto.ts +23 -0
- package/src/enterprise/dto/create-enterprise.dto.ts +41 -0
- package/src/enterprise/dto/update-enterprise-student.dto.ts +7 -0
- package/src/enterprise/dto/update-enterprise-user.dto.ts +11 -0
- package/src/enterprise/dto/update-enterprise.dto.ts +4 -0
- package/src/enterprise/enterprise.controller.ts +233 -0
- package/src/enterprise/enterprise.module.ts +12 -0
- package/src/enterprise/enterprise.service.ts +712 -0
- package/src/evaluation/evaluation.controller.ts +44 -0
- package/src/evaluation/evaluation.module.ts +12 -0
- package/src/evaluation/evaluation.service.ts +394 -0
- package/src/exam/dto/create-exam-question.dto.ts +103 -0
- package/src/exam/dto/create-exam.dto.ts +41 -0
- package/src/exam/dto/reorder-exam-questions.dto.ts +8 -0
- package/src/exam/dto/save-exam-attempt-answers.dto.ts +55 -0
- package/src/exam/dto/start-exam-attempt.dto.ts +8 -0
- package/src/exam/dto/submit-exam-attempt.dto.ts +8 -0
- package/src/exam/dto/update-exam-question.dto.ts +4 -0
- package/src/exam/dto/update-exam.dto.ts +4 -0
- package/src/exam/exam-attempt.controller.ts +65 -0
- package/src/exam/exam-attempt.service.ts +1008 -0
- package/src/exam/exam.controller.ts +102 -0
- package/src/exam/exam.module.ts +14 -0
- package/src/exam/exam.service.ts +784 -0
- package/src/index.ts +29 -0
- package/src/instructor/dto/create-instructor.dto.ts +43 -0
- package/src/instructor/dto/update-instructor.dto.ts +38 -0
- package/src/instructor/instructor.controller.ts +73 -0
- package/src/instructor/instructor.module.ts +12 -0
- package/src/instructor/instructor.service.ts +646 -0
- package/src/lms.module.ts +36 -4
- package/src/reports/reports.controller.ts +14 -0
- package/src/reports/reports.module.ts +12 -0
- package/src/reports/reports.service.ts +485 -0
- package/src/training/dto/create-training.dto.ts +81 -0
- package/src/training/dto/update-training.dto.ts +4 -0
- package/src/training/training.controller.ts +68 -0
- package/src/training/training.module.ts +12 -0
- package/src/training/training.service.ts +574 -0
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.CourseService = void 0;
|
|
24
|
+
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
25
|
+
const common_1 = require("@nestjs/common");
|
|
26
|
+
let CourseService = class CourseService {
|
|
27
|
+
constructor(prisma) {
|
|
28
|
+
this.prisma = prisma;
|
|
29
|
+
}
|
|
30
|
+
normalizeLevel(value) {
|
|
31
|
+
if (!value)
|
|
32
|
+
return undefined;
|
|
33
|
+
const normalized = String(value).trim().toLowerCase();
|
|
34
|
+
if (normalized === 'beginner' || normalized === 'iniciante') {
|
|
35
|
+
return 'beginner';
|
|
36
|
+
}
|
|
37
|
+
if (normalized === 'intermediate' || normalized === 'intermediario') {
|
|
38
|
+
return 'intermediate';
|
|
39
|
+
}
|
|
40
|
+
if (normalized === 'advanced' || normalized === 'avancado') {
|
|
41
|
+
return 'advanced';
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
normalizeStatus(value) {
|
|
46
|
+
if (!value)
|
|
47
|
+
return undefined;
|
|
48
|
+
const normalized = String(value).trim().toLowerCase();
|
|
49
|
+
if (normalized === 'published' ||
|
|
50
|
+
normalized === 'active' ||
|
|
51
|
+
normalized === 'ativo') {
|
|
52
|
+
return 'published';
|
|
53
|
+
}
|
|
54
|
+
if (normalized === 'draft' || normalized === 'rascunho') {
|
|
55
|
+
return 'draft';
|
|
56
|
+
}
|
|
57
|
+
if (normalized === 'archived' || normalized === 'arquivado') {
|
|
58
|
+
return 'archived';
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
normalizeOfferingType(value) {
|
|
63
|
+
if (!value)
|
|
64
|
+
return undefined;
|
|
65
|
+
const normalized = String(value).trim().toLowerCase();
|
|
66
|
+
if (normalized === 'scheduled') {
|
|
67
|
+
return 'scheduled';
|
|
68
|
+
}
|
|
69
|
+
if (normalized === 'on_demand' ||
|
|
70
|
+
normalized === 'ondemand' ||
|
|
71
|
+
normalized === 'on-demand') {
|
|
72
|
+
return 'on_demand';
|
|
73
|
+
}
|
|
74
|
+
if (normalized === 'blended') {
|
|
75
|
+
return 'blended';
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
normalizeOptionalText(value) {
|
|
80
|
+
const normalized = value === null || value === void 0 ? void 0 : value.trim();
|
|
81
|
+
return normalized ? normalized : undefined;
|
|
82
|
+
}
|
|
83
|
+
resolveCourseTitle(title, slug) {
|
|
84
|
+
var _a;
|
|
85
|
+
return (_a = this.normalizeOptionalText(title)) !== null && _a !== void 0 ? _a : slug;
|
|
86
|
+
}
|
|
87
|
+
async list(params) {
|
|
88
|
+
const page = Math.max(Number(params.page) || 1, 1);
|
|
89
|
+
const pageSize = Math.max(Number(params.pageSize) || 12, 1);
|
|
90
|
+
const skip = (page - 1) * pageSize;
|
|
91
|
+
const where = {};
|
|
92
|
+
const normalizedStatus = this.normalizeStatus(params.status);
|
|
93
|
+
const normalizedLevel = this.normalizeLevel(params.level);
|
|
94
|
+
if (normalizedStatus) {
|
|
95
|
+
where.status = normalizedStatus;
|
|
96
|
+
}
|
|
97
|
+
if (normalizedLevel) {
|
|
98
|
+
where.level = normalizedLevel;
|
|
99
|
+
}
|
|
100
|
+
if (params.search) {
|
|
101
|
+
where.OR = [
|
|
102
|
+
{ title: { contains: params.search, mode: 'insensitive' } },
|
|
103
|
+
{ slug: { contains: params.search, mode: 'insensitive' } },
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
if (params.category) {
|
|
107
|
+
where.course_category = {
|
|
108
|
+
some: { category: { slug: params.category } },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const [courses, total] = await Promise.all([
|
|
112
|
+
this.prisma.course.findMany({
|
|
113
|
+
skip,
|
|
114
|
+
take: pageSize,
|
|
115
|
+
where,
|
|
116
|
+
orderBy: { created_at: 'desc' },
|
|
117
|
+
include: {
|
|
118
|
+
course_category: {
|
|
119
|
+
include: {
|
|
120
|
+
category: {
|
|
121
|
+
select: { id: true, slug: true },
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
course_image: {
|
|
126
|
+
where: {
|
|
127
|
+
image_type: {
|
|
128
|
+
slug: { in: ['course-logo', 'course-banner'] },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
include: {
|
|
132
|
+
image_type: {
|
|
133
|
+
select: { slug: true },
|
|
134
|
+
},
|
|
135
|
+
file: {
|
|
136
|
+
select: { id: true, filename: true },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
140
|
+
},
|
|
141
|
+
_count: {
|
|
142
|
+
select: { course_enrollment: true, course_class_group: true },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
this.prisma.course.count({ where }),
|
|
147
|
+
]);
|
|
148
|
+
const extrasById = await this.getCourseExtras(courses.map((course) => course.id));
|
|
149
|
+
return {
|
|
150
|
+
total,
|
|
151
|
+
page,
|
|
152
|
+
pageSize,
|
|
153
|
+
lastPage: Math.max(1, Math.ceil(total / pageSize)),
|
|
154
|
+
data: courses.map((c) => this.mapCourse(c, undefined, extrasById.get(c.id))),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
async stats() {
|
|
158
|
+
const [total, published, totalStudents] = await Promise.all([
|
|
159
|
+
this.prisma.course.count(),
|
|
160
|
+
this.prisma.course.count({ where: { status: 'published' } }),
|
|
161
|
+
this.prisma.course_enrollment.count(),
|
|
162
|
+
]);
|
|
163
|
+
const featured = await this.getFeaturedCoursesCount();
|
|
164
|
+
return {
|
|
165
|
+
totalCourses: total,
|
|
166
|
+
publishedCourses: published,
|
|
167
|
+
featuredCourses: featured,
|
|
168
|
+
totalStudents,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async getById(id) {
|
|
172
|
+
var _a;
|
|
173
|
+
const c = await this.prisma.course.findUnique({
|
|
174
|
+
where: { id },
|
|
175
|
+
include: {
|
|
176
|
+
course_category: {
|
|
177
|
+
include: {
|
|
178
|
+
category: { select: { id: true, slug: true } },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
course_image: {
|
|
182
|
+
where: {
|
|
183
|
+
image_type: {
|
|
184
|
+
slug: { in: ['course-logo', 'course-banner'] },
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
include: {
|
|
188
|
+
image_type: {
|
|
189
|
+
select: { slug: true },
|
|
190
|
+
},
|
|
191
|
+
file: {
|
|
192
|
+
select: { id: true, filename: true },
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
196
|
+
},
|
|
197
|
+
course_instructor: {
|
|
198
|
+
include: {
|
|
199
|
+
instructor: {
|
|
200
|
+
select: {
|
|
201
|
+
id: true,
|
|
202
|
+
person: {
|
|
203
|
+
select: {
|
|
204
|
+
id: true,
|
|
205
|
+
name: true,
|
|
206
|
+
avatar_id: true,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
_count: {
|
|
214
|
+
select: {
|
|
215
|
+
course_enrollment: true,
|
|
216
|
+
course_module: true,
|
|
217
|
+
course_class_group: true,
|
|
218
|
+
certificate: true,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
if (!c)
|
|
224
|
+
return null;
|
|
225
|
+
const extrasById = await this.getCourseExtras([id]);
|
|
226
|
+
const [lessonCount, sessionCount, certificatesIssued, avgProgress, modules] = await Promise.all([
|
|
227
|
+
this.prisma.course_lesson.count({
|
|
228
|
+
where: { course_module: { course_id: id } },
|
|
229
|
+
}),
|
|
230
|
+
this.prisma.course_class_session.count({
|
|
231
|
+
where: { course_class_group: { course_id: id } },
|
|
232
|
+
}),
|
|
233
|
+
this.prisma.certificate.count({
|
|
234
|
+
where: { course_id: id },
|
|
235
|
+
}),
|
|
236
|
+
this.prisma.course_enrollment.aggregate({
|
|
237
|
+
where: { course_id: id },
|
|
238
|
+
_avg: { progress_percent: true },
|
|
239
|
+
}),
|
|
240
|
+
this.prisma.course_module.findMany({
|
|
241
|
+
where: { course_id: id },
|
|
242
|
+
orderBy: { order: 'asc' },
|
|
243
|
+
select: {
|
|
244
|
+
id: true,
|
|
245
|
+
title: true,
|
|
246
|
+
course_lesson: {
|
|
247
|
+
select: {
|
|
248
|
+
course_lesson_progress: {
|
|
249
|
+
select: { progress_percent: true },
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
}),
|
|
255
|
+
]);
|
|
256
|
+
const progressByModule = modules.map((module) => {
|
|
257
|
+
const values = module.course_lesson.flatMap((lesson) => lesson.course_lesson_progress.map((progress) => progress.progress_percent));
|
|
258
|
+
const average = values.length > 0
|
|
259
|
+
? Math.round(values.reduce((sum, value) => sum + value, 0) / values.length)
|
|
260
|
+
: 0;
|
|
261
|
+
return {
|
|
262
|
+
moduleId: module.id,
|
|
263
|
+
moduleTitle: module.title,
|
|
264
|
+
progress: average,
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
return this.mapCourse(c, {
|
|
268
|
+
lessonCount,
|
|
269
|
+
sessionCount,
|
|
270
|
+
certificatesIssued,
|
|
271
|
+
averageCompletion: (_a = avgProgress._avg.progress_percent) !== null && _a !== void 0 ? _a : 0,
|
|
272
|
+
progressByModule,
|
|
273
|
+
}, extrasById.get(id));
|
|
274
|
+
}
|
|
275
|
+
async create(dto) {
|
|
276
|
+
var _a, _b, _c, _d;
|
|
277
|
+
const { categorySlugs, logoFileId, bannerFileId, instructorIds } = dto, data = __rest(dto, ["categorySlugs", "logoFileId", "bannerFileId", "instructorIds"]);
|
|
278
|
+
const normalizedSlug = data.slug.trim();
|
|
279
|
+
const resolvedCode = this.normalizeCourseCode((_a = data.code) !== null && _a !== void 0 ? _a : normalizedSlug);
|
|
280
|
+
const resolvedTitle = this.resolveCourseTitle(data.title, normalizedSlug);
|
|
281
|
+
const categories = (categorySlugs === null || categorySlugs === void 0 ? void 0 : categorySlugs.length)
|
|
282
|
+
? await this.prisma.category.findMany({
|
|
283
|
+
where: { slug: { in: categorySlugs } },
|
|
284
|
+
select: { id: true },
|
|
285
|
+
})
|
|
286
|
+
: [];
|
|
287
|
+
// Validate instructor IDs if provided
|
|
288
|
+
let validInstructorIds = [];
|
|
289
|
+
if (instructorIds === null || instructorIds === void 0 ? void 0 : instructorIds.length) {
|
|
290
|
+
const instructors = await this.prisma.instructor.findMany({
|
|
291
|
+
where: { id: { in: instructorIds } },
|
|
292
|
+
select: { id: true },
|
|
293
|
+
});
|
|
294
|
+
const validIds = new Set(instructors.map((i) => i.id));
|
|
295
|
+
validInstructorIds = instructorIds.filter((id) => validIds.has(id));
|
|
296
|
+
}
|
|
297
|
+
const c = await this.prisma.course.create({
|
|
298
|
+
data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ slug: normalizedSlug, title: resolvedTitle }, (data.description !== undefined && {
|
|
299
|
+
description: data.description,
|
|
300
|
+
})), { level: (_b = this.normalizeLevel(data.level)) !== null && _b !== void 0 ? _b : 'beginner', status: (_c = this.normalizeStatus(data.status)) !== null && _c !== void 0 ? _c : 'draft' }), (data.requirements !== undefined && {
|
|
301
|
+
requirements: data.requirements,
|
|
302
|
+
})), (data.objectives !== undefined && {
|
|
303
|
+
objectives: data.objectives,
|
|
304
|
+
})), (data.targetAudience !== undefined && {
|
|
305
|
+
target_audience: data.targetAudience,
|
|
306
|
+
})), (data.durationHours !== undefined && {
|
|
307
|
+
duration_hours: data.durationHours,
|
|
308
|
+
})), (data.certificateWorkload !== undefined && {
|
|
309
|
+
certificate_workload: data.certificateWorkload,
|
|
310
|
+
})), (data.primaryColor !== undefined && {
|
|
311
|
+
primary_color: data.primaryColor,
|
|
312
|
+
})), (data.primaryContrastColor !== undefined && {
|
|
313
|
+
primary_contrast_color: data.primaryContrastColor,
|
|
314
|
+
})), (data.secondaryColor !== undefined && {
|
|
315
|
+
secondary_color: data.secondaryColor,
|
|
316
|
+
})), (data.secondaryContrastColor !== undefined && {
|
|
317
|
+
secondary_contrast_color: data.secondaryContrastColor,
|
|
318
|
+
})), (categories.length > 0 && {
|
|
319
|
+
course_category: {
|
|
320
|
+
create: categories.map((item) => ({ category_id: item.id })),
|
|
321
|
+
},
|
|
322
|
+
})), (validInstructorIds.length > 0 && {
|
|
323
|
+
course_instructor: {
|
|
324
|
+
create: validInstructorIds.map((instructorId) => ({
|
|
325
|
+
instructor_id: instructorId,
|
|
326
|
+
role: 'lead',
|
|
327
|
+
})),
|
|
328
|
+
},
|
|
329
|
+
})),
|
|
330
|
+
include: {
|
|
331
|
+
course_category: {
|
|
332
|
+
include: { category: { select: { id: true, slug: true } } },
|
|
333
|
+
},
|
|
334
|
+
course_image: {
|
|
335
|
+
where: {
|
|
336
|
+
image_type: {
|
|
337
|
+
slug: { in: ['course-logo', 'course-banner'] },
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
include: {
|
|
341
|
+
image_type: {
|
|
342
|
+
select: { slug: true },
|
|
343
|
+
},
|
|
344
|
+
file: {
|
|
345
|
+
select: { id: true, filename: true },
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
349
|
+
},
|
|
350
|
+
course_instructor: {
|
|
351
|
+
include: {
|
|
352
|
+
instructor: {
|
|
353
|
+
select: {
|
|
354
|
+
id: true,
|
|
355
|
+
person: {
|
|
356
|
+
select: {
|
|
357
|
+
id: true,
|
|
358
|
+
name: true,
|
|
359
|
+
avatar_id: true,
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
_count: { select: { course_enrollment: true } },
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
await this.syncCourseImages(c.id, {
|
|
370
|
+
logoFileId,
|
|
371
|
+
bannerFileId,
|
|
372
|
+
});
|
|
373
|
+
await this.persistCourseExtras(c.id, Object.assign(Object.assign(Object.assign({}, data), (resolvedCode && { code: resolvedCode })), { offeringType: (_d = this.normalizeOfferingType(data.offeringType)) !== null && _d !== void 0 ? _d : 'on_demand' }));
|
|
374
|
+
const extrasById = await this.getCourseExtras([c.id]);
|
|
375
|
+
return this.mapCourse(c, undefined, extrasById.get(c.id));
|
|
376
|
+
}
|
|
377
|
+
async update(id, dto) {
|
|
378
|
+
var _a;
|
|
379
|
+
const { categorySlugs, logoFileId, bannerFileId, instructorIds } = dto, data = __rest(dto, ["categorySlugs", "logoFileId", "bannerFileId", "instructorIds"]);
|
|
380
|
+
let existingSlug;
|
|
381
|
+
if (data.title !== undefined &&
|
|
382
|
+
this.normalizeOptionalText(data.title) === undefined &&
|
|
383
|
+
data.slug === undefined) {
|
|
384
|
+
const currentCourse = await this.prisma.course.findUnique({
|
|
385
|
+
where: { id },
|
|
386
|
+
select: { slug: true },
|
|
387
|
+
});
|
|
388
|
+
existingSlug = currentCourse === null || currentCourse === void 0 ? void 0 : currentCourse.slug;
|
|
389
|
+
}
|
|
390
|
+
const resolvedSlug = data.slug !== undefined ? data.slug.trim() : undefined;
|
|
391
|
+
const resolvedTitle = data.title !== undefined
|
|
392
|
+
? this.resolveCourseTitle(data.title, (_a = resolvedSlug !== null && resolvedSlug !== void 0 ? resolvedSlug : existingSlug) !== null && _a !== void 0 ? _a : '')
|
|
393
|
+
: undefined;
|
|
394
|
+
const categories = (categorySlugs === null || categorySlugs === void 0 ? void 0 : categorySlugs.length)
|
|
395
|
+
? await this.prisma.category.findMany({
|
|
396
|
+
where: { slug: { in: categorySlugs } },
|
|
397
|
+
select: { id: true },
|
|
398
|
+
})
|
|
399
|
+
: [];
|
|
400
|
+
// Validate instructor IDs if provided
|
|
401
|
+
let validInstructorIds;
|
|
402
|
+
if (instructorIds !== undefined) {
|
|
403
|
+
if (instructorIds.length === 0) {
|
|
404
|
+
validInstructorIds = [];
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
const instructors = await this.prisma.instructor.findMany({
|
|
408
|
+
where: { id: { in: instructorIds } },
|
|
409
|
+
select: { id: true },
|
|
410
|
+
});
|
|
411
|
+
const validIds = new Set(instructors.map((i) => i.id));
|
|
412
|
+
validInstructorIds = instructorIds.filter((id) => validIds.has(id));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (categorySlugs !== undefined) {
|
|
416
|
+
await this.prisma.course_category.deleteMany({
|
|
417
|
+
where: { course_id: id },
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
const c = await this.prisma.course.update({
|
|
421
|
+
where: { id },
|
|
422
|
+
data: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (resolvedSlug !== undefined && { slug: resolvedSlug })), (resolvedTitle !== undefined && { title: resolvedTitle })), (data.description !== undefined && { description: data.description })), (data.level !== undefined && {
|
|
423
|
+
level: this.normalizeLevel(data.level),
|
|
424
|
+
})), (data.status !== undefined && {
|
|
425
|
+
status: this.normalizeStatus(data.status),
|
|
426
|
+
})), (data.requirements !== undefined && {
|
|
427
|
+
requirements: data.requirements,
|
|
428
|
+
})), (data.objectives !== undefined && {
|
|
429
|
+
objectives: data.objectives,
|
|
430
|
+
})), (data.targetAudience !== undefined && {
|
|
431
|
+
target_audience: data.targetAudience,
|
|
432
|
+
})), (data.durationHours !== undefined && {
|
|
433
|
+
duration_hours: data.durationHours,
|
|
434
|
+
})), (data.certificateWorkload !== undefined && {
|
|
435
|
+
certificate_workload: data.certificateWorkload,
|
|
436
|
+
})), (data.primaryColor !== undefined && {
|
|
437
|
+
primary_color: data.primaryColor,
|
|
438
|
+
})), (data.primaryContrastColor !== undefined && {
|
|
439
|
+
primary_contrast_color: data.primaryContrastColor,
|
|
440
|
+
})), (data.secondaryColor !== undefined && {
|
|
441
|
+
secondary_color: data.secondaryColor,
|
|
442
|
+
})), (data.secondaryContrastColor !== undefined && {
|
|
443
|
+
secondary_contrast_color: data.secondaryContrastColor,
|
|
444
|
+
})), (categories.length > 0 && {
|
|
445
|
+
course_category: {
|
|
446
|
+
create: categories.map((item) => ({ category_id: item.id })),
|
|
447
|
+
},
|
|
448
|
+
})),
|
|
449
|
+
include: {
|
|
450
|
+
course_category: {
|
|
451
|
+
include: { category: { select: { id: true, slug: true } } },
|
|
452
|
+
},
|
|
453
|
+
course_image: {
|
|
454
|
+
where: {
|
|
455
|
+
image_type: {
|
|
456
|
+
slug: { in: ['course-logo', 'course-banner'] },
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
include: {
|
|
460
|
+
image_type: {
|
|
461
|
+
select: { slug: true },
|
|
462
|
+
},
|
|
463
|
+
file: {
|
|
464
|
+
select: { id: true, filename: true },
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
468
|
+
},
|
|
469
|
+
course_instructor: {
|
|
470
|
+
include: {
|
|
471
|
+
instructor: {
|
|
472
|
+
select: {
|
|
473
|
+
id: true,
|
|
474
|
+
person: {
|
|
475
|
+
select: {
|
|
476
|
+
id: true,
|
|
477
|
+
name: true,
|
|
478
|
+
avatar_id: true,
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
_count: { select: { course_enrollment: true } },
|
|
486
|
+
},
|
|
487
|
+
});
|
|
488
|
+
// Handle instructor relationships
|
|
489
|
+
if (validInstructorIds !== undefined) {
|
|
490
|
+
await this.prisma.course_instructor.deleteMany({
|
|
491
|
+
where: { course_id: id },
|
|
492
|
+
});
|
|
493
|
+
if (validInstructorIds.length > 0) {
|
|
494
|
+
await this.prisma.course_instructor.createMany({
|
|
495
|
+
data: validInstructorIds.map((instructorId) => ({
|
|
496
|
+
course_id: id,
|
|
497
|
+
instructor_id: instructorId,
|
|
498
|
+
role: 'lead',
|
|
499
|
+
})),
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
await this.syncCourseImages(id, {
|
|
504
|
+
logoFileId,
|
|
505
|
+
bannerFileId,
|
|
506
|
+
});
|
|
507
|
+
await this.persistCourseExtras(id, data);
|
|
508
|
+
const extrasById = await this.getCourseExtras([id]);
|
|
509
|
+
return this.mapCourse(c, undefined, extrasById.get(id));
|
|
510
|
+
}
|
|
511
|
+
async remove(id) {
|
|
512
|
+
await this.prisma.course.delete({ where: { id } });
|
|
513
|
+
return { success: true };
|
|
514
|
+
}
|
|
515
|
+
mapCourse(c, metrics, extras) {
|
|
516
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22;
|
|
517
|
+
const rawCode = (_b = (_a = extras === null || extras === void 0 ? void 0 : extras.code) !== null && _a !== void 0 ? _a : c.code) !== null && _b !== void 0 ? _b : c.slug;
|
|
518
|
+
const resolvedTitle = (_c = this.normalizeOptionalText(c.title)) !== null && _c !== void 0 ? _c : c.slug;
|
|
519
|
+
const courseImages = Array.isArray(c.course_image) ? c.course_image : [];
|
|
520
|
+
const classCount = (_e = (_d = c._count) === null || _d === void 0 ? void 0 : _d.course_class_group) !== null && _e !== void 0 ? _e : 0;
|
|
521
|
+
const offeringType = (_f = this.normalizeOfferingType(extras === null || extras === void 0 ? void 0 : extras.offering_type)) !== null && _f !== void 0 ? _f : (classCount > 0 ? 'scheduled' : 'on_demand');
|
|
522
|
+
const logoImage = courseImages.find((courseImage) => { var _a; return ((_a = courseImage.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-logo'; });
|
|
523
|
+
const bannerImage = courseImages.find((courseImage) => { var _a; return ((_a = courseImage.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-banner'; });
|
|
524
|
+
return {
|
|
525
|
+
id: c.id,
|
|
526
|
+
code: (_g = rawCode === null || rawCode === void 0 ? void 0 : rawCode.toUpperCase().replace(/[^A-Z0-9-]+/g, '-').slice(0, 32)) !== null && _g !== void 0 ? _g : '',
|
|
527
|
+
slug: c.slug,
|
|
528
|
+
title: resolvedTitle,
|
|
529
|
+
description: (_h = c.description) !== null && _h !== void 0 ? _h : '',
|
|
530
|
+
level: c.level,
|
|
531
|
+
status: c.status,
|
|
532
|
+
durationHours: (_j = c.duration_hours) !== null && _j !== void 0 ? _j : 0,
|
|
533
|
+
certificateWorkload: c.certificate_workload,
|
|
534
|
+
requirements: (_k = c.requirements) !== null && _k !== void 0 ? _k : '',
|
|
535
|
+
objectives: (_l = c.objectives) !== null && _l !== void 0 ? _l : '',
|
|
536
|
+
targetAudience: (_m = c.target_audience) !== null && _m !== void 0 ? _m : '',
|
|
537
|
+
primaryColor: (_o = c.primary_color) !== null && _o !== void 0 ? _o : null,
|
|
538
|
+
primaryContrastColor: (_p = c.primary_contrast_color) !== null && _p !== void 0 ? _p : null,
|
|
539
|
+
secondaryColor: (_q = c.secondary_color) !== null && _q !== void 0 ? _q : null,
|
|
540
|
+
secondaryContrastColor: (_r = c.secondary_contrast_color) !== null && _r !== void 0 ? _r : null,
|
|
541
|
+
logoFileId: (_u = (_t = (_s = logoImage === null || logoImage === void 0 ? void 0 : logoImage.file) === null || _s === void 0 ? void 0 : _s.id) !== null && _t !== void 0 ? _t : logoImage === null || logoImage === void 0 ? void 0 : logoImage.file_id) !== null && _u !== void 0 ? _u : null,
|
|
542
|
+
logoFilename: (_w = (_v = logoImage === null || logoImage === void 0 ? void 0 : logoImage.file) === null || _v === void 0 ? void 0 : _v.filename) !== null && _w !== void 0 ? _w : null,
|
|
543
|
+
bannerFileId: (_z = (_y = (_x = bannerImage === null || bannerImage === void 0 ? void 0 : bannerImage.file) === null || _x === void 0 ? void 0 : _x.id) !== null && _y !== void 0 ? _y : bannerImage === null || bannerImage === void 0 ? void 0 : bannerImage.file_id) !== null && _z !== void 0 ? _z : null,
|
|
544
|
+
bannerFilename: (_1 = (_0 = bannerImage === null || bannerImage === void 0 ? void 0 : bannerImage.file) === null || _0 === void 0 ? void 0 : _0.filename) !== null && _1 !== void 0 ? _1 : null,
|
|
545
|
+
categories: ((_2 = c.course_category) !== null && _2 !== void 0 ? _2 : []).map((cc) => { var _a, _b; return (_b = (_a = cc.category) === null || _a === void 0 ? void 0 : _a.slug) !== null && _b !== void 0 ? _b : ''; }),
|
|
546
|
+
categoryIds: ((_3 = c.course_category) !== null && _3 !== void 0 ? _3 : []).map((cc) => { var _a, _b; return (_b = (_a = cc.category) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : 0; }),
|
|
547
|
+
isFeatured: (_5 = (_4 = extras === null || extras === void 0 ? void 0 : extras.is_featured) !== null && _4 !== void 0 ? _4 : c.is_featured) !== null && _5 !== void 0 ? _5 : false,
|
|
548
|
+
hasCertificate: (_7 = (_6 = extras === null || extras === void 0 ? void 0 : extras.has_certificate) !== null && _6 !== void 0 ? _6 : c.has_certificate) !== null && _7 !== void 0 ? _7 : false,
|
|
549
|
+
isListed: (_9 = (_8 = extras === null || extras === void 0 ? void 0 : extras.is_listed) !== null && _8 !== void 0 ? _8 : c.is_listed) !== null && _9 !== void 0 ? _9 : false,
|
|
550
|
+
offeringType,
|
|
551
|
+
enrollmentCount: (_11 = (_10 = c._count) === null || _10 === void 0 ? void 0 : _10.course_enrollment) !== null && _11 !== void 0 ? _11 : 0,
|
|
552
|
+
moduleCount: (_13 = (_12 = c._count) === null || _12 === void 0 ? void 0 : _12.course_module) !== null && _13 !== void 0 ? _13 : 0,
|
|
553
|
+
classCount,
|
|
554
|
+
lessonCount: (_14 = metrics === null || metrics === void 0 ? void 0 : metrics.lessonCount) !== null && _14 !== void 0 ? _14 : 0,
|
|
555
|
+
sessionCount: (_15 = metrics === null || metrics === void 0 ? void 0 : metrics.sessionCount) !== null && _15 !== void 0 ? _15 : 0,
|
|
556
|
+
averageCompletion: Math.round((_16 = metrics === null || metrics === void 0 ? void 0 : metrics.averageCompletion) !== null && _16 !== void 0 ? _16 : 0),
|
|
557
|
+
certificatesIssued: (_19 = (_17 = metrics === null || metrics === void 0 ? void 0 : metrics.certificatesIssued) !== null && _17 !== void 0 ? _17 : (_18 = c._count) === null || _18 === void 0 ? void 0 : _18.certificate) !== null && _19 !== void 0 ? _19 : 0,
|
|
558
|
+
progressByModule: (_20 = metrics === null || metrics === void 0 ? void 0 : metrics.progressByModule) !== null && _20 !== void 0 ? _20 : [],
|
|
559
|
+
instructors: ((_21 = c.course_instructor) !== null && _21 !== void 0 ? _21 : []).map((ci) => {
|
|
560
|
+
var _a, _b, _c, _d, _e, _f;
|
|
561
|
+
return ({
|
|
562
|
+
id: ci.instructor_id,
|
|
563
|
+
name: (_c = (_b = (_a = ci.instructor) === null || _a === void 0 ? void 0 : _a.person) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : `Instructor #${ci.instructor_id}`,
|
|
564
|
+
avatarId: (_f = (_e = (_d = ci.instructor) === null || _d === void 0 ? void 0 : _d.person) === null || _e === void 0 ? void 0 : _e.avatar_id) !== null && _f !== void 0 ? _f : null,
|
|
565
|
+
});
|
|
566
|
+
}),
|
|
567
|
+
instructorIds: ((_22 = c.course_instructor) !== null && _22 !== void 0 ? _22 : []).map((ci) => ci.instructor_id),
|
|
568
|
+
createdAt: c.created_at,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
async getFeaturedCoursesCount() {
|
|
572
|
+
var _a, _b;
|
|
573
|
+
try {
|
|
574
|
+
const rows = (await this.prisma.$queryRawUnsafe('SELECT COUNT(*) AS value FROM course WHERE is_featured = true'));
|
|
575
|
+
return Number((_b = (_a = rows[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0);
|
|
576
|
+
}
|
|
577
|
+
catch (_c) {
|
|
578
|
+
return 0;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
async getCourseExtras(ids) {
|
|
582
|
+
const extrasById = new Map();
|
|
583
|
+
if (ids.length === 0) {
|
|
584
|
+
return extrasById;
|
|
585
|
+
}
|
|
586
|
+
const normalizedIds = ids
|
|
587
|
+
.map((id) => Number(id))
|
|
588
|
+
.filter((id) => Number.isInteger(id) && id > 0);
|
|
589
|
+
if (normalizedIds.length === 0) {
|
|
590
|
+
return extrasById;
|
|
591
|
+
}
|
|
592
|
+
try {
|
|
593
|
+
const idsCsv = normalizedIds.join(',');
|
|
594
|
+
const rows = (await this.prisma.$queryRawUnsafe(`
|
|
595
|
+
SELECT id, code, is_featured, has_certificate, is_listed, offering_type
|
|
596
|
+
FROM course
|
|
597
|
+
WHERE id IN (${idsCsv})
|
|
598
|
+
`));
|
|
599
|
+
for (const row of rows) {
|
|
600
|
+
extrasById.set(row.id, {
|
|
601
|
+
code: row.code,
|
|
602
|
+
is_featured: row.is_featured,
|
|
603
|
+
has_certificate: row.has_certificate,
|
|
604
|
+
is_listed: row.is_listed,
|
|
605
|
+
offering_type: row.offering_type,
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
catch (_a) {
|
|
610
|
+
return extrasById;
|
|
611
|
+
}
|
|
612
|
+
return extrasById;
|
|
613
|
+
}
|
|
614
|
+
async persistCourseExtras(id, data) {
|
|
615
|
+
const sets = [];
|
|
616
|
+
const params = [];
|
|
617
|
+
if (data.code !== undefined) {
|
|
618
|
+
params.push(data.code);
|
|
619
|
+
sets.push(`code = $${params.length}`);
|
|
620
|
+
}
|
|
621
|
+
if (data.isFeatured !== undefined) {
|
|
622
|
+
params.push(data.isFeatured);
|
|
623
|
+
sets.push(`is_featured = $${params.length}`);
|
|
624
|
+
}
|
|
625
|
+
if (data.hasCertificate !== undefined) {
|
|
626
|
+
params.push(data.hasCertificate);
|
|
627
|
+
sets.push(`has_certificate = $${params.length}`);
|
|
628
|
+
}
|
|
629
|
+
if (data.isListed !== undefined) {
|
|
630
|
+
params.push(data.isListed);
|
|
631
|
+
sets.push(`is_listed = $${params.length}`);
|
|
632
|
+
}
|
|
633
|
+
if (data.offeringType !== undefined) {
|
|
634
|
+
params.push(data.offeringType);
|
|
635
|
+
sets.push(`offering_type = $${params.length}`);
|
|
636
|
+
}
|
|
637
|
+
if (sets.length === 0) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
params.push(id);
|
|
641
|
+
try {
|
|
642
|
+
await this.prisma.$executeRawUnsafe(`
|
|
643
|
+
UPDATE course
|
|
644
|
+
SET ${sets.join(', ')}, updated_at = NOW()
|
|
645
|
+
WHERE id = $${params.length}
|
|
646
|
+
`, ...params);
|
|
647
|
+
}
|
|
648
|
+
catch (_a) {
|
|
649
|
+
// Columns may not exist yet in environments with outdated schema.
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
normalizeCourseCode(value) {
|
|
653
|
+
const normalized = String(value !== null && value !== void 0 ? value : '')
|
|
654
|
+
.trim()
|
|
655
|
+
.toUpperCase()
|
|
656
|
+
.replace(/[^A-Z0-9-]+/g, '-')
|
|
657
|
+
.replace(/-+/g, '-')
|
|
658
|
+
.replace(/^-+|-+$/g, '')
|
|
659
|
+
.slice(0, 32);
|
|
660
|
+
return normalized || undefined;
|
|
661
|
+
}
|
|
662
|
+
async syncCourseImages(courseId, data) {
|
|
663
|
+
if (data.logoFileId !== undefined) {
|
|
664
|
+
await this.upsertCourseImage(courseId, data.logoFileId, 'course-logo');
|
|
665
|
+
}
|
|
666
|
+
if (data.bannerFileId !== undefined) {
|
|
667
|
+
await this.upsertCourseImage(courseId, data.bannerFileId, 'course-banner');
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
async upsertCourseImage(courseId, fileId, imageTypeSlug) {
|
|
671
|
+
const normalizedFileId = Number(fileId);
|
|
672
|
+
if (!Number.isInteger(normalizedFileId) || normalizedFileId <= 0) {
|
|
673
|
+
throw new common_1.BadRequestException('Invalid file id for course image');
|
|
674
|
+
}
|
|
675
|
+
const file = await this.prisma.file.findUnique({
|
|
676
|
+
where: { id: normalizedFileId },
|
|
677
|
+
select: { id: true },
|
|
678
|
+
});
|
|
679
|
+
if (!file) {
|
|
680
|
+
throw new common_1.BadRequestException('File not found');
|
|
681
|
+
}
|
|
682
|
+
const imageType = await this.getOrCreateCourseImageType(imageTypeSlug);
|
|
683
|
+
const courseImages = await this.prisma.course_image.findMany({
|
|
684
|
+
where: {
|
|
685
|
+
course_id: courseId,
|
|
686
|
+
image_type_id: imageType.id,
|
|
687
|
+
},
|
|
688
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
689
|
+
select: { id: true, order: true },
|
|
690
|
+
});
|
|
691
|
+
if (courseImages.length > 0) {
|
|
692
|
+
const [primaryImage, ...duplicates] = courseImages;
|
|
693
|
+
await this.prisma.course_image.update({
|
|
694
|
+
where: { id: primaryImage.id },
|
|
695
|
+
data: {
|
|
696
|
+
file_id: normalizedFileId,
|
|
697
|
+
is_primary: true,
|
|
698
|
+
},
|
|
699
|
+
});
|
|
700
|
+
if (duplicates.length > 0) {
|
|
701
|
+
await this.prisma.course_image.deleteMany({
|
|
702
|
+
where: { id: { in: duplicates.map((item) => item.id) } },
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
await this.prisma.course_image.create({
|
|
708
|
+
data: {
|
|
709
|
+
course_id: courseId,
|
|
710
|
+
file_id: normalizedFileId,
|
|
711
|
+
image_type_id: imageType.id,
|
|
712
|
+
order: 0,
|
|
713
|
+
is_primary: true,
|
|
714
|
+
},
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
async getOrCreateCourseImageType(imageTypeSlug) {
|
|
718
|
+
const existing = await this.prisma.image_type.findFirst({
|
|
719
|
+
where: {
|
|
720
|
+
slug: imageTypeSlug,
|
|
721
|
+
applies_to_course: true,
|
|
722
|
+
},
|
|
723
|
+
select: { id: true },
|
|
724
|
+
});
|
|
725
|
+
if (existing) {
|
|
726
|
+
return existing;
|
|
727
|
+
}
|
|
728
|
+
return this.prisma.image_type.create({
|
|
729
|
+
data: {
|
|
730
|
+
name: imageTypeSlug === 'course-logo' ? 'Course Logo' : 'Course Banner',
|
|
731
|
+
slug: imageTypeSlug,
|
|
732
|
+
applies_to_course: true,
|
|
733
|
+
},
|
|
734
|
+
select: { id: true },
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
};
|
|
738
|
+
exports.CourseService = CourseService;
|
|
739
|
+
exports.CourseService = CourseService = __decorate([
|
|
740
|
+
(0, common_1.Injectable)(),
|
|
741
|
+
__metadata("design:paramtypes", [api_prisma_1.PrismaService])
|
|
742
|
+
], CourseService);
|
|
743
|
+
//# sourceMappingURL=course.service.js.map
|