@hed-hog/lms 0.0.364 → 0.0.365
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 +1 -0
- package/dist/bitcode-wallet/bitcode-wallet.service.d.ts.map +1 -1
- package/dist/bitcode-wallet/bitcode-wallet.service.js +22 -3
- package/dist/bitcode-wallet/bitcode-wallet.service.js.map +1 -1
- package/dist/course/course-export-scorm12-worker.service.d.ts +21 -0
- package/dist/course/course-export-scorm12-worker.service.d.ts.map +1 -0
- package/dist/course/course-export-scorm12-worker.service.js +109 -0
- package/dist/course/course-export-scorm12-worker.service.js.map +1 -0
- package/dist/course/course-export-scorm12.service.d.ts +42 -0
- package/dist/course/course-export-scorm12.service.d.ts.map +1 -0
- package/dist/course/course-export-scorm12.service.js +628 -0
- package/dist/course/course-export-scorm12.service.js.map +1 -0
- package/dist/course/course-export.service.d.ts +84 -0
- package/dist/course/course-export.service.d.ts.map +1 -0
- package/dist/course/course-export.service.js +237 -0
- package/dist/course/course-export.service.js.map +1 -0
- package/dist/course/course-structure.controller.d.ts +17 -9
- package/dist/course/course-structure.controller.d.ts.map +1 -1
- package/dist/course/course-structure.controller.js +17 -4
- package/dist/course/course-structure.controller.js.map +1 -1
- package/dist/course/course-structure.service.d.ts +12 -4
- package/dist/course/course-structure.service.d.ts.map +1 -1
- package/dist/course/course-structure.service.js +98 -23
- package/dist/course/course-structure.service.js.map +1 -1
- package/dist/course/course-video-hls.service.d.ts +57 -0
- package/dist/course/course-video-hls.service.d.ts.map +1 -0
- package/dist/course/course-video-hls.service.js +767 -0
- package/dist/course/course-video-hls.service.js.map +1 -0
- package/dist/course/course.controller.d.ts +45 -13
- package/dist/course/course.controller.d.ts.map +1 -1
- package/dist/course/course.controller.js +40 -26
- package/dist/course/course.controller.js.map +1 -1
- package/dist/course/course.mcp-tools.js +1 -1
- package/dist/course/course.mcp-tools.js.map +1 -1
- package/dist/course/course.module.d.ts.map +1 -1
- package/dist/course/course.module.js +11 -0
- package/dist/course/course.module.js.map +1 -1
- package/dist/course/course.service.d.ts +6 -9
- package/dist/course/course.service.d.ts.map +1 -1
- package/dist/course/course.service.js +57 -48
- package/dist/course/course.service.js.map +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.d.ts +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.d.ts.map +1 -1
- package/dist/course/dto/cleanup-course-storage.dto.js +1 -0
- package/dist/course/dto/cleanup-course-storage.dto.js.map +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.d.ts +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.d.ts.map +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.js +1 -1
- package/dist/course/dto/cleanup-upload-history.dto.js.map +1 -1
- package/dist/course/dto/create-course-bulk-job.dto.d.ts +2 -1
- package/dist/course/dto/create-course-bulk-job.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-bulk-job.dto.js +6 -1
- package/dist/course/dto/create-course-bulk-job.dto.js.map +1 -1
- package/dist/course/dto/create-course-export.dto.d.ts +14 -0
- package/dist/course/dto/create-course-export.dto.d.ts.map +1 -0
- package/dist/course/dto/create-course-export.dto.js +71 -0
- package/dist/course/dto/create-course-export.dto.js.map +1 -0
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts +2 -2
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-structure-lesson.dto.js +3 -2
- package/dist/course/dto/create-course-structure-lesson.dto.js.map +1 -1
- package/dist/course/lms-bulk-upload-automation.service.d.ts +16 -1
- package/dist/course/lms-bulk-upload-automation.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload-automation.service.js +102 -8
- package/dist/course/lms-bulk-upload-automation.service.js.map +1 -1
- package/dist/course/lms-bulk-upload-infra.service.d.ts +1 -0
- package/dist/course/lms-bulk-upload-infra.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload-infra.service.js +32 -8
- package/dist/course/lms-bulk-upload-infra.service.js.map +1 -1
- package/dist/course/lms-bulk-upload.controller.d.ts +30 -3
- package/dist/course/lms-bulk-upload.controller.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload.controller.js +43 -2
- package/dist/course/lms-bulk-upload.controller.js.map +1 -1
- package/dist/course/lms-bulk-upload.service.d.ts +11 -0
- package/dist/course/lms-bulk-upload.service.d.ts.map +1 -1
- package/dist/course/lms-bulk-upload.service.js +59 -6
- package/dist/course/lms-bulk-upload.service.js.map +1 -1
- package/dist/course/lms-setting.controller.d.ts +2 -1
- package/dist/course/lms-setting.controller.d.ts.map +1 -1
- package/dist/course/lms-setting.controller.js +4 -2
- package/dist/course/lms-setting.controller.js.map +1 -1
- package/dist/course/scorm12-schemas.d.ts +4 -0
- package/dist/course/scorm12-schemas.d.ts.map +1 -0
- package/dist/course/scorm12-schemas.js +9 -0
- package/dist/course/scorm12-schemas.js.map +1 -0
- package/dist/enterprise/training/training-student.service.d.ts +51 -0
- package/dist/enterprise/training/training-student.service.d.ts.map +1 -1
- package/dist/enterprise/training/training-student.service.js +217 -4
- package/dist/enterprise/training/training-student.service.js.map +1 -1
- package/dist/evaluation/evaluation.service.d.ts +18 -0
- package/dist/evaluation/evaluation.service.d.ts.map +1 -1
- package/dist/evaluation/evaluation.service.js +125 -0
- package/dist/evaluation/evaluation.service.js.map +1 -1
- package/dist/exam/dto/create-standalone-question.dto.d.ts +12 -0
- package/dist/exam/dto/create-standalone-question.dto.d.ts.map +1 -0
- package/dist/exam/dto/create-standalone-question.dto.js +70 -0
- package/dist/exam/dto/create-standalone-question.dto.js.map +1 -0
- package/dist/exam/exam.module.d.ts.map +1 -1
- package/dist/exam/exam.module.js +2 -1
- package/dist/exam/exam.module.js.map +1 -1
- package/dist/exam/exam.service.d.ts +21 -0
- package/dist/exam/exam.service.d.ts.map +1 -1
- package/dist/exam/exam.service.js +80 -0
- package/dist/exam/exam.service.js.map +1 -1
- package/dist/exam/question.controller.d.ts +27 -0
- package/dist/exam/question.controller.d.ts.map +1 -0
- package/dist/exam/question.controller.js +53 -0
- package/dist/exam/question.controller.js.map +1 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts +4 -0
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.d.ts.map +1 -1
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js +161 -25
- package/dist/lesson-xp-map/lesson-xp-ai-calculation.service.js.map +1 -1
- package/dist/libraries/lms/tsconfig.tsbuildinfo +1 -1
- package/dist/lms-commerce-access.subscriber.d.ts +11 -0
- package/dist/lms-commerce-access.subscriber.d.ts.map +1 -0
- package/dist/lms-commerce-access.subscriber.js +74 -0
- package/dist/lms-commerce-access.subscriber.js.map +1 -0
- package/dist/lms.module.d.ts.map +1 -1
- package/dist/lms.module.js +6 -5
- package/dist/lms.module.js.map +1 -1
- package/dist/platforma/platforma-video.service.d.ts +39 -0
- package/dist/platforma/platforma-video.service.d.ts.map +1 -0
- package/dist/platforma/platforma-video.service.js +301 -0
- package/dist/platforma/platforma-video.service.js.map +1 -0
- package/dist/platforma/platforma.controller.d.ts +95 -1
- package/dist/platforma/platforma.controller.d.ts.map +1 -1
- package/dist/platforma/platforma.controller.js +160 -2
- package/dist/platforma/platforma.controller.js.map +1 -1
- package/dist/student-xp/dto/grant-skill-card-xp.dto.d.ts +5 -0
- package/dist/student-xp/dto/grant-skill-card-xp.dto.d.ts.map +1 -0
- package/dist/student-xp/dto/grant-skill-card-xp.dto.js +26 -0
- package/dist/student-xp/dto/grant-skill-card-xp.dto.js.map +1 -0
- package/dist/student-xp/student-xp.controller.d.ts +15 -0
- package/dist/student-xp/student-xp.controller.d.ts.map +1 -1
- package/dist/student-xp/student-xp.controller.js +24 -0
- package/dist/student-xp/student-xp.controller.js.map +1 -1
- package/dist/student-xp/student-xp.service.d.ts +16 -0
- package/dist/student-xp/student-xp.service.d.ts.map +1 -1
- package/dist/student-xp/student-xp.service.js +51 -1
- package/dist/student-xp/student-xp.service.js.map +1 -1
- package/hedhog/data/evaluation_topic.yaml +17 -0
- package/hedhog/data/menu.yaml +0 -17
- package/hedhog/data/queue_definition.yaml +48 -0
- package/hedhog/data/route.yaml +94 -124
- package/hedhog/data/setting_group.yaml +19 -19
- package/hedhog/frontend/app/bulk-upload-sessions/page.tsx.ejs +337 -41
- package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +69 -4
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-export-sheet.tsx.ejs +420 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-exports-tab.tsx.ejs +308 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/course-overview-tab.tsx.ejs +17 -15
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +51 -63
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-panel.tsx.ejs +8 -3
- package/hedhog/frontend/app/courses/[id]/structure/_components/detail-session.tsx.ejs +31 -8
- package/hedhog/frontend/app/courses/[id]/structure/_components/drag-overlay.tsx.ejs +16 -9
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +201 -401
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-lesson.tsx.ejs +378 -690
- package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +1 -2
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-lesson.tsx.ejs +3 -9
- package/hedhog/frontend/app/courses/[id]/structure/_components/types.ts.ejs +1 -1
- package/hedhog/frontend/app/courses/[id]/structure/_data/adapters/course-structure.adapter.ts.ejs +6 -10
- package/hedhog/frontend/app/courses/[id]/structure/_data/services/course-structure.service.ts.ejs +49 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/types/api-course.types.ts.ejs +4 -3
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-content-overview.ts.ejs +0 -1
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-exports.ts.ejs +106 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-mutations.ts.ejs +28 -1
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-lms-settings-query.ts.ejs +0 -2
- package/hedhog/frontend/app/courses/page.tsx.ejs +45 -0
- package/hedhog/frontend/messages/en.json +26 -28
- package/hedhog/frontend/messages/pt.json +26 -28
- package/hedhog/table/course_export.yaml +62 -0
- package/package.json +13 -9
- package/src/bitcode-wallet/bitcode-wallet.service.ts +43 -4
- package/src/course/course-export-scorm12-worker.service.ts +124 -0
- package/src/course/course-export-scorm12.service.ts +668 -0
- package/src/course/course-export.service.ts +280 -0
- package/src/course/course-structure.controller.ts +14 -2
- package/src/course/course-structure.service.ts +100 -7
- package/src/course/course-video-hls.service.ts +946 -0
- package/src/course/course.controller.ts +33 -19
- package/src/course/course.mcp-tools.ts +1 -1
- package/src/course/course.module.ts +11 -0
- package/src/course/course.service.ts +73 -60
- package/src/course/dto/cleanup-course-storage.dto.ts +1 -0
- package/src/course/dto/cleanup-upload-history.dto.ts +1 -1
- package/src/course/dto/create-course-bulk-job.dto.ts +7 -3
- package/src/course/dto/create-course-export.dto.ts +56 -0
- package/src/course/dto/create-course-structure-lesson.dto.ts +4 -3
- package/src/course/lms-bulk-upload-automation.service.ts +153 -6
- package/src/course/lms-bulk-upload-infra.service.ts +39 -6
- package/src/course/lms-bulk-upload.controller.ts +32 -2
- package/src/course/lms-bulk-upload.service.ts +70 -7
- package/src/course/lms-setting.controller.ts +4 -2
- package/src/course/scorm12-schemas.ts +9 -0
- package/src/enterprise/training/training-student.service.ts +221 -2
- package/src/evaluation/evaluation.service.ts +123 -0
- package/src/exam/dto/create-standalone-question.dto.ts +66 -0
- package/src/exam/exam.module.ts +2 -1
- package/src/exam/exam.service.ts +86 -0
- package/src/exam/question.controller.ts +28 -0
- package/src/lesson-xp-map/lesson-xp-ai-calculation.service.ts +205 -31
- package/src/lms-commerce-access.subscriber.ts +88 -0
- package/src/lms.module.ts +6 -5
- package/src/platforma/platforma-video.service.ts +346 -0
- package/src/platforma/platforma.controller.ts +95 -1
- package/src/platforma/platforma.service.ts +268 -268
- package/src/student-xp/dto/grant-skill-card-xp.dto.ts +10 -0
- package/src/student-xp/student-xp.controller.ts +18 -2
- package/src/student-xp/student-xp.service.ts +84 -2
- package/hedhog/data/video_resolution_profile.yaml +0 -7
- package/hedhog/frontend/app/video-resolution-profiles/page.tsx.ejs +0 -607
- package/hedhog/table/course_video_resolution_profile.yaml +0 -22
- package/hedhog/table/video_resolution_profile.yaml +0 -18
- package/src/video-resolution-profile/dto/create-video-resolution-profile.dto.ts +0 -16
- package/src/video-resolution-profile/dto/update-video-resolution-profile.dto.ts +0 -16
- package/src/video-resolution-profile/video-resolution-profile.controller.ts +0 -62
- package/src/video-resolution-profile/video-resolution-profile.mcp-tools.ts +0 -128
- package/src/video-resolution-profile/video-resolution-profile.module.ts +0 -13
- package/src/video-resolution-profile/video-resolution-profile.service.ts +0 -117
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { PrismaService } from '@hed-hog/api-prisma';
|
|
2
|
+
import {
|
|
3
|
+
FileService,
|
|
4
|
+
NotificationActionType,
|
|
5
|
+
NotificationService,
|
|
6
|
+
NotificationType,
|
|
7
|
+
} from '@hed-hog/core';
|
|
8
|
+
import { QueueJobService } from '@hed-hog/queue';
|
|
9
|
+
import {
|
|
10
|
+
BadRequestException,
|
|
11
|
+
Inject,
|
|
12
|
+
Injectable,
|
|
13
|
+
NotFoundException,
|
|
14
|
+
forwardRef,
|
|
15
|
+
} from '@nestjs/common';
|
|
16
|
+
import { CreateCourseExportDto } from './dto/create-course-export.dto';
|
|
17
|
+
|
|
18
|
+
export const LMS_COURSE_EXPORT_SCORM12_JOB = 'lms.course.export.scorm12';
|
|
19
|
+
|
|
20
|
+
export type VideoLessonWithFile = {
|
|
21
|
+
id: number;
|
|
22
|
+
title: string;
|
|
23
|
+
order: number;
|
|
24
|
+
content: string | null;
|
|
25
|
+
duration_seconds: number | null;
|
|
26
|
+
session: {
|
|
27
|
+
id: number;
|
|
28
|
+
title: string;
|
|
29
|
+
order: number;
|
|
30
|
+
};
|
|
31
|
+
files: {
|
|
32
|
+
id: number;
|
|
33
|
+
file_id: number | null;
|
|
34
|
+
type: string;
|
|
35
|
+
file: {
|
|
36
|
+
id: number;
|
|
37
|
+
path: string;
|
|
38
|
+
size: number | null;
|
|
39
|
+
} | null;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
@Injectable()
|
|
44
|
+
export class CourseExportService {
|
|
45
|
+
constructor(
|
|
46
|
+
@Inject(forwardRef(() => PrismaService))
|
|
47
|
+
private readonly prisma: PrismaService,
|
|
48
|
+
@Inject(forwardRef(() => QueueJobService))
|
|
49
|
+
private readonly queueJob: QueueJobService,
|
|
50
|
+
@Inject(forwardRef(() => NotificationService))
|
|
51
|
+
private readonly notificationService: NotificationService,
|
|
52
|
+
@Inject(forwardRef(() => FileService))
|
|
53
|
+
private readonly fileService: FileService,
|
|
54
|
+
) {}
|
|
55
|
+
|
|
56
|
+
async deleteExport(courseId: number, exportId: number): Promise<void> {
|
|
57
|
+
const record = await this.prisma.course_export.findUnique({
|
|
58
|
+
where: { id: exportId },
|
|
59
|
+
select: { id: true, course_id: true, status: true, file_id: true },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (!record || record.course_id !== courseId) {
|
|
63
|
+
throw new NotFoundException('Exportação não encontrada.');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (record.status === 'pending' || record.status === 'processing') {
|
|
67
|
+
throw new BadRequestException(
|
|
68
|
+
'Não é possível excluir uma exportação em andamento.',
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (record.file_id) {
|
|
73
|
+
await this.fileService
|
|
74
|
+
.delete('pt', { ids: [record.file_id] })
|
|
75
|
+
.catch(() => undefined);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
await this.prisma.course_export.delete({ where: { id: exportId } });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async listExports(courseId: number) {
|
|
82
|
+
return this.prisma.course_export.findMany({
|
|
83
|
+
where: { course_id: courseId },
|
|
84
|
+
orderBy: { created_at: 'desc' },
|
|
85
|
+
include: {
|
|
86
|
+
user: {
|
|
87
|
+
select: {
|
|
88
|
+
id: true,
|
|
89
|
+
name: true,
|
|
90
|
+
photo_id: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
file: {
|
|
94
|
+
select: {
|
|
95
|
+
id: true,
|
|
96
|
+
path: true,
|
|
97
|
+
filename: true,
|
|
98
|
+
size: true,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async enqueueScorm12Export(
|
|
106
|
+
courseId: number,
|
|
107
|
+
userId: number,
|
|
108
|
+
dto: CreateCourseExportDto,
|
|
109
|
+
) {
|
|
110
|
+
const settings = {
|
|
111
|
+
visual: { ...(dto.visualSettings ?? {}) },
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const exportRecord = await this.prisma.course_export.create({
|
|
115
|
+
data: {
|
|
116
|
+
course_id: courseId,
|
|
117
|
+
user_id: userId,
|
|
118
|
+
format: dto.format,
|
|
119
|
+
status: 'pending',
|
|
120
|
+
settings,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const course = await this.prisma.course.findUnique({
|
|
125
|
+
where: { id: courseId },
|
|
126
|
+
select: { title: true, name: true },
|
|
127
|
+
});
|
|
128
|
+
const courseTitle = course?.title || course?.name || `Curso ${courseId}`;
|
|
129
|
+
|
|
130
|
+
const notification = await this.notificationService.create({
|
|
131
|
+
user_id: userId,
|
|
132
|
+
title: `Exportando "${courseTitle}" — SCORM 1.2`,
|
|
133
|
+
body: 'Aguardando início do processamento...',
|
|
134
|
+
type: NotificationType.Progress,
|
|
135
|
+
progress: 1,
|
|
136
|
+
auto_remove: false,
|
|
137
|
+
action_type: NotificationActionType.Url,
|
|
138
|
+
action_url: `/lms/courses/${courseId}?tab=exportacoes`,
|
|
139
|
+
started_at: new Date().toISOString(),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const job = await this.queueJob.enqueue(
|
|
143
|
+
{
|
|
144
|
+
type: LMS_COURSE_EXPORT_SCORM12_JOB,
|
|
145
|
+
queueName: LMS_COURSE_EXPORT_SCORM12_JOB,
|
|
146
|
+
payload: {
|
|
147
|
+
exportId: exportRecord.id,
|
|
148
|
+
courseId,
|
|
149
|
+
userId,
|
|
150
|
+
notificationId: notification.id,
|
|
151
|
+
settings,
|
|
152
|
+
},
|
|
153
|
+
sourceModule: 'lms',
|
|
154
|
+
sourceEntity: 'course_export',
|
|
155
|
+
sourceEntityId: String(exportRecord.id),
|
|
156
|
+
maxAttempts: 3,
|
|
157
|
+
},
|
|
158
|
+
userId,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
await this.prisma.course_export.update({
|
|
162
|
+
where: { id: exportRecord.id },
|
|
163
|
+
data: {
|
|
164
|
+
queue_job_id: job.id,
|
|
165
|
+
notification_id: notification.id,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
exportId: exportRecord.id,
|
|
171
|
+
queueJobId: job.id,
|
|
172
|
+
notificationId: notification.id,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async markStarted(exportId: number) {
|
|
177
|
+
await this.prisma.course_export.update({
|
|
178
|
+
where: { id: exportId },
|
|
179
|
+
data: {
|
|
180
|
+
status: 'processing',
|
|
181
|
+
started_at: new Date(),
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async markCompleted(
|
|
187
|
+
exportId: number,
|
|
188
|
+
fileId: number,
|
|
189
|
+
durationSeconds: number,
|
|
190
|
+
) {
|
|
191
|
+
await this.prisma.course_export.update({
|
|
192
|
+
where: { id: exportId },
|
|
193
|
+
data: {
|
|
194
|
+
status: 'completed',
|
|
195
|
+
file_id: fileId,
|
|
196
|
+
duration_seconds: durationSeconds,
|
|
197
|
+
finished_at: new Date(),
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async markFailed(exportId: number, errorMessage: string) {
|
|
203
|
+
await this.prisma.course_export.update({
|
|
204
|
+
where: { id: exportId },
|
|
205
|
+
data: {
|
|
206
|
+
status: 'failed',
|
|
207
|
+
error_message: errorMessage,
|
|
208
|
+
finished_at: new Date(),
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async getCourseVideoLessons(courseId: number): Promise<VideoLessonWithFile[]> {
|
|
214
|
+
const lessons = await this.prisma.course_lesson.findMany({
|
|
215
|
+
where: {
|
|
216
|
+
type: 'video',
|
|
217
|
+
course_module: {
|
|
218
|
+
course_id: courseId,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
orderBy: [
|
|
222
|
+
{ course_module: { order: 'asc' } },
|
|
223
|
+
{ order: 'asc' },
|
|
224
|
+
],
|
|
225
|
+
include: {
|
|
226
|
+
course_module: {
|
|
227
|
+
select: { id: true, title: true, order: true },
|
|
228
|
+
},
|
|
229
|
+
course_lesson_file: {
|
|
230
|
+
where: {
|
|
231
|
+
type: {
|
|
232
|
+
in: ['video_original', 'video_hls', 'video_profile:720p', 'video_profile:1080p'],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
include: {
|
|
236
|
+
file: {
|
|
237
|
+
select: { id: true, path: true, size: true },
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
orderBy: { id: 'asc' },
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return lessons.map((l) => ({
|
|
246
|
+
id: l.id,
|
|
247
|
+
title: l.title,
|
|
248
|
+
order: l.order,
|
|
249
|
+
content: l.content,
|
|
250
|
+
duration_seconds: l.duration_seconds,
|
|
251
|
+
session: {
|
|
252
|
+
id: l.course_module.id,
|
|
253
|
+
title: l.course_module.title,
|
|
254
|
+
order: l.course_module.order,
|
|
255
|
+
},
|
|
256
|
+
files: l.course_lesson_file.map((f) => ({
|
|
257
|
+
id: f.id,
|
|
258
|
+
file_id: f.file_id,
|
|
259
|
+
type: f.type,
|
|
260
|
+
file: f.file
|
|
261
|
+
? { id: f.file.id, path: f.file.path, size: f.file.size }
|
|
262
|
+
: null,
|
|
263
|
+
})),
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
getBestVideoFile(lesson: VideoLessonWithFile) {
|
|
268
|
+
const priority = [
|
|
269
|
+
'video_profile:720p',
|
|
270
|
+
'video_profile:1080p',
|
|
271
|
+
'video_original',
|
|
272
|
+
'video_hls',
|
|
273
|
+
];
|
|
274
|
+
for (const p of priority) {
|
|
275
|
+
const f = lesson.files.find((f) => f.type === p && f.file_id && f.file);
|
|
276
|
+
if (f) return f;
|
|
277
|
+
}
|
|
278
|
+
return lesson.files.find((f) => f.file_id && f.file) ?? null;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from '@nestjs/common';
|
|
12
12
|
import { CourseStructureService } from './course-structure.service';
|
|
13
13
|
import { CourseVideoConversionService } from './course-video-conversion.service';
|
|
14
|
+
import { CourseVideoHlsService } from './course-video-hls.service';
|
|
14
15
|
import { CreateCourseBulkJobDto } from './dto/create-course-bulk-job.dto';
|
|
15
16
|
import { CreateCourseLessonFrameDto } from './dto/create-course-lesson-frame.dto';
|
|
16
17
|
import {
|
|
@@ -33,6 +34,7 @@ export class CourseStructureController {
|
|
|
33
34
|
constructor(
|
|
34
35
|
private readonly courseStructureService: CourseStructureService,
|
|
35
36
|
private readonly courseVideoConversionService: CourseVideoConversionService,
|
|
37
|
+
private readonly courseVideoHlsService: CourseVideoHlsService,
|
|
36
38
|
) {}
|
|
37
39
|
|
|
38
40
|
@Get()
|
|
@@ -160,7 +162,7 @@ export class CourseStructureController {
|
|
|
160
162
|
@Param('lessonId', ParseIntPipe) lessonId: number,
|
|
161
163
|
@Body() dto: CreateLessonVideoConversionDto,
|
|
162
164
|
) {
|
|
163
|
-
return this.
|
|
165
|
+
return this.courseVideoHlsService.enqueueHls({
|
|
164
166
|
userId,
|
|
165
167
|
courseId,
|
|
166
168
|
sessionId,
|
|
@@ -229,12 +231,22 @@ export class CourseStructureController {
|
|
|
229
231
|
return this.courseStructureService.duplicateLesson(courseId, sessionId, lessonId);
|
|
230
232
|
}
|
|
231
233
|
|
|
234
|
+
@Get('video-processing-stats')
|
|
235
|
+
getVideoProcessingStats(@Param('id', ParseIntPipe) courseId: number) {
|
|
236
|
+
return this.courseStructureService.getVideoProcessingStats(courseId);
|
|
237
|
+
}
|
|
238
|
+
|
|
232
239
|
@Post('bulk-jobs')
|
|
233
240
|
createBulkJobs(
|
|
234
241
|
@User() user: any,
|
|
235
242
|
@Param('id', ParseIntPipe) courseId: number,
|
|
236
243
|
@Body() dto: CreateCourseBulkJobDto,
|
|
237
244
|
) {
|
|
238
|
-
return this.courseStructureService.bulkEnqueueJobs(
|
|
245
|
+
return this.courseStructureService.bulkEnqueueJobs(
|
|
246
|
+
courseId,
|
|
247
|
+
dto.jobType,
|
|
248
|
+
user?.id ?? 0,
|
|
249
|
+
dto.reprocessAlreadyProcessed,
|
|
250
|
+
);
|
|
239
251
|
}
|
|
240
252
|
}
|
|
@@ -4,6 +4,7 @@ import { QueueJobService } from '@hed-hog/queue';
|
|
|
4
4
|
import { BadRequestException, Injectable, Logger, NotFoundException } from '@nestjs/common';
|
|
5
5
|
import { InstructorService } from '../instructor/instructor.service';
|
|
6
6
|
import { CourseOperationsIntegrationService } from './course-operations-integration.service';
|
|
7
|
+
import { CourseVideoHlsService } from './course-video-hls.service';
|
|
7
8
|
import { CreateCourseLessonFrameDto } from './dto/create-course-lesson-frame.dto';
|
|
8
9
|
import { CreateCourseStructureLessonDto } from './dto/create-course-structure-lesson.dto';
|
|
9
10
|
import { CreateCourseStructureSessionDto } from './dto/create-course-structure-session.dto';
|
|
@@ -17,7 +18,7 @@ import { UpdateCourseStructureLessonDto } from './dto/update-course-structure-le
|
|
|
17
18
|
import { UpdateCourseStructureSessionDto } from './dto/update-course-structure-session.dto';
|
|
18
19
|
import { UpdateTranscriptionSegmentsDTO } from './dto/update-transcription-segments.dto';
|
|
19
20
|
|
|
20
|
-
type LessonUiType = 'video' | 'questao' | 'post'
|
|
21
|
+
type LessonUiType = 'video' | 'questao' | 'post';
|
|
21
22
|
type LessonDbType = 'video' | 'text' | 'quiz';
|
|
22
23
|
type LessonProductionStatus =
|
|
23
24
|
| 'preparada'
|
|
@@ -27,6 +28,7 @@ type LessonProductionStatus =
|
|
|
27
28
|
| 'publicada';
|
|
28
29
|
type LessonFileType =
|
|
29
30
|
| 'video_original'
|
|
31
|
+
| 'video_hls'
|
|
30
32
|
| `video_profile:${number}`
|
|
31
33
|
| 'lesson_audio'
|
|
32
34
|
| 'student_download'
|
|
@@ -42,6 +44,7 @@ export class CourseStructureService {
|
|
|
42
44
|
private readonly instructorService: InstructorService,
|
|
43
45
|
private readonly operationsIntegration: CourseOperationsIntegrationService,
|
|
44
46
|
private readonly queueJob: QueueJobService,
|
|
47
|
+
private readonly courseVideoHlsService: CourseVideoHlsService,
|
|
45
48
|
) {}
|
|
46
49
|
|
|
47
50
|
async getStructure(courseId: number) {
|
|
@@ -102,6 +105,7 @@ export class CourseStructureService {
|
|
|
102
105
|
title: true,
|
|
103
106
|
description: true,
|
|
104
107
|
offering_type: true,
|
|
108
|
+
status: true,
|
|
105
109
|
},
|
|
106
110
|
}),
|
|
107
111
|
this.operationsIntegration.getCourseProjectLinks([courseId]),
|
|
@@ -146,7 +150,7 @@ export class CourseStructureService {
|
|
|
146
150
|
videoUrl: parsedContent?.videoUrl,
|
|
147
151
|
duracaoAutomatica: parsedContent?.duracaoAutomatica,
|
|
148
152
|
transcricao: parsedContent?.transcricao,
|
|
149
|
-
videoConversionJobId: parsedContent?.videoConversionJobId,
|
|
153
|
+
videoConversionJobId: parsedContent?.videoConversionJobId ?? parsedContent?.videoHlsJobId,
|
|
150
154
|
exameVinculado:
|
|
151
155
|
parsedContent?.exameVinculado != null
|
|
152
156
|
? String(parsedContent.exameVinculado)
|
|
@@ -203,6 +207,7 @@ export class CourseStructureService {
|
|
|
203
207
|
titulo: courseRecord.title,
|
|
204
208
|
descricao: courseRecord.description ?? '',
|
|
205
209
|
offeringType: courseRecord.offering_type ?? 'on_demand',
|
|
210
|
+
status: courseRecord.status ?? 'draft',
|
|
206
211
|
recursos: courseResources,
|
|
207
212
|
operationsProjectId: courseProject?.projectId ?? null,
|
|
208
213
|
operationsProjectCode: courseProject?.projectCode ?? null,
|
|
@@ -1226,10 +1231,48 @@ export class CourseStructureService {
|
|
|
1226
1231
|
return true;
|
|
1227
1232
|
}
|
|
1228
1233
|
|
|
1234
|
+
async getVideoProcessingStats(courseId: number): Promise<{
|
|
1235
|
+
withOriginal: number;
|
|
1236
|
+
withoutOriginal: number;
|
|
1237
|
+
alreadyProcessed: number;
|
|
1238
|
+
}> {
|
|
1239
|
+
const lessons = await (this.prisma as any).course_lesson.findMany({
|
|
1240
|
+
where: {
|
|
1241
|
+
type: 'video',
|
|
1242
|
+
course_module: { course_id: courseId },
|
|
1243
|
+
},
|
|
1244
|
+
select: {
|
|
1245
|
+
id: true,
|
|
1246
|
+
course_lesson_file: { select: { type: true } },
|
|
1247
|
+
},
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
let withOriginal = 0;
|
|
1251
|
+
let withoutOriginal = 0;
|
|
1252
|
+
let alreadyProcessed = 0;
|
|
1253
|
+
|
|
1254
|
+
for (const lesson of lessons) {
|
|
1255
|
+
const files: { type: string }[] = lesson.course_lesson_file;
|
|
1256
|
+
const hasOriginal = files.some((f) => f.type === 'video_original');
|
|
1257
|
+
if (!hasOriginal) {
|
|
1258
|
+
withoutOriginal++;
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
withOriginal++;
|
|
1262
|
+
const hasProcessed = files.some(
|
|
1263
|
+
(f) => f.type === 'video_hls' || f.type.startsWith('video_profile:'),
|
|
1264
|
+
);
|
|
1265
|
+
if (hasProcessed) alreadyProcessed++;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
return { withOriginal, withoutOriginal, alreadyProcessed };
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1229
1271
|
async bulkEnqueueJobs(
|
|
1230
1272
|
courseId: number,
|
|
1231
|
-
jobType: 'transcription' | 'xp_recalculation',
|
|
1273
|
+
jobType: 'transcription' | 'xp_recalculation' | 'video_processing',
|
|
1232
1274
|
userId: number,
|
|
1275
|
+
reprocessAlreadyProcessed?: boolean,
|
|
1233
1276
|
): Promise<{
|
|
1234
1277
|
queued: number;
|
|
1235
1278
|
skipped: number;
|
|
@@ -1273,6 +1316,53 @@ export class CourseStructureService {
|
|
|
1273
1316
|
});
|
|
1274
1317
|
queued++;
|
|
1275
1318
|
}
|
|
1319
|
+
} else if (jobType === 'video_processing') {
|
|
1320
|
+
const videoLessons = await (this.prisma as any).course_lesson.findMany({
|
|
1321
|
+
where: {
|
|
1322
|
+
type: 'video',
|
|
1323
|
+
course_module: { course_id: courseId },
|
|
1324
|
+
},
|
|
1325
|
+
select: {
|
|
1326
|
+
id: true,
|
|
1327
|
+
course_module_id: true,
|
|
1328
|
+
course_lesson_file: { select: { type: true, file_id: true } },
|
|
1329
|
+
},
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
for (const lesson of videoLessons) {
|
|
1333
|
+
const files: { type: string; file_id: number }[] = lesson.course_lesson_file;
|
|
1334
|
+
const originalFile = files.find((f) => f.type === 'video_original');
|
|
1335
|
+
|
|
1336
|
+
if (!originalFile) {
|
|
1337
|
+
skipped++;
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
const isAlreadyProcessed = files.some(
|
|
1342
|
+
(f) => f.type === 'video_hls' || f.type.startsWith('video_profile:'),
|
|
1343
|
+
);
|
|
1344
|
+
|
|
1345
|
+
if (isAlreadyProcessed && !reprocessAlreadyProcessed) {
|
|
1346
|
+
skipped++;
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
try {
|
|
1351
|
+
await this.courseVideoHlsService.enqueueHls({
|
|
1352
|
+
userId,
|
|
1353
|
+
courseId,
|
|
1354
|
+
sessionId: lesson.course_module_id,
|
|
1355
|
+
lessonId: lesson.id,
|
|
1356
|
+
originalFileId: originalFile.file_id,
|
|
1357
|
+
});
|
|
1358
|
+
queued++;
|
|
1359
|
+
} catch (err: unknown) {
|
|
1360
|
+
this.logger.warn(
|
|
1361
|
+
`bulkEnqueueJobs(video_processing): skipped lesson ${lesson.id} — ${err instanceof Error ? err.message : String(err)}`,
|
|
1362
|
+
);
|
|
1363
|
+
skipped++;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1276
1366
|
} else {
|
|
1277
1367
|
for (const lesson of lessons) {
|
|
1278
1368
|
const segments = await (this.prisma as any).course_lesson_transcription_segment.findFirst({
|
|
@@ -1465,7 +1555,7 @@ export class CourseStructureService {
|
|
|
1465
1555
|
videoUrl: parsedContent?.videoUrl,
|
|
1466
1556
|
duracaoAutomatica: parsedContent?.duracaoAutomatica,
|
|
1467
1557
|
transcricao: parsedContent?.transcricao,
|
|
1468
|
-
videoConversionJobId: parsedContent?.videoConversionJobId,
|
|
1558
|
+
videoConversionJobId: parsedContent?.videoConversionJobId ?? parsedContent?.videoHlsJobId,
|
|
1469
1559
|
exameVinculado:
|
|
1470
1560
|
parsedContent?.exameVinculado != null
|
|
1471
1561
|
? String(parsedContent.exameVinculado)
|
|
@@ -1538,8 +1628,7 @@ export class CourseStructureService {
|
|
|
1538
1628
|
if (
|
|
1539
1629
|
sourceType === 'video' ||
|
|
1540
1630
|
sourceType === 'questao' ||
|
|
1541
|
-
sourceType === 'post'
|
|
1542
|
-
sourceType === 'exercicio'
|
|
1631
|
+
sourceType === 'post'
|
|
1543
1632
|
) {
|
|
1544
1633
|
return sourceType;
|
|
1545
1634
|
}
|
|
@@ -1577,7 +1666,7 @@ export class CourseStructureService {
|
|
|
1577
1666
|
}
|
|
1578
1667
|
}
|
|
1579
1668
|
|
|
1580
|
-
if (data.tipo === 'post'
|
|
1669
|
+
if (data.tipo === 'post') {
|
|
1581
1670
|
payload.conteudoPost = data.conteudoPost ?? '';
|
|
1582
1671
|
}
|
|
1583
1672
|
|
|
@@ -1710,6 +1799,10 @@ export class CourseStructureService {
|
|
|
1710
1799
|
return 'video_original';
|
|
1711
1800
|
}
|
|
1712
1801
|
|
|
1802
|
+
if (value === 'video_hls') {
|
|
1803
|
+
return 'video_hls';
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1713
1806
|
if (value?.startsWith('video_profile:')) {
|
|
1714
1807
|
const profileId = Number(value.replace('video_profile:', ''));
|
|
1715
1808
|
if (Number.isInteger(profileId) && profileId > 0) {
|