@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,776 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ExamAttemptService = void 0;
|
|
13
|
+
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const create_exam_question_dto_1 = require("./dto/create-exam-question.dto");
|
|
16
|
+
let ExamAttemptService = class ExamAttemptService {
|
|
17
|
+
constructor(prisma) {
|
|
18
|
+
this.prisma = prisma;
|
|
19
|
+
}
|
|
20
|
+
async getAttemptState(examId, userId, explicitStudentId) {
|
|
21
|
+
const exam = await this.findExamOrThrow(examId);
|
|
22
|
+
const studentId = await this.resolveStudentId(userId, explicitStudentId);
|
|
23
|
+
let attempt = await this.findRelevantAttempt(examId, studentId);
|
|
24
|
+
if (attempt) {
|
|
25
|
+
attempt = await this.maybeFinalizeExpiredAttempt(exam, attempt);
|
|
26
|
+
}
|
|
27
|
+
return this.buildAttemptPayload(exam, studentId, attempt);
|
|
28
|
+
}
|
|
29
|
+
async startAttempt(examId, userId, ipAddress, dto) {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
const exam = await this.findExamOrThrow(examId);
|
|
32
|
+
const studentId = await this.resolveStudentId(userId, dto.studentId);
|
|
33
|
+
let activeAttempt = await this.findActiveAttempt(examId, studentId);
|
|
34
|
+
if (activeAttempt) {
|
|
35
|
+
activeAttempt = await this.maybeFinalizeExpiredAttempt(exam, activeAttempt);
|
|
36
|
+
if (activeAttempt.status === 'in_progress') {
|
|
37
|
+
return this.buildAttemptPayload(exam, studentId, activeAttempt);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const usedAttempts = await this.countAttempts(examId, studentId);
|
|
41
|
+
const attemptsAllowed = Math.max((_a = exam.attempts_allowed) !== null && _a !== void 0 ? _a : 1, 1);
|
|
42
|
+
if (usedAttempts >= attemptsAllowed) {
|
|
43
|
+
throw new common_1.BadRequestException('No attempts remaining for this exam');
|
|
44
|
+
}
|
|
45
|
+
if (((_b = exam.exam_question) !== null && _b !== void 0 ? _b : []).length === 0) {
|
|
46
|
+
throw new common_1.BadRequestException('Exam has no questions');
|
|
47
|
+
}
|
|
48
|
+
const enrollment = await this.findMatchingEnrollment(exam, studentId);
|
|
49
|
+
const created = await this.prisma.exam_attempt.create({
|
|
50
|
+
data: {
|
|
51
|
+
exam_id: exam.id,
|
|
52
|
+
student_id: studentId,
|
|
53
|
+
course_enrollment_id: (_c = enrollment === null || enrollment === void 0 ? void 0 : enrollment.id) !== null && _c !== void 0 ? _c : null,
|
|
54
|
+
attempt_number: usedAttempts + 1,
|
|
55
|
+
started_at: new Date(),
|
|
56
|
+
ip_address: ipAddress || null,
|
|
57
|
+
},
|
|
58
|
+
include: {
|
|
59
|
+
exam_answer: true,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return this.buildAttemptPayload(exam, studentId, created);
|
|
63
|
+
}
|
|
64
|
+
async saveAnswers(examId, attemptId, userId, dto) {
|
|
65
|
+
const exam = await this.findExamOrThrow(examId);
|
|
66
|
+
const studentId = await this.resolveStudentId(userId);
|
|
67
|
+
let attempt = await this.findAttemptOrThrow(examId, attemptId, studentId);
|
|
68
|
+
attempt = await this.maybeFinalizeExpiredAttempt(exam, attempt);
|
|
69
|
+
if (attempt.status !== 'in_progress') {
|
|
70
|
+
return this.buildAttemptPayload(exam, studentId, attempt);
|
|
71
|
+
}
|
|
72
|
+
await this.persistAnswers(attempt.id, exam, dto.answers);
|
|
73
|
+
const updated = await this.findAttemptOrThrow(examId, attemptId, studentId);
|
|
74
|
+
return this.buildAttemptPayload(exam, studentId, updated);
|
|
75
|
+
}
|
|
76
|
+
async submitAttempt(examId, attemptId, userId, dto) {
|
|
77
|
+
var _a, _b;
|
|
78
|
+
const exam = await this.findExamOrThrow(examId);
|
|
79
|
+
const studentId = await this.resolveStudentId(userId);
|
|
80
|
+
let attempt = await this.findAttemptOrThrow(examId, attemptId, studentId);
|
|
81
|
+
attempt = await this.maybeFinalizeExpiredAttempt(exam, attempt);
|
|
82
|
+
if (attempt.status === 'completed') {
|
|
83
|
+
return this.buildAttemptPayload(exam, studentId, attempt);
|
|
84
|
+
}
|
|
85
|
+
await this.persistAnswers(attempt.id, exam, (_a = dto.answers) !== null && _a !== void 0 ? _a : []);
|
|
86
|
+
const completed = await this.completeAttempt(exam, attempt.id, (_b = dto.force) !== null && _b !== void 0 ? _b : false);
|
|
87
|
+
return this.buildAttemptPayload(exam, studentId, completed);
|
|
88
|
+
}
|
|
89
|
+
async persistAnswers(attemptId, exam, answers) {
|
|
90
|
+
var _a, _b, _c, _d;
|
|
91
|
+
const normalizedAnswers = new Map();
|
|
92
|
+
for (const answer of answers !== null && answers !== void 0 ? answers : []) {
|
|
93
|
+
normalizedAnswers.set(answer.questionId, {
|
|
94
|
+
examOptionId: (_a = answer.examOptionId) !== null && _a !== void 0 ? _a : null,
|
|
95
|
+
answerText: ((_b = answer.answerText) === null || _b === void 0 ? void 0 : _b.trim()) || null,
|
|
96
|
+
matchingPairs: ((_c = answer.matchingPairs) !== null && _c !== void 0 ? _c : []).map((pair) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
return ({
|
|
99
|
+
leftId: String((_a = pair.leftId) !== null && _a !== void 0 ? _a : '').trim(),
|
|
100
|
+
rightId: String((_b = pair.rightId) !== null && _b !== void 0 ? _b : '').trim(),
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const questionsById = new Map(((_d = exam.exam_question) !== null && _d !== void 0 ? _d : []).map((item) => [item.question_id, item]));
|
|
106
|
+
for (const questionId of normalizedAnswers.keys()) {
|
|
107
|
+
if (!questionsById.has(questionId)) {
|
|
108
|
+
throw new common_1.BadRequestException(`Question ${questionId} does not belong to exam`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const questionIds = [...normalizedAnswers.keys()];
|
|
112
|
+
if (questionIds.length === 0) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
await this.prisma.$transaction(async (tx) => {
|
|
116
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
117
|
+
const existingAnswers = await tx.exam_answer.findMany({
|
|
118
|
+
where: {
|
|
119
|
+
exam_attempt_id: attemptId,
|
|
120
|
+
question_id: { in: questionIds },
|
|
121
|
+
},
|
|
122
|
+
select: {
|
|
123
|
+
id: true,
|
|
124
|
+
question_id: true,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
const existingByQuestionId = new Map(existingAnswers.map((item) => [item.question_id, item.id]));
|
|
128
|
+
for (const [questionId, answerValue] of normalizedAnswers.entries()) {
|
|
129
|
+
const question = questionsById.get(questionId);
|
|
130
|
+
const existingId = existingByQuestionId.get(questionId);
|
|
131
|
+
if (!question) {
|
|
132
|
+
throw new common_1.BadRequestException(`Question ${questionId} does not belong to exam`);
|
|
133
|
+
}
|
|
134
|
+
const questionType = this.resolveQuestionType((_a = question.question) === null || _a === void 0 ? void 0 : _a.question_type);
|
|
135
|
+
if (questionType === 'essay') {
|
|
136
|
+
if (!answerValue.answerText) {
|
|
137
|
+
if (existingId) {
|
|
138
|
+
await tx.exam_answer.delete({ where: { id: existingId } });
|
|
139
|
+
}
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const payload = {
|
|
143
|
+
exam_option_id: null,
|
|
144
|
+
answer_text: answerValue.answerText,
|
|
145
|
+
is_correct: null,
|
|
146
|
+
points_awarded: 0,
|
|
147
|
+
};
|
|
148
|
+
if (existingId) {
|
|
149
|
+
await tx.exam_answer.update({
|
|
150
|
+
where: { id: existingId },
|
|
151
|
+
data: payload,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
await tx.exam_answer.create({
|
|
156
|
+
data: Object.assign({ exam_attempt_id: attemptId, question_id: questionId }, payload),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (questionType === 'fill_blank') {
|
|
162
|
+
if (!answerValue.answerText) {
|
|
163
|
+
if (existingId) {
|
|
164
|
+
await tx.exam_answer.delete({ where: { id: existingId } });
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const parsedOptions = this.parseSpecialOptions((_c = (_b = question.question) === null || _b === void 0 ? void 0 : _b.exam_option) !== null && _c !== void 0 ? _c : []);
|
|
169
|
+
const expectedAnswers = this.extractFillBlankExpectedAnswers(parsedOptions.fillBlankAnswers);
|
|
170
|
+
if (expectedAnswers.length === 0) {
|
|
171
|
+
throw new common_1.BadRequestException(`Fill-blank question ${questionId} has no expected answers`);
|
|
172
|
+
}
|
|
173
|
+
const isCorrect = this.isFillBlankCorrect(answerValue.answerText, expectedAnswers);
|
|
174
|
+
const payload = {
|
|
175
|
+
exam_option_id: null,
|
|
176
|
+
answer_text: answerValue.answerText,
|
|
177
|
+
is_correct: isCorrect,
|
|
178
|
+
points_awarded: isCorrect ? (_d = question.question.points) !== null && _d !== void 0 ? _d : 0 : 0,
|
|
179
|
+
};
|
|
180
|
+
if (existingId) {
|
|
181
|
+
await tx.exam_answer.update({
|
|
182
|
+
where: { id: existingId },
|
|
183
|
+
data: payload,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
await tx.exam_answer.create({
|
|
188
|
+
data: Object.assign({ exam_attempt_id: attemptId, question_id: questionId }, payload),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (questionType === 'matching') {
|
|
194
|
+
const parsedOptions = this.parseSpecialOptions((_f = (_e = question.question) === null || _e === void 0 ? void 0 : _e.exam_option) !== null && _f !== void 0 ? _f : []);
|
|
195
|
+
const expectedPairs = this.extractMatchingPairs(parsedOptions.matchingPairs);
|
|
196
|
+
if (expectedPairs.length < 2) {
|
|
197
|
+
throw new common_1.BadRequestException(`Matching question ${questionId} has no valid pairs`);
|
|
198
|
+
}
|
|
199
|
+
const sanitizedPairs = answerValue.matchingPairs.filter((pair) => pair.leftId.length > 0 && pair.rightId.length > 0);
|
|
200
|
+
if (sanitizedPairs.length === 0) {
|
|
201
|
+
if (existingId) {
|
|
202
|
+
await tx.exam_answer.delete({ where: { id: existingId } });
|
|
203
|
+
}
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const isCorrect = this.isMatchingCorrect(sanitizedPairs, expectedPairs);
|
|
207
|
+
const payload = {
|
|
208
|
+
exam_option_id: null,
|
|
209
|
+
answer_text: JSON.stringify({ matchingPairs: sanitizedPairs }),
|
|
210
|
+
is_correct: isCorrect,
|
|
211
|
+
points_awarded: isCorrect ? (_g = question.question.points) !== null && _g !== void 0 ? _g : 0 : 0,
|
|
212
|
+
};
|
|
213
|
+
if (existingId) {
|
|
214
|
+
await tx.exam_answer.update({
|
|
215
|
+
where: { id: existingId },
|
|
216
|
+
data: payload,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
await tx.exam_answer.create({
|
|
221
|
+
data: Object.assign({ exam_attempt_id: attemptId, question_id: questionId }, payload),
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (!answerValue.examOptionId) {
|
|
227
|
+
if (existingId) {
|
|
228
|
+
await tx.exam_answer.delete({ where: { id: existingId } });
|
|
229
|
+
}
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
const option = ((_j = (_h = question === null || question === void 0 ? void 0 : question.question) === null || _h === void 0 ? void 0 : _h.exam_option) !== null && _j !== void 0 ? _j : []).find((item) => item.id === answerValue.examOptionId);
|
|
233
|
+
if (!option) {
|
|
234
|
+
throw new common_1.BadRequestException(`Option ${answerValue.examOptionId} does not belong to question ${questionId}`);
|
|
235
|
+
}
|
|
236
|
+
const payload = {
|
|
237
|
+
exam_option_id: option.id,
|
|
238
|
+
answer_text: null,
|
|
239
|
+
is_correct: Boolean(option.is_correct),
|
|
240
|
+
points_awarded: option.is_correct ? (_k = question.question.points) !== null && _k !== void 0 ? _k : 0 : 0,
|
|
241
|
+
};
|
|
242
|
+
if (existingId) {
|
|
243
|
+
await tx.exam_answer.update({
|
|
244
|
+
where: { id: existingId },
|
|
245
|
+
data: payload,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
await tx.exam_answer.create({
|
|
250
|
+
data: Object.assign({ exam_attempt_id: attemptId, question_id: questionId }, payload),
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async completeAttempt(exam, attemptId, force) {
|
|
257
|
+
var _a, _b;
|
|
258
|
+
const currentAttempt = await this.prisma.exam_attempt.findUnique({
|
|
259
|
+
where: { id: attemptId },
|
|
260
|
+
include: {
|
|
261
|
+
exam_answer: true,
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
if (!currentAttempt) {
|
|
265
|
+
throw new common_1.NotFoundException('Attempt not found');
|
|
266
|
+
}
|
|
267
|
+
if (currentAttempt.status === 'completed') {
|
|
268
|
+
return currentAttempt;
|
|
269
|
+
}
|
|
270
|
+
const maxPoints = this.getExamMaxPoints(exam);
|
|
271
|
+
const answeredCount = currentAttempt.exam_answer.length;
|
|
272
|
+
const questionCount = ((_a = exam.exam_question) !== null && _a !== void 0 ? _a : []).length;
|
|
273
|
+
if (!force &&
|
|
274
|
+
exam.require_all_questions_answered_to_finish &&
|
|
275
|
+
answeredCount < questionCount) {
|
|
276
|
+
throw new common_1.BadRequestException('All questions must be answered before finishing');
|
|
277
|
+
}
|
|
278
|
+
const totalPoints = currentAttempt.exam_answer.reduce((sum, answer) => { var _a; return sum + ((_a = answer.points_awarded) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
279
|
+
const maxScore = Math.max((_b = exam.max_score) !== null && _b !== void 0 ? _b : 100, 1);
|
|
280
|
+
const scaledScore = maxPoints > 0 ? Math.round((totalPoints / maxPoints) * maxScore) : 0;
|
|
281
|
+
return this.prisma.exam_attempt.update({
|
|
282
|
+
where: { id: attemptId },
|
|
283
|
+
data: {
|
|
284
|
+
status: 'completed',
|
|
285
|
+
finished_at: new Date(),
|
|
286
|
+
duration_seconds: Math.max(0, Math.floor((Date.now() - currentAttempt.started_at.getTime()) / 1000)),
|
|
287
|
+
score: scaledScore,
|
|
288
|
+
},
|
|
289
|
+
include: {
|
|
290
|
+
exam_answer: true,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async buildAttemptPayload(exam, studentId, attempt) {
|
|
295
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
296
|
+
const attemptsAllowed = Math.max((_a = exam.attempts_allowed) !== null && _a !== void 0 ? _a : 1, 1);
|
|
297
|
+
const attemptsUsed = await this.countAttempts(exam.id, studentId);
|
|
298
|
+
const maxPoints = this.getExamMaxPoints(exam);
|
|
299
|
+
const questions = this.mapQuestions(exam, (_b = attempt === null || attempt === void 0 ? void 0 : attempt.id) !== null && _b !== void 0 ? _b : exam.id);
|
|
300
|
+
return {
|
|
301
|
+
exam: {
|
|
302
|
+
id: exam.id,
|
|
303
|
+
title: exam.title,
|
|
304
|
+
description: exam.description,
|
|
305
|
+
instructions: exam.instructions,
|
|
306
|
+
questionCount: questions.length,
|
|
307
|
+
maxPoints,
|
|
308
|
+
timeLimitMinutes: exam.time_limit_minutes,
|
|
309
|
+
passingScore: this.scoreToTen((_c = exam.min_score) !== null && _c !== void 0 ? _c : 0),
|
|
310
|
+
passingPercent: this.toPercent((_d = exam.min_score) !== null && _d !== void 0 ? _d : 0, (_e = exam.max_score) !== null && _e !== void 0 ? _e : 100),
|
|
311
|
+
requireAllQuestionsAnsweredToFinish: Boolean(exam.require_all_questions_answered_to_finish),
|
|
312
|
+
showResult: Boolean((_f = exam.show_result) !== null && _f !== void 0 ? _f : true),
|
|
313
|
+
},
|
|
314
|
+
attempts: {
|
|
315
|
+
allowed: attemptsAllowed,
|
|
316
|
+
used: attemptsUsed,
|
|
317
|
+
remaining: Math.max(attemptsAllowed - attemptsUsed, 0),
|
|
318
|
+
canStart: attemptsUsed < attemptsAllowed,
|
|
319
|
+
},
|
|
320
|
+
questions,
|
|
321
|
+
attempt: attempt
|
|
322
|
+
? {
|
|
323
|
+
id: attempt.id,
|
|
324
|
+
attemptNumber: attempt.attempt_number,
|
|
325
|
+
status: attempt.status,
|
|
326
|
+
startedAt: attempt.started_at,
|
|
327
|
+
finishedAt: attempt.finished_at,
|
|
328
|
+
timeRemainingSeconds: this.getRemainingSeconds(exam, attempt),
|
|
329
|
+
answeredCount: attempt.exam_answer.length,
|
|
330
|
+
answers: ((_g = attempt.exam_answer) !== null && _g !== void 0 ? _g : []).map((answer) => ({
|
|
331
|
+
questionId: answer.question_id,
|
|
332
|
+
examOptionId: answer.exam_option_id,
|
|
333
|
+
answerText: answer.answer_text,
|
|
334
|
+
matchingPairs: this.extractMatchingPairsFromAnswerText(answer.answer_text),
|
|
335
|
+
})),
|
|
336
|
+
result: attempt.status === 'completed'
|
|
337
|
+
? this.mapAttemptResult(exam, attempt)
|
|
338
|
+
: null,
|
|
339
|
+
}
|
|
340
|
+
: null,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
mapAttemptResult(exam, attempt) {
|
|
344
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
345
|
+
const maxPoints = this.getExamMaxPoints(exam);
|
|
346
|
+
const maxScore = Math.max((_a = exam.max_score) !== null && _a !== void 0 ? _a : 100, 1);
|
|
347
|
+
const score = (_b = attempt.score) !== null && _b !== void 0 ? _b : 0;
|
|
348
|
+
const answersByQuestion = new Map(((_c = attempt.exam_answer) !== null && _c !== void 0 ? _c : []).map((answer) => [answer.question_id, answer]));
|
|
349
|
+
const hasPendingReview = ((_d = exam.exam_question) !== null && _d !== void 0 ? _d : []).some((item) => {
|
|
350
|
+
var _a;
|
|
351
|
+
const answer = answersByQuestion.get(item.question_id);
|
|
352
|
+
return this.requiresManualReview((_a = item.question) === null || _a === void 0 ? void 0 : _a.question_type) && Boolean(answer);
|
|
353
|
+
});
|
|
354
|
+
return {
|
|
355
|
+
totalPoints: ((_e = attempt.exam_answer) !== null && _e !== void 0 ? _e : []).reduce((sum, answer) => { var _a; return sum + ((_a = answer.points_awarded) !== null && _a !== void 0 ? _a : 0); }, 0),
|
|
356
|
+
maxPoints,
|
|
357
|
+
score,
|
|
358
|
+
scoreDisplay: this.scoreToTen(score),
|
|
359
|
+
percent: this.toPercent(score, maxScore),
|
|
360
|
+
passed: hasPendingReview ? null : score >= ((_f = exam.min_score) !== null && _f !== void 0 ? _f : 0),
|
|
361
|
+
hasPendingReview,
|
|
362
|
+
pendingReviewCount: ((_g = exam.exam_question) !== null && _g !== void 0 ? _g : []).filter((item) => {
|
|
363
|
+
var _a;
|
|
364
|
+
const answer = answersByQuestion.get(item.question_id);
|
|
365
|
+
return this.requiresManualReview((_a = item.question) === null || _a === void 0 ? void 0 : _a.question_type) && Boolean(answer);
|
|
366
|
+
}).length,
|
|
367
|
+
answersSummary: ((_h = exam.exam_question) !== null && _h !== void 0 ? _h : []).map((item) => {
|
|
368
|
+
var _a, _b;
|
|
369
|
+
const answer = answersByQuestion.get(item.question_id);
|
|
370
|
+
return {
|
|
371
|
+
questionId: item.question_id,
|
|
372
|
+
hasAnswer: Boolean(answer),
|
|
373
|
+
isCorrect: typeof (answer === null || answer === void 0 ? void 0 : answer.is_correct) === 'boolean' ? Boolean(answer.is_correct) : null,
|
|
374
|
+
pointsAwarded: (_a = answer === null || answer === void 0 ? void 0 : answer.points_awarded) !== null && _a !== void 0 ? _a : 0,
|
|
375
|
+
requiresManualReview: this.requiresManualReview((_b = item.question) === null || _b === void 0 ? void 0 : _b.question_type),
|
|
376
|
+
};
|
|
377
|
+
}),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
mapQuestions(exam, seedBase) {
|
|
381
|
+
var _a;
|
|
382
|
+
const orderedQuestions = this.sortWithSeed(exam.shuffle_questions, ((_a = exam.exam_question) !== null && _a !== void 0 ? _a : []), (item) => item.question_id, `${seedBase}:questions`);
|
|
383
|
+
return orderedQuestions.map((item, index) => {
|
|
384
|
+
var _a, _b, _c, _d, _e;
|
|
385
|
+
const questionType = this.resolveQuestionType((_a = item.question) === null || _a === void 0 ? void 0 : _a.question_type);
|
|
386
|
+
const parsedOptions = this.parseSpecialOptions((_c = (_b = item.question) === null || _b === void 0 ? void 0 : _b.exam_option) !== null && _c !== void 0 ? _c : []);
|
|
387
|
+
const objectiveOptions = ((_e = (_d = item.question) === null || _d === void 0 ? void 0 : _d.exam_option) !== null && _e !== void 0 ? _e : []).filter((option) => !this.isJsonString(option.option_text));
|
|
388
|
+
const orderedOptions = this.sortWithSeed(exam.shuffle_options, objectiveOptions, (option) => option.id, `${seedBase}:question:${item.question_id}:options`);
|
|
389
|
+
return {
|
|
390
|
+
id: item.question_id,
|
|
391
|
+
order: index,
|
|
392
|
+
questionType,
|
|
393
|
+
statement: item.question.statement,
|
|
394
|
+
points: item.question.points,
|
|
395
|
+
fillBlankAnswers: parsedOptions.fillBlankAnswers,
|
|
396
|
+
matchingPairs: parsedOptions.matchingPairs,
|
|
397
|
+
matchingOptions: questionType === 'matching'
|
|
398
|
+
? this.sortWithSeed(true, parsedOptions.matchingPairs.map((pair) => ({
|
|
399
|
+
id: pair.id,
|
|
400
|
+
text: pair.rightText,
|
|
401
|
+
})), (option) => this.hash(option.id), `${seedBase}:question:${item.question_id}:matching-options`)
|
|
402
|
+
: [],
|
|
403
|
+
alternatives: questionType === 'multiple_choice' || questionType === 'true_false'
|
|
404
|
+
? orderedOptions.map((option) => ({
|
|
405
|
+
id: option.id,
|
|
406
|
+
text: option.option_text,
|
|
407
|
+
}))
|
|
408
|
+
: [],
|
|
409
|
+
};
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
sortWithSeed(enabled, items, getId, seed) {
|
|
413
|
+
const list = [...items];
|
|
414
|
+
if (!enabled) {
|
|
415
|
+
return list;
|
|
416
|
+
}
|
|
417
|
+
return list.sort((left, right) => {
|
|
418
|
+
const leftHash = this.hash(`${seed}:${getId(left)}`);
|
|
419
|
+
const rightHash = this.hash(`${seed}:${getId(right)}`);
|
|
420
|
+
if (leftHash === rightHash) {
|
|
421
|
+
return getId(left) - getId(right);
|
|
422
|
+
}
|
|
423
|
+
return leftHash - rightHash;
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
hash(value) {
|
|
427
|
+
let hash = 0;
|
|
428
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
429
|
+
hash = (hash * 31 + value.charCodeAt(index)) >>> 0;
|
|
430
|
+
}
|
|
431
|
+
return hash;
|
|
432
|
+
}
|
|
433
|
+
async maybeFinalizeExpiredAttempt(exam, attempt) {
|
|
434
|
+
const remainingSeconds = this.getRemainingSeconds(exam, attempt);
|
|
435
|
+
if (attempt.status !== 'in_progress' || remainingSeconds === null || remainingSeconds > 0) {
|
|
436
|
+
return attempt;
|
|
437
|
+
}
|
|
438
|
+
return this.completeAttempt(exam, attempt.id, true);
|
|
439
|
+
}
|
|
440
|
+
getRemainingSeconds(exam, attempt) {
|
|
441
|
+
if (!exam.time_limit_minutes) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
const endsAt = attempt.started_at.getTime() + exam.time_limit_minutes * 60 * 1000;
|
|
445
|
+
return Math.max(0, Math.floor((endsAt - Date.now()) / 1000));
|
|
446
|
+
}
|
|
447
|
+
getExamMaxPoints(exam) {
|
|
448
|
+
var _a;
|
|
449
|
+
return ((_a = exam.exam_question) !== null && _a !== void 0 ? _a : []).reduce((sum, item) => { var _a, _b; return sum + ((_b = (_a = item.question) === null || _a === void 0 ? void 0 : _a.points) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
450
|
+
}
|
|
451
|
+
isObjectiveQuestion(questionType) {
|
|
452
|
+
return create_exam_question_dto_1.OBJECTIVE_EXAM_QUESTION_TYPES.includes(this.resolveQuestionType(questionType));
|
|
453
|
+
}
|
|
454
|
+
requiresManualReview(questionType) {
|
|
455
|
+
return this.resolveQuestionType(questionType) === 'essay';
|
|
456
|
+
}
|
|
457
|
+
resolveQuestionType(questionType) {
|
|
458
|
+
var _a;
|
|
459
|
+
return (_a = questionType) !== null && _a !== void 0 ? _a : 'multiple_choice';
|
|
460
|
+
}
|
|
461
|
+
isJsonString(value) {
|
|
462
|
+
try {
|
|
463
|
+
const parsed = JSON.parse(value);
|
|
464
|
+
return typeof parsed === 'object' && parsed !== null;
|
|
465
|
+
}
|
|
466
|
+
catch (_a) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
parseSpecialOptions(options) {
|
|
471
|
+
const fillBlankAnswers = [];
|
|
472
|
+
const matchingPairs = [];
|
|
473
|
+
for (const option of options) {
|
|
474
|
+
try {
|
|
475
|
+
const parsed = JSON.parse(option.option_text);
|
|
476
|
+
if ((parsed === null || parsed === void 0 ? void 0 : parsed.kind) === 'fill_blank' && typeof parsed.answer === 'string') {
|
|
477
|
+
fillBlankAnswers.push({
|
|
478
|
+
answer: parsed.answer,
|
|
479
|
+
alternatives: Array.isArray(parsed.alternatives)
|
|
480
|
+
? parsed.alternatives
|
|
481
|
+
: [],
|
|
482
|
+
});
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if ((parsed === null || parsed === void 0 ? void 0 : parsed.kind) === 'matching' &&
|
|
486
|
+
typeof parsed.id === 'string' &&
|
|
487
|
+
typeof parsed.leftText === 'string' &&
|
|
488
|
+
typeof parsed.rightText === 'string') {
|
|
489
|
+
matchingPairs.push({
|
|
490
|
+
id: parsed.id,
|
|
491
|
+
leftText: parsed.leftText,
|
|
492
|
+
rightText: parsed.rightText,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
catch (_a) {
|
|
497
|
+
// Ignore objective options
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
fillBlankAnswers,
|
|
502
|
+
matchingPairs,
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
extractFillBlankExpectedAnswers(rawValue) {
|
|
506
|
+
if (!Array.isArray(rawValue)) {
|
|
507
|
+
return [];
|
|
508
|
+
}
|
|
509
|
+
return rawValue.flatMap((item) => {
|
|
510
|
+
const primary = typeof (item === null || item === void 0 ? void 0 : item.answer) === 'string' ? [item.answer] : [];
|
|
511
|
+
const alternatives = Array.isArray(item === null || item === void 0 ? void 0 : item.alternatives)
|
|
512
|
+
? item.alternatives.filter((alternative) => typeof alternative === 'string')
|
|
513
|
+
: [];
|
|
514
|
+
return [...primary, ...alternatives]
|
|
515
|
+
.map((value) => value.trim())
|
|
516
|
+
.filter((value) => value.length > 0);
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
isFillBlankCorrect(answerText, expectedAnswers) {
|
|
520
|
+
const normalizedAnswer = answerText.trim().toLowerCase();
|
|
521
|
+
return expectedAnswers.some((expected) => expected.trim().toLowerCase() === normalizedAnswer);
|
|
522
|
+
}
|
|
523
|
+
extractMatchingPairs(rawValue) {
|
|
524
|
+
if (!Array.isArray(rawValue)) {
|
|
525
|
+
return [];
|
|
526
|
+
}
|
|
527
|
+
return rawValue
|
|
528
|
+
.map((pair) => {
|
|
529
|
+
var _a, _b, _c;
|
|
530
|
+
return ({
|
|
531
|
+
id: String((_a = pair === null || pair === void 0 ? void 0 : pair.id) !== null && _a !== void 0 ? _a : '').trim(),
|
|
532
|
+
leftText: String((_b = pair === null || pair === void 0 ? void 0 : pair.leftText) !== null && _b !== void 0 ? _b : '').trim(),
|
|
533
|
+
rightText: String((_c = pair === null || pair === void 0 ? void 0 : pair.rightText) !== null && _c !== void 0 ? _c : '').trim(),
|
|
534
|
+
});
|
|
535
|
+
})
|
|
536
|
+
.filter((pair) => pair.id.length > 0 &&
|
|
537
|
+
pair.leftText.length > 0 &&
|
|
538
|
+
pair.rightText.length > 0);
|
|
539
|
+
}
|
|
540
|
+
isMatchingCorrect(submittedPairs, expectedPairs) {
|
|
541
|
+
if (submittedPairs.length !== expectedPairs.length) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
const expectedMap = new Map(expectedPairs.map((pair) => [pair.id, pair.id]));
|
|
545
|
+
const submittedMap = new Map(submittedPairs.map((pair) => [pair.leftId, pair.rightId]));
|
|
546
|
+
if (submittedMap.size !== expectedMap.size) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
for (const [leftId, expectedRightId] of expectedMap.entries()) {
|
|
550
|
+
if (submittedMap.get(leftId) !== expectedRightId) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return true;
|
|
555
|
+
}
|
|
556
|
+
extractMatchingPairsFromAnswerText(answerText) {
|
|
557
|
+
if (!answerText) {
|
|
558
|
+
return [];
|
|
559
|
+
}
|
|
560
|
+
try {
|
|
561
|
+
const parsed = JSON.parse(answerText);
|
|
562
|
+
if (!Array.isArray(parsed === null || parsed === void 0 ? void 0 : parsed.matchingPairs)) {
|
|
563
|
+
return [];
|
|
564
|
+
}
|
|
565
|
+
return parsed.matchingPairs
|
|
566
|
+
.map((pair) => {
|
|
567
|
+
var _a, _b;
|
|
568
|
+
return ({
|
|
569
|
+
leftId: String((_a = pair === null || pair === void 0 ? void 0 : pair.leftId) !== null && _a !== void 0 ? _a : '').trim(),
|
|
570
|
+
rightId: String((_b = pair === null || pair === void 0 ? void 0 : pair.rightId) !== null && _b !== void 0 ? _b : '').trim(),
|
|
571
|
+
});
|
|
572
|
+
})
|
|
573
|
+
.filter((pair) => pair.leftId.length > 0 && pair.rightId.length > 0);
|
|
574
|
+
}
|
|
575
|
+
catch (_a) {
|
|
576
|
+
return [];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
async findExamOrThrow(examId) {
|
|
580
|
+
const exam = await this.prisma.exam.findUnique({
|
|
581
|
+
where: { id: examId },
|
|
582
|
+
include: {
|
|
583
|
+
exam_question: {
|
|
584
|
+
orderBy: { order: 'asc' },
|
|
585
|
+
include: {
|
|
586
|
+
question: {
|
|
587
|
+
include: {
|
|
588
|
+
exam_option: {
|
|
589
|
+
orderBy: { position: 'asc' },
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
});
|
|
597
|
+
if (!exam) {
|
|
598
|
+
throw new common_1.NotFoundException('Exam not found');
|
|
599
|
+
}
|
|
600
|
+
return exam;
|
|
601
|
+
}
|
|
602
|
+
async findRelevantAttempt(examId, studentId) {
|
|
603
|
+
const activeAttempt = await this.findActiveAttempt(examId, studentId);
|
|
604
|
+
if (activeAttempt) {
|
|
605
|
+
return activeAttempt;
|
|
606
|
+
}
|
|
607
|
+
return this.prisma.exam_attempt.findFirst({
|
|
608
|
+
where: {
|
|
609
|
+
exam_id: examId,
|
|
610
|
+
student_id: studentId,
|
|
611
|
+
},
|
|
612
|
+
orderBy: { created_at: 'desc' },
|
|
613
|
+
include: {
|
|
614
|
+
exam_answer: true,
|
|
615
|
+
},
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
findActiveAttempt(examId, studentId) {
|
|
619
|
+
return this.prisma.exam_attempt.findFirst({
|
|
620
|
+
where: {
|
|
621
|
+
exam_id: examId,
|
|
622
|
+
student_id: studentId,
|
|
623
|
+
status: 'in_progress',
|
|
624
|
+
},
|
|
625
|
+
orderBy: { created_at: 'desc' },
|
|
626
|
+
include: {
|
|
627
|
+
exam_answer: true,
|
|
628
|
+
},
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
async findAttemptOrThrow(examId, attemptId, studentId) {
|
|
632
|
+
const attempt = await this.prisma.exam_attempt.findFirst({
|
|
633
|
+
where: {
|
|
634
|
+
id: attemptId,
|
|
635
|
+
exam_id: examId,
|
|
636
|
+
student_id: studentId,
|
|
637
|
+
},
|
|
638
|
+
include: {
|
|
639
|
+
exam_answer: true,
|
|
640
|
+
},
|
|
641
|
+
});
|
|
642
|
+
if (!attempt) {
|
|
643
|
+
throw new common_1.NotFoundException('Attempt not found');
|
|
644
|
+
}
|
|
645
|
+
return attempt;
|
|
646
|
+
}
|
|
647
|
+
countAttempts(examId, studentId) {
|
|
648
|
+
return this.prisma.exam_attempt.count({
|
|
649
|
+
where: {
|
|
650
|
+
exam_id: examId,
|
|
651
|
+
student_id: studentId,
|
|
652
|
+
status: {
|
|
653
|
+
not: 'voided',
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
async findMatchingEnrollment(exam, studentId) {
|
|
659
|
+
if (exam.course_class_group_id) {
|
|
660
|
+
return this.prisma.course_enrollment.findFirst({
|
|
661
|
+
where: {
|
|
662
|
+
person_id: studentId,
|
|
663
|
+
course_class_group_id: exam.course_class_group_id,
|
|
664
|
+
},
|
|
665
|
+
orderBy: { updated_at: 'desc' },
|
|
666
|
+
select: { id: true },
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
if (exam.course_id) {
|
|
670
|
+
return this.prisma.course_enrollment.findFirst({
|
|
671
|
+
where: {
|
|
672
|
+
person_id: studentId,
|
|
673
|
+
course_id: exam.course_id,
|
|
674
|
+
},
|
|
675
|
+
orderBy: { updated_at: 'desc' },
|
|
676
|
+
select: { id: true },
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
async resolveStudentId(userId, explicitStudentId) {
|
|
682
|
+
var _a, _b, _c;
|
|
683
|
+
if (explicitStudentId) {
|
|
684
|
+
const person = await this.prisma.person.findUnique({
|
|
685
|
+
where: { id: explicitStudentId },
|
|
686
|
+
select: { id: true },
|
|
687
|
+
});
|
|
688
|
+
if (!person) {
|
|
689
|
+
throw new common_1.NotFoundException('Student not found');
|
|
690
|
+
}
|
|
691
|
+
return person.id;
|
|
692
|
+
}
|
|
693
|
+
const user = await this.prisma.user.findUnique({
|
|
694
|
+
where: { id: userId },
|
|
695
|
+
select: {
|
|
696
|
+
id: true,
|
|
697
|
+
name: true,
|
|
698
|
+
user_identifier: {
|
|
699
|
+
where: {
|
|
700
|
+
type: 'email',
|
|
701
|
+
enabled: true,
|
|
702
|
+
},
|
|
703
|
+
select: {
|
|
704
|
+
value: true,
|
|
705
|
+
},
|
|
706
|
+
take: 1,
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
});
|
|
710
|
+
if (!user) {
|
|
711
|
+
throw new common_1.NotFoundException('Authenticated user not found');
|
|
712
|
+
}
|
|
713
|
+
const userEmail = (_c = (_b = (_a = user.user_identifier) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.trim().toLowerCase();
|
|
714
|
+
if (userEmail) {
|
|
715
|
+
const matchingPersons = await this.prisma.person.findMany({
|
|
716
|
+
where: {
|
|
717
|
+
contact: {
|
|
718
|
+
some: {
|
|
719
|
+
value: { equals: userEmail, mode: 'insensitive' },
|
|
720
|
+
contact_type: {
|
|
721
|
+
code: 'email',
|
|
722
|
+
},
|
|
723
|
+
},
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
select: { id: true },
|
|
727
|
+
take: 2,
|
|
728
|
+
});
|
|
729
|
+
if (matchingPersons.length === 1) {
|
|
730
|
+
return matchingPersons[0].id;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
const sameIdPerson = await this.prisma.person.findUnique({
|
|
734
|
+
where: { id: userId },
|
|
735
|
+
select: { id: true },
|
|
736
|
+
});
|
|
737
|
+
if (sameIdPerson) {
|
|
738
|
+
return sameIdPerson.id;
|
|
739
|
+
}
|
|
740
|
+
const emailType = await this.prisma.contact_type.findFirst({
|
|
741
|
+
where: { code: 'email' },
|
|
742
|
+
select: { id: true },
|
|
743
|
+
});
|
|
744
|
+
const createdPerson = await this.prisma.person.create({
|
|
745
|
+
data: Object.assign({ name: user.name, type: 'individual', status: 'active' }, (userEmail && emailType
|
|
746
|
+
? {
|
|
747
|
+
contact: {
|
|
748
|
+
create: {
|
|
749
|
+
contact_type_id: emailType.id,
|
|
750
|
+
value: userEmail,
|
|
751
|
+
is_primary: true,
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
}
|
|
755
|
+
: {})),
|
|
756
|
+
select: { id: true },
|
|
757
|
+
});
|
|
758
|
+
return createdPerson.id;
|
|
759
|
+
}
|
|
760
|
+
toPercent(value, max) {
|
|
761
|
+
if (!max)
|
|
762
|
+
return 0;
|
|
763
|
+
return Math.round((value / max) * 100);
|
|
764
|
+
}
|
|
765
|
+
scoreToTen(score) {
|
|
766
|
+
if (!score)
|
|
767
|
+
return 0;
|
|
768
|
+
return score > 10 ? Number((score / 10).toFixed(1)) : Number(score.toFixed(1));
|
|
769
|
+
}
|
|
770
|
+
};
|
|
771
|
+
exports.ExamAttemptService = ExamAttemptService;
|
|
772
|
+
exports.ExamAttemptService = ExamAttemptService = __decorate([
|
|
773
|
+
(0, common_1.Injectable)(),
|
|
774
|
+
__metadata("design:paramtypes", [api_prisma_1.PrismaService])
|
|
775
|
+
], ExamAttemptService);
|
|
776
|
+
//# sourceMappingURL=exam-attempt.service.js.map
|