@hed-hog/lms 0.0.361 → 0.0.364
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/dist/bitcode-wallet/bitcode-wallet.service.d.ts +65 -0
- package/dist/bitcode-wallet/bitcode-wallet.service.d.ts.map +1 -1
- package/dist/bitcode-wallet/bitcode-wallet.service.js +72 -0
- package/dist/bitcode-wallet/bitcode-wallet.service.js.map +1 -1
- package/dist/bitcode-wallet/dto/create-current-bitcode-wallet-transaction.dto.d.ts +8 -0
- package/dist/bitcode-wallet/dto/create-current-bitcode-wallet-transaction.dto.d.ts.map +1 -0
- package/dist/bitcode-wallet/dto/create-current-bitcode-wallet-transaction.dto.js +40 -0
- package/dist/bitcode-wallet/dto/create-current-bitcode-wallet-transaction.dto.js.map +1 -0
- package/dist/class-group/class-group.controller.d.ts +16 -16
- package/dist/class-group/class-group.service.d.ts +12 -12
- package/dist/course/course-audio-transcription.service.d.ts +3 -2
- package/dist/course/course-audio-transcription.service.d.ts.map +1 -1
- package/dist/course/course-audio-transcription.service.js +49 -8
- package/dist/course/course-audio-transcription.service.js.map +1 -1
- package/dist/course/course-lesson.controller.d.ts +4 -0
- package/dist/course/course-lesson.controller.d.ts.map +1 -1
- package/dist/course/course-lesson.controller.js +10 -0
- package/dist/course/course-lesson.controller.js.map +1 -1
- package/dist/course/course-structure.controller.d.ts +11 -4
- package/dist/course/course-structure.controller.d.ts.map +1 -1
- package/dist/course/course-structure.controller.js +14 -0
- package/dist/course/course-structure.controller.js.map +1 -1
- package/dist/course/course-structure.service.d.ts +15 -1
- package/dist/course/course-structure.service.d.ts.map +1 -1
- package/dist/course/course-structure.service.js +139 -4
- package/dist/course/course-structure.service.js.map +1 -1
- package/dist/course/course-video-conversion.service.d.ts +8 -0
- package/dist/course/course-video-conversion.service.d.ts.map +1 -1
- package/dist/course/course-video-conversion.service.js +87 -51
- package/dist/course/course-video-conversion.service.js.map +1 -1
- package/dist/course/course.controller.d.ts +73 -1
- package/dist/course/course.controller.d.ts.map +1 -1
- package/dist/course/course.controller.js +27 -3
- package/dist/course/course.controller.js.map +1 -1
- package/dist/course/course.module.d.ts.map +1 -1
- package/dist/course/course.module.js +2 -0
- package/dist/course/course.module.js.map +1 -1
- package/dist/course/course.service.d.ts +108 -4
- package/dist/course/course.service.d.ts.map +1 -1
- package/dist/course/course.service.js +631 -30
- package/dist/course/course.service.js.map +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.d.ts +6 -0
- package/dist/course/dto/cleanup-course-storage.dto.d.ts.map +1 -0
- package/dist/course/dto/cleanup-course-storage.dto.js +33 -0
- package/dist/course/dto/cleanup-course-storage.dto.js.map +1 -0
- package/dist/course/dto/cleanup-upload-history.dto.d.ts +9 -0
- package/dist/course/dto/cleanup-upload-history.dto.d.ts.map +1 -0
- package/dist/course/dto/cleanup-upload-history.dto.js +36 -0
- package/dist/course/dto/cleanup-upload-history.dto.js.map +1 -0
- package/dist/course/dto/create-course-bulk-job.dto.d.ts +4 -0
- package/dist/course/dto/create-course-bulk-job.dto.d.ts.map +1 -0
- package/dist/course/dto/create-course-bulk-job.dto.js +21 -0
- package/dist/course/dto/create-course-bulk-job.dto.js.map +1 -0
- package/dist/course/lms-bulk-upload-automation.service.d.ts +39 -0
- package/dist/course/lms-bulk-upload-automation.service.d.ts.map +1 -0
- package/dist/course/lms-bulk-upload-automation.service.js +443 -0
- package/dist/course/lms-bulk-upload-automation.service.js.map +1 -0
- package/dist/course/lms-bulk-upload-infra.service.d.ts +31 -0
- package/dist/course/lms-bulk-upload-infra.service.d.ts.map +1 -0
- package/dist/course/lms-bulk-upload-infra.service.js +277 -0
- package/dist/course/lms-bulk-upload-infra.service.js.map +1 -0
- package/dist/course/lms-bulk-upload.constants.d.ts +4 -0
- package/dist/course/lms-bulk-upload.constants.d.ts.map +1 -0
- package/dist/course/lms-bulk-upload.constants.js +7 -0
- package/dist/course/lms-bulk-upload.constants.js.map +1 -0
- package/dist/course/lms-bulk-upload.controller.d.ts +116 -0
- package/dist/course/lms-bulk-upload.controller.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload.controller.js +71 -2
- package/dist/course/lms-bulk-upload.controller.js.map +1 -1
- package/dist/course/lms-bulk-upload.service.d.ts +142 -3
- package/dist/course/lms-bulk-upload.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload.service.js +606 -21
- package/dist/course/lms-bulk-upload.service.js.map +1 -1
- package/dist/course/lms-setting.controller.d.ts +4 -1
- package/dist/course/lms-setting.controller.d.ts.map +1 -1
- package/dist/course/lms-setting.controller.js +21 -6
- package/dist/course/lms-setting.controller.js.map +1 -1
- package/dist/enterprise/enterprise.controller.d.ts +20 -20
- package/dist/enterprise/enterprise.service.d.ts +20 -20
- package/dist/enterprise/training/training-admin.controller.d.ts +11 -11
- package/dist/enterprise/training/training-admin.service.d.ts +11 -11
- package/dist/enterprise/training/training-instructor.controller.d.ts +2 -2
- package/dist/enterprise/training/training-instructor.service.d.ts +2 -2
- package/dist/enterprise/training/training-student.controller.d.ts +1 -1
- package/dist/enterprise/training/training-student.service.d.ts +1 -1
- package/dist/enterprise/training/training-viewer.controller.d.ts +2 -2
- package/dist/evaluation/evaluation.controller.d.ts +8 -8
- package/dist/evaluation/evaluation.service.d.ts +8 -8
- package/dist/lesson-xp-map/dto/create-lesson-xp-map.dto.d.ts +6 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-map.dto.d.ts.map +1 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-map.dto.js +34 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-map.dto.js.map +1 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-segment.dto.d.ts +28 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-segment.dto.d.ts.map +1 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-segment.dto.js +123 -0
- package/dist/lesson-xp-map/dto/create-lesson-xp-segment.dto.js.map +1 -0
- package/dist/lesson-xp-map/dto/review-lesson-xp-map.dto.d.ts +4 -0
- package/dist/lesson-xp-map/dto/review-lesson-xp-map.dto.d.ts.map +1 -0
- package/dist/lesson-xp-map/dto/review-lesson-xp-map.dto.js +22 -0
- package/dist/lesson-xp-map/dto/review-lesson-xp-map.dto.js.map +1 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-map.dto.d.ts +10 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-map.dto.d.ts.map +1 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-map.dto.js +52 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-map.dto.js.map +1 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-segment.dto.d.ts +15 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-segment.dto.d.ts.map +1 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-segment.dto.js +86 -0
- package/dist/lesson-xp-map/dto/update-lesson-xp-segment.dto.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts +26 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js +304 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-map.controller.d.ts +87 -0
- package/dist/lesson-xp-map/lesson-xp-map.controller.d.ts.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-map.controller.js +185 -0
- package/dist/lesson-xp-map/lesson-xp-map.controller.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-map.module.d.ts +3 -0
- package/dist/lesson-xp-map/lesson-xp-map.module.d.ts.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-map.module.js +34 -0
- package/dist/lesson-xp-map/lesson-xp-map.module.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-map.service.d.ts +84 -0
- package/dist/lesson-xp-map/lesson-xp-map.service.d.ts.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-map.service.js +353 -0
- package/dist/lesson-xp-map/lesson-xp-map.service.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-segment.controller.d.ts +10 -0
- package/dist/lesson-xp-map/lesson-xp-segment.controller.d.ts.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-segment.controller.js +63 -0
- package/dist/lesson-xp-map/lesson-xp-segment.controller.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-segment.service.d.ts +27 -0
- package/dist/lesson-xp-map/lesson-xp-segment.service.d.ts.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-segment.service.js +194 -0
- package/dist/lesson-xp-map/lesson-xp-segment.service.js.map +1 -0
- package/dist/libraries/lms/tsconfig.tsbuildinfo +1 -0
- package/dist/lms.module.d.ts.map +1 -1
- package/dist/lms.module.js +17 -2
- package/dist/lms.module.js.map +1 -1
- package/dist/platforma/dto/update-profile.dto.d.ts +17 -0
- package/dist/platforma/dto/update-profile.dto.d.ts.map +1 -0
- package/dist/platforma/dto/update-profile.dto.js +87 -0
- package/dist/platforma/dto/update-profile.dto.js.map +1 -0
- package/dist/platforma/platforma.controller.d.ts +88 -1
- package/dist/platforma/platforma.controller.d.ts.map +1 -1
- package/dist/platforma/platforma.controller.js +85 -2
- package/dist/platforma/platforma.controller.js.map +1 -1
- package/dist/platforma/platforma.service.d.ts +27 -0
- package/dist/platforma/platforma.service.d.ts.map +1 -0
- package/dist/platforma/platforma.service.js +274 -0
- package/dist/platforma/platforma.service.js.map +1 -0
- package/dist/student-xp/student-xp.controller.d.ts +41 -0
- package/dist/student-xp/student-xp.controller.d.ts.map +1 -0
- package/dist/student-xp/student-xp.controller.js +114 -0
- package/dist/student-xp/student-xp.controller.js.map +1 -0
- package/dist/student-xp/student-xp.module.d.ts +3 -0
- package/dist/student-xp/student-xp.module.d.ts.map +1 -0
- package/dist/student-xp/student-xp.module.js +25 -0
- package/dist/student-xp/student-xp.module.js.map +1 -0
- package/dist/student-xp/student-xp.service.d.ts +65 -0
- package/dist/student-xp/student-xp.service.d.ts.map +1 -0
- package/dist/student-xp/student-xp.service.js +197 -0
- package/dist/student-xp/student-xp.service.js.map +1 -0
- package/dist/xp-catalog/dto/create-xp-area.dto.d.ts +12 -0
- package/dist/xp-catalog/dto/create-xp-area.dto.d.ts.map +1 -0
- package/dist/xp-catalog/dto/create-xp-area.dto.js +63 -0
- package/dist/xp-catalog/dto/create-xp-area.dto.js.map +1 -0
- package/dist/xp-catalog/dto/create-xp-learning-type.dto.d.ts +11 -0
- package/dist/xp-catalog/dto/create-xp-learning-type.dto.d.ts.map +1 -0
- package/dist/xp-catalog/dto/create-xp-learning-type.dto.js +57 -0
- package/dist/xp-catalog/dto/create-xp-learning-type.dto.js.map +1 -0
- package/dist/xp-catalog/dto/create-xp-skill.dto.d.ts +11 -0
- package/dist/xp-catalog/dto/create-xp-skill.dto.d.ts.map +1 -0
- package/dist/xp-catalog/dto/create-xp-skill.dto.js +57 -0
- package/dist/xp-catalog/dto/create-xp-skill.dto.js.map +1 -0
- package/dist/xp-catalog/dto/update-xp-area.dto.d.ts +12 -0
- package/dist/xp-catalog/dto/update-xp-area.dto.d.ts.map +1 -0
- package/dist/xp-catalog/dto/update-xp-area.dto.js +66 -0
- package/dist/xp-catalog/dto/update-xp-area.dto.js.map +1 -0
- package/dist/xp-catalog/dto/update-xp-learning-type.dto.d.ts +11 -0
- package/dist/xp-catalog/dto/update-xp-learning-type.dto.d.ts.map +1 -0
- package/dist/xp-catalog/dto/update-xp-learning-type.dto.js +60 -0
- package/dist/xp-catalog/dto/update-xp-learning-type.dto.js.map +1 -0
- package/dist/xp-catalog/dto/update-xp-skill.dto.d.ts +11 -0
- package/dist/xp-catalog/dto/update-xp-skill.dto.d.ts.map +1 -0
- package/dist/xp-catalog/dto/update-xp-skill.dto.js +60 -0
- package/dist/xp-catalog/dto/update-xp-skill.dto.js.map +1 -0
- package/dist/xp-catalog/xp-area.controller.d.ts +25 -0
- package/dist/xp-catalog/xp-area.controller.d.ts.map +1 -0
- package/dist/xp-catalog/xp-area.controller.js +105 -0
- package/dist/xp-catalog/xp-area.controller.js.map +1 -0
- package/dist/xp-catalog/xp-area.service.d.ts +35 -0
- package/dist/xp-catalog/xp-area.service.d.ts.map +1 -0
- package/dist/xp-catalog/xp-area.service.js +168 -0
- package/dist/xp-catalog/xp-area.service.js.map +1 -0
- package/dist/xp-catalog/xp-catalog.module.d.ts +3 -0
- package/dist/xp-catalog/xp-catalog.module.d.ts.map +1 -0
- package/dist/xp-catalog/xp-catalog.module.js +29 -0
- package/dist/xp-catalog/xp-catalog.module.js.map +1 -0
- package/dist/xp-catalog/xp-learning-type.controller.d.ts +20 -0
- package/dist/xp-catalog/xp-learning-type.controller.d.ts.map +1 -0
- package/dist/xp-catalog/xp-learning-type.controller.js +96 -0
- package/dist/xp-catalog/xp-learning-type.controller.js.map +1 -0
- package/dist/xp-catalog/xp-learning-type.service.d.ts +30 -0
- package/dist/xp-catalog/xp-learning-type.service.d.ts.map +1 -0
- package/dist/xp-catalog/xp-learning-type.service.js +146 -0
- package/dist/xp-catalog/xp-learning-type.service.js.map +1 -0
- package/dist/xp-catalog/xp-skill.controller.d.ts +26 -0
- package/dist/xp-catalog/xp-skill.controller.d.ts.map +1 -0
- package/dist/xp-catalog/xp-skill.controller.js +113 -0
- package/dist/xp-catalog/xp-skill.controller.js.map +1 -0
- package/dist/xp-catalog/xp-skill.service.d.ts +37 -0
- package/dist/xp-catalog/xp-skill.service.d.ts.map +1 -0
- package/dist/xp-catalog/xp-skill.service.js +174 -0
- package/dist/xp-catalog/xp-skill.service.js.map +1 -0
- package/hedhog/data/menu.yaml +101 -0
- package/hedhog/data/route.yaml +512 -0
- package/hedhog/data/setting_group.yaml +1 -1
- package/hedhog/data/xp_area.yaml +164 -0
- package/hedhog/data/xp_learning_type.yaml +131 -0
- package/hedhog/data/xp_skill.yaml +1834 -0
- package/hedhog/frontend/app/achievements/page.tsx.ejs +108 -118
- package/hedhog/frontend/app/bitcodes/page.tsx.ejs +22 -34
- package/hedhog/frontend/app/bulk-upload-sessions/page.tsx.ejs +1453 -0
- package/hedhog/frontend/app/certificates/models/page.tsx.ejs +21 -45
- package/hedhog/frontend/app/classes/[id]/page.tsx.ejs +40 -74
- package/hedhog/frontend/app/classes/page.tsx.ejs +56 -85
- package/hedhog/frontend/app/courses/[id]/_components/CourseDangerZoneCard.tsx.ejs +3 -2
- package/hedhog/frontend/app/courses/[id]/_components/CourseMediaCard.tsx.ejs +48 -5
- package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +4 -4
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-operations-tab.tsx.ejs +19 -2
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-overview-tab.tsx.ejs +1170 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree-dnd.tsx.ejs +16 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree.tsx.ejs +2 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-xp-overview-tab.tsx.ejs +623 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson-xp-tab.tsx.ejs +1458 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +55 -2
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +442 -104
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-lesson.tsx.ejs +296 -49
- package/hedhog/frontend/app/courses/[id]/structure/_components/sortable-tree-row.tsx.ejs +3 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/store.ts.ejs +1 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-display-settings-popover.tsx.ejs +101 -85
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-lesson.tsx.ejs +21 -1
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row.tsx.ejs +3 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/use-tree-display-settings.ts.ejs +7 -1
- package/hedhog/frontend/app/courses/[id]/structure/_components/xp-premium-pills.tsx.ejs +44 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-content-overview.ts.ejs +54 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-mutations.ts.ejs +52 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-xp-overview.ts.ejs +76 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-lesson-xp-map.ts.ejs +128 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-transcription-segments.ts.ejs +30 -0
- package/hedhog/frontend/app/courses/[id]/structure/_utils/xp-color-config.ts.ejs +115 -0
- package/hedhog/frontend/app/courses/_components/CourseDeleteDialog.tsx.ejs +223 -0
- package/hedhog/frontend/app/courses/_components/CourseRowActions.tsx.ejs +89 -0
- package/hedhog/frontend/app/courses/page.tsx.ejs +400 -230
- package/hedhog/frontend/app/enterprise/page.tsx.ejs +39 -63
- package/hedhog/frontend/app/exams/[id]/questions/page.tsx.ejs +53 -77
- package/hedhog/frontend/app/exams/page.tsx.ejs +54 -90
- package/hedhog/frontend/app/instructor-skills/page.tsx.ejs +23 -36
- package/hedhog/frontend/app/instructors/page.tsx.ejs +72 -81
- package/hedhog/frontend/app/paths/page.tsx.ejs +40 -68
- package/hedhog/frontend/app/training/page.tsx.ejs +40 -68
- package/hedhog/frontend/app/xp/areas/page.tsx.ejs +782 -0
- package/hedhog/frontend/app/xp/learning-types/page.tsx.ejs +690 -0
- package/hedhog/frontend/app/xp/skills/page.tsx.ejs +811 -0
- package/hedhog/frontend/messages/en.json +386 -3
- package/hedhog/frontend/messages/pt.json +386 -3
- package/hedhog/table/lesson_xp_map.yaml +50 -0
- package/hedhog/table/lesson_xp_segment.yaml +40 -0
- package/hedhog/table/lesson_xp_segment_area.yaml +24 -0
- package/hedhog/table/lesson_xp_segment_learning_type.yaml +24 -0
- package/hedhog/table/lesson_xp_segment_skill.yaml +24 -0
- package/hedhog/table/lms_bulk_upload_item.yaml +44 -0
- package/hedhog/table/lms_bulk_upload_session.yaml +42 -0
- package/hedhog/table/student_area_xp.yaml +30 -0
- package/hedhog/table/student_learning_type_xp.yaml +30 -0
- package/hedhog/table/student_skill_xp.yaml +30 -0
- package/hedhog/table/student_xp_event.yaml +34 -0
- package/hedhog/table/xp_area.yaml +39 -0
- package/hedhog/table/xp_learning_type.yaml +34 -0
- package/hedhog/table/xp_skill.yaml +39 -0
- package/package.json +8 -7
- package/src/bitcode-wallet/bitcode-wallet.service.ts +113 -0
- package/src/bitcode-wallet/dto/create-current-bitcode-wallet-transaction.dto.ts +32 -0
- package/src/course/course-audio-transcription.service.ts +58 -21
- package/src/course/course-lesson.controller.ts +6 -1
- package/src/course/course-structure.controller.ts +10 -0
- package/src/course/course-structure.service.ts +174 -1
- package/src/course/course-video-conversion.service.ts +113 -75
- package/src/course/course.controller.ts +22 -3
- package/src/course/course.module.ts +2 -0
- package/src/course/course.service.ts +847 -30
- package/src/course/dto/cleanup-course-storage.dto.ts +22 -0
- package/src/course/dto/cleanup-upload-history.dto.ts +26 -0
- package/src/course/dto/create-course-bulk-job.dto.ts +6 -0
- package/src/course/lms-bulk-upload-automation.service.ts +560 -0
- package/src/course/lms-bulk-upload-infra.service.ts +327 -0
- package/src/course/lms-bulk-upload.constants.ts +5 -0
- package/src/course/lms-bulk-upload.controller.ts +79 -3
- package/src/course/lms-bulk-upload.service.ts +1029 -204
- package/src/course/lms-setting.controller.ts +22 -6
- package/src/lesson-xp-map/dto/create-lesson-xp-map.dto.ts +17 -0
- package/src/lesson-xp-map/dto/create-lesson-xp-segment.dto.ts +102 -0
- package/src/lesson-xp-map/dto/review-lesson-xp-map.dto.ts +7 -0
- package/src/lesson-xp-map/dto/update-lesson-xp-map.dto.ts +36 -0
- package/src/lesson-xp-map/dto/update-lesson-xp-segment.dto.ts +78 -0
- package/src/lesson-xp-map/lesson-xp-ai-calculation.service.ts +396 -0
- package/src/lesson-xp-map/lesson-xp-map.controller.ts +116 -0
- package/src/lesson-xp-map/lesson-xp-map.module.ts +21 -0
- package/src/lesson-xp-map/lesson-xp-map.service.ts +442 -0
- package/src/lesson-xp-map/lesson-xp-segment.controller.ts +36 -0
- package/src/lesson-xp-map/lesson-xp-segment.service.ts +229 -0
- package/src/lms.module.ts +17 -2
- package/src/platforma/dto/update-profile.dto.ts +59 -0
- package/src/platforma/platforma.controller.ts +57 -2
- package/src/platforma/platforma.service.ts +268 -0
- package/src/student-xp/student-xp.controller.ts +76 -0
- package/src/student-xp/student-xp.module.ts +12 -0
- package/src/student-xp/student-xp.service.ts +236 -0
- package/src/xp-catalog/dto/create-xp-area.dto.ts +40 -0
- package/src/xp-catalog/dto/create-xp-learning-type.dto.ts +35 -0
- package/src/xp-catalog/dto/create-xp-skill.dto.ts +35 -0
- package/src/xp-catalog/dto/update-xp-area.dto.ts +43 -0
- package/src/xp-catalog/dto/update-xp-learning-type.dto.ts +38 -0
- package/src/xp-catalog/dto/update-xp-skill.dto.ts +38 -0
- package/src/xp-catalog/xp-area.controller.ts +64 -0
- package/src/xp-catalog/xp-area.service.ts +196 -0
- package/src/xp-catalog/xp-catalog.module.ts +16 -0
- package/src/xp-catalog/xp-learning-type.controller.ts +59 -0
- package/src/xp-catalog/xp-learning-type.service.ts +170 -0
- package/src/xp-catalog/xp-skill.controller.ts +71 -0
- package/src/xp-catalog/xp-skill.service.ts +205 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { PrismaService } from '@hed-hog/api-prisma';
|
|
2
|
+
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
3
|
+
import {
|
|
4
|
+
SegmentAreaDto,
|
|
5
|
+
SegmentLearningTypeDto,
|
|
6
|
+
SegmentSkillDto,
|
|
7
|
+
CreateLessonXpSegmentDto,
|
|
8
|
+
} from './dto/create-lesson-xp-segment.dto';
|
|
9
|
+
import { UpdateLessonXpSegmentDto } from './dto/update-lesson-xp-segment.dto';
|
|
10
|
+
|
|
11
|
+
@Injectable()
|
|
12
|
+
export class LessonXpSegmentService {
|
|
13
|
+
constructor(private readonly prisma: PrismaService) {}
|
|
14
|
+
|
|
15
|
+
async listByMap(mapId: number, params: { page?: number; pageSize?: number }) {
|
|
16
|
+
const page = Math.max(Number(params.page) || 1, 1);
|
|
17
|
+
const pageSize = Math.max(Number(params.pageSize) || 50, 1);
|
|
18
|
+
const offset = (page - 1) * pageSize;
|
|
19
|
+
|
|
20
|
+
const totalRow = await this.querySingle<{ total: string }>(
|
|
21
|
+
`SELECT COUNT(*)::text AS total FROM lesson_xp_segment WHERE lesson_xp_map_id = $1`,
|
|
22
|
+
[mapId],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const rows = await this.queryRows<any>(
|
|
26
|
+
`SELECT
|
|
27
|
+
s.id,
|
|
28
|
+
s.lesson_xp_map_id AS "lessonXpMapId",
|
|
29
|
+
s.start_seconds::float AS "startSeconds",
|
|
30
|
+
s.end_seconds::float AS "endSeconds",
|
|
31
|
+
s.xp_value AS "xpValue",
|
|
32
|
+
s.difficulty::text AS difficulty,
|
|
33
|
+
s.should_grant_xp AS "shouldGrantXp",
|
|
34
|
+
s.ai_summary AS "aiSummary",
|
|
35
|
+
s.ai_confidence::float AS "aiConfidence",
|
|
36
|
+
s.sort_order AS "sortOrder",
|
|
37
|
+
s.created_at::text AS "createdAt",
|
|
38
|
+
s.updated_at::text AS "updatedAt",
|
|
39
|
+
COALESCE(
|
|
40
|
+
(SELECT json_agg(json_build_object('xpAreaId', sa.xp_area_id, 'weightPercent', sa.weight_percent::float))
|
|
41
|
+
FROM lesson_xp_segment_area sa WHERE sa.lesson_xp_segment_id = s.id),
|
|
42
|
+
'[]'
|
|
43
|
+
) AS areas,
|
|
44
|
+
COALESCE(
|
|
45
|
+
(SELECT json_agg(json_build_object('xpSkillId', ss.xp_skill_id, 'weightPercent', ss.weight_percent::float))
|
|
46
|
+
FROM lesson_xp_segment_skill ss WHERE ss.lesson_xp_segment_id = s.id),
|
|
47
|
+
'[]'
|
|
48
|
+
) AS skills,
|
|
49
|
+
COALESCE(
|
|
50
|
+
(SELECT json_agg(json_build_object('xpLearningTypeId', sl.xp_learning_type_id, 'weightPercent', sl.weight_percent::float))
|
|
51
|
+
FROM lesson_xp_segment_learning_type sl WHERE sl.lesson_xp_segment_id = s.id),
|
|
52
|
+
'[]'
|
|
53
|
+
) AS "learningTypes"
|
|
54
|
+
FROM lesson_xp_segment s
|
|
55
|
+
WHERE s.lesson_xp_map_id = $1
|
|
56
|
+
ORDER BY s.sort_order ASC, s.start_seconds ASC
|
|
57
|
+
LIMIT $2 OFFSET $3`,
|
|
58
|
+
[mapId, pageSize, offset],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const total = Number(totalRow?.total ?? 0);
|
|
62
|
+
return { data: rows, total, page, pageSize, lastPage: Math.ceil(total / pageSize) };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getById(id: number) {
|
|
66
|
+
const row = await this.querySingle<any>(
|
|
67
|
+
`SELECT
|
|
68
|
+
s.id,
|
|
69
|
+
s.lesson_xp_map_id AS "lessonXpMapId",
|
|
70
|
+
s.start_seconds::float AS "startSeconds",
|
|
71
|
+
s.end_seconds::float AS "endSeconds",
|
|
72
|
+
s.xp_value AS "xpValue",
|
|
73
|
+
s.difficulty::text AS difficulty,
|
|
74
|
+
s.should_grant_xp AS "shouldGrantXp",
|
|
75
|
+
s.ai_summary AS "aiSummary",
|
|
76
|
+
s.ai_confidence::float AS "aiConfidence",
|
|
77
|
+
s.sort_order AS "sortOrder",
|
|
78
|
+
s.created_at::text AS "createdAt",
|
|
79
|
+
s.updated_at::text AS "updatedAt"
|
|
80
|
+
FROM lesson_xp_segment s WHERE s.id = $1`,
|
|
81
|
+
[id],
|
|
82
|
+
);
|
|
83
|
+
if (!row) throw new NotFoundException('Lesson XP segment not found');
|
|
84
|
+
|
|
85
|
+
const [areas, skills, learningTypes] = await Promise.all([
|
|
86
|
+
this.queryRows<any>(`SELECT xp_area_id AS "xpAreaId", weight_percent::float AS "weightPercent" FROM lesson_xp_segment_area WHERE lesson_xp_segment_id = $1`, [id]),
|
|
87
|
+
this.queryRows<any>(`SELECT xp_skill_id AS "xpSkillId", weight_percent::float AS "weightPercent" FROM lesson_xp_segment_skill WHERE lesson_xp_segment_id = $1`, [id]),
|
|
88
|
+
this.queryRows<any>(`SELECT xp_learning_type_id AS "xpLearningTypeId", weight_percent::float AS "weightPercent" FROM lesson_xp_segment_learning_type WHERE lesson_xp_segment_id = $1`, [id]),
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
return { ...row, areas, skills, learningTypes };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async create(mapId: number, dto: CreateLessonXpSegmentDto) {
|
|
95
|
+
const map = await this.querySingle<{ id: number }>(`SELECT id FROM lesson_xp_map WHERE id = $1`, [mapId]);
|
|
96
|
+
if (!map) throw new NotFoundException('Lesson XP map not found');
|
|
97
|
+
|
|
98
|
+
const created = await this.querySingle<{ id: number }>(
|
|
99
|
+
`INSERT INTO lesson_xp_segment
|
|
100
|
+
(lesson_xp_map_id, start_seconds, end_seconds, xp_value, difficulty, should_grant_xp,
|
|
101
|
+
ai_summary, ai_confidence, sort_order, created_at, updated_at)
|
|
102
|
+
VALUES ($1, $2, $3, $4, $5::lesson_xp_segment_difficulty_e5f6a7b8c9_enum, $6, $7, $8, $9, NOW(), NOW())
|
|
103
|
+
RETURNING id`,
|
|
104
|
+
[
|
|
105
|
+
mapId, dto.startSeconds, dto.endSeconds, dto.xpValue,
|
|
106
|
+
dto.difficulty, dto.shouldGrantXp, dto.aiSummary ?? null,
|
|
107
|
+
dto.aiConfidence ?? null, dto.sortOrder ?? 0,
|
|
108
|
+
],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
await this.syncRelations(created!.id, dto.areas, dto.skills, dto.learningTypes);
|
|
112
|
+
await this.recalculateTotalXp(mapId);
|
|
113
|
+
return this.getById(created!.id);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async update(id: number, dto: UpdateLessonXpSegmentDto) {
|
|
117
|
+
const segment = await this.querySingle<{ id: number; lesson_xp_map_id: number }>(
|
|
118
|
+
`SELECT id, lesson_xp_map_id FROM lesson_xp_segment WHERE id = $1`,
|
|
119
|
+
[id],
|
|
120
|
+
);
|
|
121
|
+
if (!segment) throw new NotFoundException('Lesson XP segment not found');
|
|
122
|
+
|
|
123
|
+
const updates: string[] = [];
|
|
124
|
+
const values: unknown[] = [];
|
|
125
|
+
|
|
126
|
+
if (dto.startSeconds !== undefined) updates.push(`start_seconds = ${this.param(values, dto.startSeconds)}`);
|
|
127
|
+
if (dto.endSeconds !== undefined) updates.push(`end_seconds = ${this.param(values, dto.endSeconds)}`);
|
|
128
|
+
if (dto.xpValue !== undefined) updates.push(`xp_value = ${this.param(values, dto.xpValue)}`);
|
|
129
|
+
if (dto.difficulty !== undefined) updates.push(`difficulty = ${this.param(values, dto.difficulty)}::lesson_xp_segment_difficulty_e5f6a7b8c9_enum`);
|
|
130
|
+
if (dto.shouldGrantXp !== undefined) updates.push(`should_grant_xp = ${this.param(values, dto.shouldGrantXp)}`);
|
|
131
|
+
if (dto.aiSummary !== undefined) updates.push(`ai_summary = ${this.param(values, dto.aiSummary)}`);
|
|
132
|
+
if (dto.aiConfidence !== undefined) updates.push(`ai_confidence = ${this.param(values, dto.aiConfidence)}`);
|
|
133
|
+
if (dto.sortOrder !== undefined) updates.push(`sort_order = ${this.param(values, dto.sortOrder)}`);
|
|
134
|
+
|
|
135
|
+
if (updates.length > 0) {
|
|
136
|
+
values.push(id);
|
|
137
|
+
await this.prisma.$executeRawUnsafe(
|
|
138
|
+
`UPDATE lesson_xp_segment SET ${updates.join(', ')}, updated_at = NOW() WHERE id = $${values.length}`,
|
|
139
|
+
...values,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (dto.areas !== undefined || dto.skills !== undefined || dto.learningTypes !== undefined) {
|
|
144
|
+
await this.syncRelations(id, dto.areas, dto.skills, dto.learningTypes);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
await this.recalculateTotalXp(segment.lesson_xp_map_id);
|
|
148
|
+
return this.getById(id);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async delete(id: number) {
|
|
152
|
+
const segment = await this.querySingle<{ id: number; lesson_xp_map_id: number }>(
|
|
153
|
+
`SELECT id, lesson_xp_map_id FROM lesson_xp_segment WHERE id = $1`,
|
|
154
|
+
[id],
|
|
155
|
+
);
|
|
156
|
+
if (!segment) throw new NotFoundException('Lesson XP segment not found');
|
|
157
|
+
|
|
158
|
+
await this.prisma.$executeRawUnsafe(`DELETE FROM lesson_xp_segment WHERE id = $1`, id);
|
|
159
|
+
await this.recalculateTotalXp(segment.lesson_xp_map_id);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private async syncRelations(
|
|
163
|
+
segmentId: number,
|
|
164
|
+
areas?: SegmentAreaDto[],
|
|
165
|
+
skills?: SegmentSkillDto[],
|
|
166
|
+
learningTypes?: SegmentLearningTypeDto[],
|
|
167
|
+
) {
|
|
168
|
+
if (areas !== undefined) {
|
|
169
|
+
await this.prisma.$executeRawUnsafe(`DELETE FROM lesson_xp_segment_area WHERE lesson_xp_segment_id = $1`, segmentId);
|
|
170
|
+
for (const area of areas) {
|
|
171
|
+
await this.prisma.$executeRawUnsafe(
|
|
172
|
+
`INSERT INTO lesson_xp_segment_area (lesson_xp_segment_id, xp_area_id, weight_percent, created_at, updated_at)
|
|
173
|
+
VALUES ($1, $2, $3, NOW(), NOW())`,
|
|
174
|
+
segmentId, area.xpAreaId, area.weightPercent,
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (skills !== undefined) {
|
|
180
|
+
await this.prisma.$executeRawUnsafe(`DELETE FROM lesson_xp_segment_skill WHERE lesson_xp_segment_id = $1`, segmentId);
|
|
181
|
+
for (const skill of skills) {
|
|
182
|
+
await this.prisma.$executeRawUnsafe(
|
|
183
|
+
`INSERT INTO lesson_xp_segment_skill (lesson_xp_segment_id, xp_skill_id, weight_percent, created_at, updated_at)
|
|
184
|
+
VALUES ($1, $2, $3, NOW(), NOW())`,
|
|
185
|
+
segmentId, skill.xpSkillId, skill.weightPercent,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (learningTypes !== undefined) {
|
|
191
|
+
await this.prisma.$executeRawUnsafe(`DELETE FROM lesson_xp_segment_learning_type WHERE lesson_xp_segment_id = $1`, segmentId);
|
|
192
|
+
for (const lt of learningTypes) {
|
|
193
|
+
await this.prisma.$executeRawUnsafe(
|
|
194
|
+
`INSERT INTO lesson_xp_segment_learning_type (lesson_xp_segment_id, xp_learning_type_id, weight_percent, created_at, updated_at)
|
|
195
|
+
VALUES ($1, $2, $3, NOW(), NOW())`,
|
|
196
|
+
segmentId, lt.xpLearningTypeId, lt.weightPercent,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private async recalculateTotalXp(mapId: number) {
|
|
203
|
+
await this.prisma.$executeRawUnsafe(
|
|
204
|
+
`UPDATE lesson_xp_map
|
|
205
|
+
SET total_xp = COALESCE(
|
|
206
|
+
(SELECT SUM(xp_value) FROM lesson_xp_segment
|
|
207
|
+
WHERE lesson_xp_map_id = $1 AND should_grant_xp = true),
|
|
208
|
+
0
|
|
209
|
+
),
|
|
210
|
+
updated_at = NOW()
|
|
211
|
+
WHERE id = $1`,
|
|
212
|
+
mapId,
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private param(values: unknown[], value: unknown) {
|
|
217
|
+
values.push(value);
|
|
218
|
+
return `$${values.length}`;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private async queryRows<T>(query: string, values: unknown[] = []) {
|
|
222
|
+
return this.prisma.$queryRawUnsafe<T[]>(query, ...values);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private async querySingle<T>(query: string, values: unknown[] = []) {
|
|
226
|
+
const rows = await this.prisma.$queryRawUnsafe<T[]>(query, ...values);
|
|
227
|
+
return rows[0] ?? null;
|
|
228
|
+
}
|
|
229
|
+
}
|
package/src/lms.module.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { ClassGroupModule } from './class-group/class-group.module';
|
|
|
12
12
|
import { CourseLessonDiscussionModule } from './course-lesson-discussion/course-lesson-discussion.module';
|
|
13
13
|
import { CourseLessonNoteModule } from './course-lesson-note/course-lesson-note.module';
|
|
14
14
|
import { CourseAudioTranscriptionService } from './course/course-audio-transcription.service';
|
|
15
|
+
import { LmsBulkUploadAutomationService } from './course/lms-bulk-upload-automation.service';
|
|
15
16
|
import { CourseModule } from './course/course.module';
|
|
16
17
|
import { LmsDashboardModule } from './dashboard/dashboard.module';
|
|
17
18
|
import { EnterpriseModule } from './enterprise/enterprise.module';
|
|
@@ -19,9 +20,13 @@ import { EnterpriseTrainingModule } from './enterprise/training/enterprise-train
|
|
|
19
20
|
import { EvaluationModule } from './evaluation/evaluation.module';
|
|
20
21
|
import { ExamModule } from './exam/exam.module';
|
|
21
22
|
import { InstructorModule } from './instructor/instructor.module';
|
|
23
|
+
import { LessonXpMapModule } from './lesson-xp-map/lesson-xp-map.module';
|
|
24
|
+
import { PlataformaController } from './platforma/platforma.controller';
|
|
25
|
+
import { StudentXpModule } from './student-xp/student-xp.module';
|
|
26
|
+
import { XpCatalogModule } from './xp-catalog/xp-catalog.module';
|
|
27
|
+
import { PlatformaService } from './platforma/platforma.service';
|
|
22
28
|
import { LmsRealtimeModule } from './realtime/lms-realtime.module';
|
|
23
29
|
import { LmsReportsModule } from './reports/reports.module';
|
|
24
|
-
import { PlataformaController } from './platforma/platforma.controller';
|
|
25
30
|
import { TrainingModule } from './training/training.module';
|
|
26
31
|
import { VideoResolutionProfileModule } from './video-resolution-profile/video-resolution-profile.module';
|
|
27
32
|
|
|
@@ -50,9 +55,16 @@ import { VideoResolutionProfileModule } from './video-resolution-profile/video-r
|
|
|
50
55
|
forwardRef(() => LmsReportsModule),
|
|
51
56
|
forwardRef(() => TrainingModule),
|
|
52
57
|
forwardRef(() => VideoResolutionProfileModule),
|
|
58
|
+
forwardRef(() => XpCatalogModule),
|
|
59
|
+
forwardRef(() => LessonXpMapModule),
|
|
60
|
+
forwardRef(() => StudentXpModule),
|
|
53
61
|
],
|
|
54
62
|
controllers: [PlataformaController],
|
|
55
|
-
providers: [
|
|
63
|
+
providers: [
|
|
64
|
+
CourseAudioTranscriptionService,
|
|
65
|
+
LmsBulkUploadAutomationService,
|
|
66
|
+
PlatformaService,
|
|
67
|
+
],
|
|
56
68
|
exports: [
|
|
57
69
|
forwardRef(() => AchievementModule),
|
|
58
70
|
forwardRef(() => BitcodeWalletModule),
|
|
@@ -71,6 +83,9 @@ import { VideoResolutionProfileModule } from './video-resolution-profile/video-r
|
|
|
71
83
|
forwardRef(() => LmsReportsModule),
|
|
72
84
|
forwardRef(() => TrainingModule),
|
|
73
85
|
forwardRef(() => VideoResolutionProfileModule),
|
|
86
|
+
forwardRef(() => XpCatalogModule),
|
|
87
|
+
forwardRef(() => LessonXpMapModule),
|
|
88
|
+
forwardRef(() => StudentXpModule),
|
|
74
89
|
],
|
|
75
90
|
})
|
|
76
91
|
export class LmsModule {}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IsOptional, IsString } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class UpdatePlatformaProfileDto {
|
|
4
|
+
@IsOptional()
|
|
5
|
+
@IsString()
|
|
6
|
+
name?: string;
|
|
7
|
+
|
|
8
|
+
@IsOptional()
|
|
9
|
+
@IsString()
|
|
10
|
+
cpf?: string;
|
|
11
|
+
|
|
12
|
+
@IsOptional()
|
|
13
|
+
@IsString()
|
|
14
|
+
dob?: string;
|
|
15
|
+
|
|
16
|
+
@IsOptional()
|
|
17
|
+
@IsString()
|
|
18
|
+
gender?: string;
|
|
19
|
+
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@IsString()
|
|
22
|
+
country?: string;
|
|
23
|
+
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@IsString()
|
|
26
|
+
city?: string;
|
|
27
|
+
|
|
28
|
+
@IsOptional()
|
|
29
|
+
@IsString()
|
|
30
|
+
state?: string;
|
|
31
|
+
|
|
32
|
+
@IsOptional()
|
|
33
|
+
@IsString()
|
|
34
|
+
neighborhood?: string;
|
|
35
|
+
|
|
36
|
+
@IsOptional()
|
|
37
|
+
@IsString()
|
|
38
|
+
street?: string;
|
|
39
|
+
|
|
40
|
+
@IsOptional()
|
|
41
|
+
@IsString()
|
|
42
|
+
number?: string;
|
|
43
|
+
|
|
44
|
+
@IsOptional()
|
|
45
|
+
@IsString()
|
|
46
|
+
complement?: string;
|
|
47
|
+
|
|
48
|
+
@IsOptional()
|
|
49
|
+
@IsString()
|
|
50
|
+
zip?: string;
|
|
51
|
+
|
|
52
|
+
@IsOptional()
|
|
53
|
+
@IsString()
|
|
54
|
+
phone?: string;
|
|
55
|
+
|
|
56
|
+
@IsOptional()
|
|
57
|
+
@IsString()
|
|
58
|
+
profession?: string;
|
|
59
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { NoRole, User } from '@hed-hog/api';
|
|
2
2
|
import { NotificationService } from '@hed-hog/core';
|
|
3
|
-
import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Query } from '@nestjs/common';
|
|
3
|
+
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, Put, Query, Req, Res } from '@nestjs/common';
|
|
4
|
+
import type { Request, Response } from 'express';
|
|
5
|
+
import { BitcodeWalletService } from '../bitcode-wallet/bitcode-wallet.service';
|
|
6
|
+
import { CreateCurrentBitcodeWalletTransactionDto } from '../bitcode-wallet/dto/create-current-bitcode-wallet-transaction.dto';
|
|
4
7
|
import { TrainingStudentService } from '../enterprise/training/training-student.service';
|
|
8
|
+
import { UpdatePlatformaProfileDto } from './dto/update-profile.dto';
|
|
9
|
+
import { PlatformaService } from './platforma.service';
|
|
5
10
|
|
|
6
11
|
@NoRole()
|
|
7
12
|
@Controller('lms/platforma')
|
|
@@ -9,6 +14,8 @@ export class PlataformaController {
|
|
|
9
14
|
constructor(
|
|
10
15
|
private readonly trainingStudentService: TrainingStudentService,
|
|
11
16
|
private readonly notificationService: NotificationService,
|
|
17
|
+
private readonly platforma: PlatformaService,
|
|
18
|
+
private readonly bitcodeWalletService: BitcodeWalletService,
|
|
12
19
|
) {}
|
|
13
20
|
|
|
14
21
|
@Get()
|
|
@@ -74,6 +81,28 @@ export class PlataformaController {
|
|
|
74
81
|
return this.notificationService.markRead(userId, id);
|
|
75
82
|
}
|
|
76
83
|
|
|
84
|
+
@Get('notifications/stream')
|
|
85
|
+
streamNotifications(
|
|
86
|
+
@User('id') userId: number,
|
|
87
|
+
@Req() req: Request,
|
|
88
|
+
@Res() res: Response,
|
|
89
|
+
) {
|
|
90
|
+
return this.notificationService.stream(userId, req, res);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Delete('notifications/:id')
|
|
94
|
+
deleteNotification(
|
|
95
|
+
@User('id') userId: number,
|
|
96
|
+
@Param('id', ParseIntPipe) id: number,
|
|
97
|
+
) {
|
|
98
|
+
return this.notificationService.delete(userId, id);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Delete('notifications')
|
|
102
|
+
deleteAllNotifications(@User('id') userId: number) {
|
|
103
|
+
return this.notificationService.deleteAll(userId);
|
|
104
|
+
}
|
|
105
|
+
|
|
77
106
|
@Get('streak')
|
|
78
107
|
getStreak(
|
|
79
108
|
@User('id') userId: number,
|
|
@@ -89,4 +118,30 @@ export class PlataformaController {
|
|
|
89
118
|
) {
|
|
90
119
|
return this.trainingStudentService.registerStreakActivity(userId, body);
|
|
91
120
|
}
|
|
92
|
-
|
|
121
|
+
|
|
122
|
+
@Get('bitcodes/wallet')
|
|
123
|
+
getBitcodeWallet(@User('id') userId: number) {
|
|
124
|
+
return this.bitcodeWalletService.getCurrentUserWallet(userId);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Post('bitcodes/transactions')
|
|
128
|
+
createBitcodeTransaction(
|
|
129
|
+
@User('id') userId: number,
|
|
130
|
+
@Body() dto: CreateCurrentBitcodeWalletTransactionDto,
|
|
131
|
+
) {
|
|
132
|
+
return this.bitcodeWalletService.createCurrentUserTransaction(userId, dto);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Get('profile')
|
|
136
|
+
getProfile(@User('id') userId: number) {
|
|
137
|
+
return this.platforma.getProfile(userId);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@Put('profile')
|
|
141
|
+
updateProfile(
|
|
142
|
+
@User('id') userId: number,
|
|
143
|
+
@Body() dto: UpdatePlatformaProfileDto,
|
|
144
|
+
) {
|
|
145
|
+
return this.platforma.updateProfile(userId, dto);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { PrismaService } from '@hed-hog/api-prisma';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { UpdatePlatformaProfileDto } from './dto/update-profile.dto';
|
|
4
|
+
|
|
5
|
+
function mapGenderToDb(
|
|
6
|
+
gender?: string | null,
|
|
7
|
+
): 'male' | 'female' | 'other' | null {
|
|
8
|
+
if (!gender) return null;
|
|
9
|
+
if (gender === 'Masculino') return 'male';
|
|
10
|
+
if (gender === 'Feminino') return 'female';
|
|
11
|
+
return 'other';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function mapGenderToDisplay(gender?: string | null): string | null {
|
|
15
|
+
if (!gender) return null;
|
|
16
|
+
if (gender === 'male') return 'Masculino';
|
|
17
|
+
if (gender === 'female') return 'Feminino';
|
|
18
|
+
return 'Prefiro nao dizer';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildLine1(street?: string | null, number?: string | null): string {
|
|
22
|
+
if (!street && !number) return '';
|
|
23
|
+
if (!number) return street ?? '';
|
|
24
|
+
if (!street) return number;
|
|
25
|
+
return `${street}, ${number}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function buildLine2(
|
|
29
|
+
neighborhood?: string | null,
|
|
30
|
+
complement?: string | null,
|
|
31
|
+
): string {
|
|
32
|
+
const parts = [neighborhood, complement].filter(Boolean);
|
|
33
|
+
return parts.join('; ');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function parseAddressLine1(line1?: string | null): [string, string] {
|
|
37
|
+
if (!line1) return ['', ''];
|
|
38
|
+
const idx = line1.lastIndexOf(', ');
|
|
39
|
+
if (idx === -1) return [line1, ''];
|
|
40
|
+
return [line1.slice(0, idx), line1.slice(idx + 2)];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function parseAddressLine2(line2?: string | null): [string, string] {
|
|
44
|
+
if (!line2) return ['', ''];
|
|
45
|
+
const idx = line2.indexOf('; ');
|
|
46
|
+
if (idx === -1) return [line2, ''];
|
|
47
|
+
return [line2.slice(0, idx), line2.slice(idx + 2)];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Injectable()
|
|
51
|
+
export class PlatformaService {
|
|
52
|
+
constructor(private readonly prisma: PrismaService) {}
|
|
53
|
+
|
|
54
|
+
async getProfile(userId: number) {
|
|
55
|
+
const [user, personUser] = await Promise.all([
|
|
56
|
+
this.prisma.user.findUnique({ where: { id: userId } }),
|
|
57
|
+
this.prisma.person_user.findFirst({
|
|
58
|
+
where: { user_id: userId },
|
|
59
|
+
select: { person_id: true },
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
const personId = personUser?.person_id;
|
|
64
|
+
|
|
65
|
+
const [individual, contacts, documents, personAddresses] =
|
|
66
|
+
await Promise.all([
|
|
67
|
+
personId
|
|
68
|
+
? this.prisma.person_individual.findUnique({
|
|
69
|
+
where: { id: personId },
|
|
70
|
+
})
|
|
71
|
+
: Promise.resolve(null),
|
|
72
|
+
personId
|
|
73
|
+
? this.prisma.contact.findMany({
|
|
74
|
+
where: { person_id: personId },
|
|
75
|
+
include: { contact_type: true },
|
|
76
|
+
})
|
|
77
|
+
: Promise.resolve([]),
|
|
78
|
+
personId
|
|
79
|
+
? this.prisma.document.findMany({
|
|
80
|
+
where: { person_id: personId },
|
|
81
|
+
include: { document_type: true },
|
|
82
|
+
})
|
|
83
|
+
: Promise.resolve([]),
|
|
84
|
+
personId
|
|
85
|
+
? this.prisma.person_address.findMany({
|
|
86
|
+
where: { person_id: personId },
|
|
87
|
+
include: { address: true },
|
|
88
|
+
orderBy: { address: { is_primary: 'desc' } },
|
|
89
|
+
})
|
|
90
|
+
: Promise.resolve([]),
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const phoneContact = contacts.find((c) => c.contact_type.code === 'PHONE');
|
|
94
|
+
const cpfDoc = documents.find((d) => d.document_type.code === 'CPF');
|
|
95
|
+
const primaryAddress =
|
|
96
|
+
personAddresses.find((pa) => pa.address.is_primary)?.address ??
|
|
97
|
+
personAddresses[0]?.address;
|
|
98
|
+
|
|
99
|
+
const [street, number] = parseAddressLine1(primaryAddress?.line1);
|
|
100
|
+
const [neighborhood, complement] = parseAddressLine2(primaryAddress?.line2);
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
id: user?.id,
|
|
104
|
+
name: user?.name ?? null,
|
|
105
|
+
cpf: cpfDoc?.value ?? null,
|
|
106
|
+
dob: individual?.birth_date
|
|
107
|
+
? individual.birth_date.toISOString().slice(0, 10)
|
|
108
|
+
: null,
|
|
109
|
+
gender: mapGenderToDisplay(individual?.gender as string | null),
|
|
110
|
+
country: primaryAddress?.country_code ?? null,
|
|
111
|
+
city: primaryAddress?.city ?? null,
|
|
112
|
+
state: primaryAddress?.state ?? null,
|
|
113
|
+
neighborhood,
|
|
114
|
+
street,
|
|
115
|
+
number,
|
|
116
|
+
complement,
|
|
117
|
+
zip: primaryAddress?.postal_code ?? null,
|
|
118
|
+
phone: phoneContact?.value ?? null,
|
|
119
|
+
profession: individual?.job_title ?? null,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async updateProfile(userId: number, dto: UpdatePlatformaProfileDto) {
|
|
124
|
+
await this.prisma.$transaction(async (tx) => {
|
|
125
|
+
if (dto.name) {
|
|
126
|
+
await tx.user.update({
|
|
127
|
+
where: { id: userId },
|
|
128
|
+
data: { name: dto.name },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let personUser = await tx.person_user.findFirst({
|
|
133
|
+
where: { user_id: userId },
|
|
134
|
+
});
|
|
135
|
+
let personId: number;
|
|
136
|
+
|
|
137
|
+
if (!personUser) {
|
|
138
|
+
const user = await tx.user.findUnique({ where: { id: userId } });
|
|
139
|
+
const newPerson = await tx.person.create({
|
|
140
|
+
data: {
|
|
141
|
+
name: dto.name ?? user?.name ?? '',
|
|
142
|
+
type: 'individual',
|
|
143
|
+
status: 'active',
|
|
144
|
+
} as any,
|
|
145
|
+
});
|
|
146
|
+
await tx.person_user.create({
|
|
147
|
+
data: { person_id: newPerson.id, user_id: userId },
|
|
148
|
+
});
|
|
149
|
+
personId = newPerson.id;
|
|
150
|
+
} else {
|
|
151
|
+
personId = personUser.person_id;
|
|
152
|
+
if (dto.name) {
|
|
153
|
+
await tx.person.update({
|
|
154
|
+
where: { id: personId },
|
|
155
|
+
data: { name: dto.name },
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const individualData: Record<string, unknown> = {};
|
|
161
|
+
if (dto.dob !== undefined) {
|
|
162
|
+
individualData.birth_date = dto.dob ? new Date(dto.dob) : null;
|
|
163
|
+
}
|
|
164
|
+
if (dto.gender !== undefined) {
|
|
165
|
+
individualData.gender = mapGenderToDb(dto.gender);
|
|
166
|
+
}
|
|
167
|
+
if (dto.profession !== undefined) {
|
|
168
|
+
individualData.job_title = dto.profession || null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
await (tx as any).person_individual.upsert({
|
|
172
|
+
where: { id: personId },
|
|
173
|
+
create: { id: personId, ...individualData },
|
|
174
|
+
update: individualData,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const phoneType = await tx.contact_type.findFirst({
|
|
178
|
+
where: { code: 'PHONE' },
|
|
179
|
+
});
|
|
180
|
+
if (phoneType && dto.phone !== undefined) {
|
|
181
|
+
const existingPhone = await tx.contact.findFirst({
|
|
182
|
+
where: { person_id: personId, contact_type_id: phoneType.id },
|
|
183
|
+
});
|
|
184
|
+
if (dto.phone) {
|
|
185
|
+
if (existingPhone) {
|
|
186
|
+
await tx.contact.update({
|
|
187
|
+
where: { id: existingPhone.id },
|
|
188
|
+
data: { value: dto.phone },
|
|
189
|
+
});
|
|
190
|
+
} else {
|
|
191
|
+
await tx.contact.create({
|
|
192
|
+
data: {
|
|
193
|
+
person_id: personId,
|
|
194
|
+
contact_type_id: phoneType.id,
|
|
195
|
+
value: dto.phone,
|
|
196
|
+
is_primary: true,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
} else if (existingPhone) {
|
|
201
|
+
await tx.contact.delete({ where: { id: existingPhone.id } });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const cpfType = await tx.document_type.findFirst({
|
|
206
|
+
where: { code: 'CPF' },
|
|
207
|
+
});
|
|
208
|
+
if (cpfType && dto.cpf !== undefined) {
|
|
209
|
+
const existingCpf = await tx.document.findFirst({
|
|
210
|
+
where: { person_id: personId, document_type_id: cpfType.id },
|
|
211
|
+
});
|
|
212
|
+
if (dto.cpf) {
|
|
213
|
+
if (existingCpf) {
|
|
214
|
+
await tx.document.update({
|
|
215
|
+
where: { id: existingCpf.id },
|
|
216
|
+
data: { value: dto.cpf },
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
await tx.document.create({
|
|
220
|
+
data: {
|
|
221
|
+
person_id: personId,
|
|
222
|
+
document_type_id: cpfType.id,
|
|
223
|
+
value: dto.cpf,
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
} else if (existingCpf) {
|
|
228
|
+
await tx.document.delete({ where: { id: existingCpf.id } });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const hasAddressData =
|
|
233
|
+
dto.street || dto.city || dto.state || dto.zip || dto.country;
|
|
234
|
+
if (hasAddressData) {
|
|
235
|
+
const existingPersonAddress = await tx.person_address.findFirst({
|
|
236
|
+
where: { person_id: personId },
|
|
237
|
+
include: { address: true },
|
|
238
|
+
orderBy: { address: { is_primary: 'desc' } },
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const addressData = {
|
|
242
|
+
country_code: dto.country ?? '',
|
|
243
|
+
state: dto.state ?? '',
|
|
244
|
+
city: dto.city ?? '',
|
|
245
|
+
postal_code: (dto.zip ?? '').replace(/\D/g, ''),
|
|
246
|
+
line1: buildLine1(dto.street, dto.number),
|
|
247
|
+
line2: buildLine2(dto.neighborhood, dto.complement),
|
|
248
|
+
is_primary: true,
|
|
249
|
+
address_type: 'residential' as const,
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
if (existingPersonAddress) {
|
|
253
|
+
await tx.address.update({
|
|
254
|
+
where: { id: existingPersonAddress.address_id },
|
|
255
|
+
data: addressData,
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
const newAddress = await tx.address.create({ data: addressData });
|
|
259
|
+
await tx.person_address.create({
|
|
260
|
+
data: { person_id: personId, address_id: newAddress.id },
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
return { success: true };
|
|
267
|
+
}
|
|
268
|
+
}
|