@hed-hog/lms 0.0.331 → 0.0.347

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.
Files changed (135) hide show
  1. package/dist/class-group/class-group.controller.d.ts +8 -8
  2. package/dist/class-group/class-group.service.d.ts +8 -8
  3. package/dist/course/course.controller.d.ts +6 -1
  4. package/dist/course/course.controller.d.ts.map +1 -1
  5. package/dist/course/course.controller.js +19 -2
  6. package/dist/course/course.controller.js.map +1 -1
  7. package/dist/course/course.service.d.ts +6 -0
  8. package/dist/course/course.service.d.ts.map +1 -1
  9. package/dist/course/course.service.js +63 -28
  10. package/dist/course/course.service.js.map +1 -1
  11. package/dist/course/dto/create-course.dto.d.ts +1 -0
  12. package/dist/course/dto/create-course.dto.d.ts.map +1 -1
  13. package/dist/course/dto/create-course.dto.js +5 -0
  14. package/dist/course/dto/create-course.dto.js.map +1 -1
  15. package/dist/enterprise/enterprise.controller.d.ts +84 -12
  16. package/dist/enterprise/enterprise.controller.d.ts.map +1 -1
  17. package/dist/enterprise/enterprise.controller.js +10 -0
  18. package/dist/enterprise/enterprise.controller.js.map +1 -1
  19. package/dist/enterprise/enterprise.service.d.ts +90 -12
  20. package/dist/enterprise/enterprise.service.d.ts.map +1 -1
  21. package/dist/enterprise/enterprise.service.js +413 -40
  22. package/dist/enterprise/enterprise.service.js.map +1 -1
  23. package/dist/enterprise/training/training-admin.controller.d.ts +9 -6
  24. package/dist/enterprise/training/training-admin.controller.d.ts.map +1 -1
  25. package/dist/enterprise/training/training-admin.controller.js +10 -6
  26. package/dist/enterprise/training/training-admin.controller.js.map +1 -1
  27. package/dist/enterprise/training/training-admin.service.d.ts +11 -5
  28. package/dist/enterprise/training/training-admin.service.d.ts.map +1 -1
  29. package/dist/enterprise/training/training-admin.service.js +108 -52
  30. package/dist/enterprise/training/training-admin.service.js.map +1 -1
  31. package/dist/enterprise/training/training-viewer.controller.d.ts +3 -0
  32. package/dist/enterprise/training/training-viewer.controller.d.ts.map +1 -1
  33. package/dist/evaluation/evaluation.controller.d.ts +2 -2
  34. package/dist/evaluation/evaluation.service.d.ts +2 -2
  35. package/dist/instructor/dto/create-instructor-skill.dto.d.ts +0 -4
  36. package/dist/instructor/dto/create-instructor-skill.dto.d.ts.map +1 -1
  37. package/dist/instructor/dto/create-instructor-skill.dto.js +0 -21
  38. package/dist/instructor/dto/create-instructor-skill.dto.js.map +1 -1
  39. package/dist/instructor/dto/update-instructor-skill.dto.d.ts +0 -4
  40. package/dist/instructor/dto/update-instructor-skill.dto.d.ts.map +1 -1
  41. package/dist/instructor/dto/update-instructor-skill.dto.js +0 -22
  42. package/dist/instructor/dto/update-instructor-skill.dto.js.map +1 -1
  43. package/dist/instructor/instructor-skill.controller.d.ts +4 -4
  44. package/dist/instructor/instructor-skill.service.d.ts +4 -7
  45. package/dist/instructor/instructor-skill.service.d.ts.map +1 -1
  46. package/dist/instructor/instructor-skill.service.js +2 -89
  47. package/dist/instructor/instructor-skill.service.js.map +1 -1
  48. package/dist/instructor/instructor.controller.d.ts +21 -0
  49. package/dist/instructor/instructor.controller.d.ts.map +1 -1
  50. package/dist/instructor/instructor.controller.js +19 -0
  51. package/dist/instructor/instructor.controller.js.map +1 -1
  52. package/dist/instructor/instructor.service.d.ts +27 -0
  53. package/dist/instructor/instructor.service.d.ts.map +1 -1
  54. package/dist/instructor/instructor.service.js +79 -25
  55. package/dist/instructor/instructor.service.js.map +1 -1
  56. package/dist/lms.module.d.ts.map +1 -1
  57. package/dist/lms.module.js.map +1 -1
  58. package/dist/training/dto/create-training.dto.d.ts +1 -0
  59. package/dist/training/dto/create-training.dto.d.ts.map +1 -1
  60. package/dist/training/dto/create-training.dto.js +5 -0
  61. package/dist/training/dto/create-training.dto.js.map +1 -1
  62. package/dist/training/training.controller.d.ts +4 -0
  63. package/dist/training/training.controller.d.ts.map +1 -1
  64. package/dist/training/training.service.d.ts +8 -0
  65. package/dist/training/training.service.d.ts.map +1 -1
  66. package/dist/training/training.service.js +71 -6
  67. package/dist/training/training.service.js.map +1 -1
  68. package/hedhog/data/route.yaml +23 -1
  69. package/hedhog/frontend/app/_components/class-form-sheet.tsx.ejs +80 -33
  70. package/hedhog/frontend/app/_components/course-form-sheet.tsx.ejs +3 -3
  71. package/hedhog/frontend/app/_components/create-lms-instructor-sheet.tsx.ejs +591 -0
  72. package/hedhog/frontend/app/certificates/issued/page.tsx.ejs +6 -1
  73. package/hedhog/frontend/app/certificates/models/page.tsx.ejs +39 -7
  74. package/hedhog/frontend/app/classes/[id]/page.tsx.ejs +1 -3
  75. package/hedhog/frontend/app/classes/page.tsx.ejs +34 -7
  76. package/hedhog/frontend/app/courses/[id]/_components/CourseClassificationCard.tsx.ejs +3 -33
  77. package/hedhog/frontend/app/courses/[id]/_components/CourseContentCard.tsx.ejs +9 -9
  78. package/hedhog/frontend/app/courses/[id]/_components/CourseMainInfoCard.tsx.ejs +109 -0
  79. package/hedhog/frontend/app/courses/[id]/_components/CourseMultiEntityPicker.tsx.ejs +40 -13
  80. package/hedhog/frontend/app/courses/[id]/_components/CourseRelationsCard.tsx.ejs +76 -81
  81. package/hedhog/frontend/app/courses/[id]/_components/CourseSummaryCard.tsx.ejs +60 -0
  82. package/hedhog/frontend/app/courses/[id]/structure/_components/course-scheduled-classes-tab.tsx.ejs +406 -0
  83. package/hedhog/frontend/app/courses/[id]/structure/_components/course-tree.tsx.ejs +134 -0
  84. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-course.tsx.ejs +113 -0
  85. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-lesson.tsx.ejs +314 -0
  86. package/hedhog/frontend/app/courses/[id]/structure/_components/detail-session.tsx.ejs +174 -0
  87. package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +243 -34
  88. package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +185 -0
  89. package/hedhog/frontend/app/courses/page.tsx.ejs +6 -1
  90. package/hedhog/frontend/app/enterprise/_components/enterprise-activity-timeline.tsx.ejs +87 -0
  91. package/hedhog/frontend/app/enterprise/_components/enterprise-admin-create-sheet.tsx.ejs +4 -0
  92. package/hedhog/frontend/app/enterprise/_components/enterprise-administrators-tab.tsx.ejs +31 -5
  93. package/hedhog/frontend/app/enterprise/_components/enterprise-classes-tab.tsx.ejs +79 -20
  94. package/hedhog/frontend/app/enterprise/_components/enterprise-company-identity-card.tsx.ejs +11 -2
  95. package/hedhog/frontend/app/enterprise/_components/enterprise-course-edit-sheet.tsx.ejs +201 -0
  96. package/hedhog/frontend/app/enterprise/_components/enterprise-courses-tab.tsx.ejs +55 -24
  97. package/hedhog/frontend/app/enterprise/_components/enterprise-detail-sheet.tsx.ejs +430 -296
  98. package/hedhog/frontend/app/enterprise/_components/enterprise-mocks.ts.ejs +277 -0
  99. package/hedhog/frontend/app/enterprise/_components/enterprise-overview-analytics.tsx.ejs +205 -0
  100. package/hedhog/frontend/app/enterprise/_components/enterprise-person-edit-sheet.tsx.ejs +97 -0
  101. package/hedhog/frontend/app/enterprise/_components/enterprise-sheet.tsx.ejs +82 -57
  102. package/hedhog/frontend/app/enterprise/_components/enterprise-student-create-sheet.tsx.ejs +4 -0
  103. package/hedhog/frontend/app/enterprise/_components/enterprise-students-tab.tsx.ejs +60 -22
  104. package/hedhog/frontend/app/enterprise/_components/enterprise-types.ts.ejs +54 -0
  105. package/hedhog/frontend/app/enterprise/_components/enterprise-user-create-sheet.tsx.ejs +211 -0
  106. package/hedhog/frontend/app/enterprise/page.tsx.ejs +39 -7
  107. package/hedhog/frontend/app/exams/[id]/questions/page.tsx.ejs +31 -19
  108. package/hedhog/frontend/app/exams/page.tsx.ejs +6 -1
  109. package/hedhog/frontend/app/instructor-skills/page.tsx.ejs +51 -104
  110. package/hedhog/frontend/app/instructors/_components/instructor-form-sheet.tsx.ejs +625 -366
  111. package/hedhog/frontend/app/instructors/page.tsx.ejs +6 -1
  112. package/hedhog/frontend/app/paths/page.tsx.ejs +76 -8
  113. package/hedhog/frontend/app/reports/evaluations/page.tsx.ejs +6 -1
  114. package/hedhog/frontend/app/training/page.tsx.ejs +78 -9
  115. package/hedhog/frontend/messages/en.json +101 -10
  116. package/hedhog/frontend/messages/pt.json +115 -11
  117. package/hedhog/table/enterprise_student_license_event.yaml +30 -0
  118. package/hedhog/table/instructor_skill.yaml +0 -11
  119. package/hedhog/table/learning_path.yaml +4 -0
  120. package/package.json +6 -6
  121. package/src/course/course.controller.ts +18 -0
  122. package/src/course/course.service.ts +85 -26
  123. package/src/course/dto/create-course.dto.ts +4 -0
  124. package/src/enterprise/enterprise.controller.ts +5 -0
  125. package/src/enterprise/enterprise.service.ts +507 -29
  126. package/src/enterprise/training/training-admin.controller.ts +4 -0
  127. package/src/enterprise/training/training-admin.service.ts +115 -51
  128. package/src/instructor/dto/create-instructor-skill.dto.ts +0 -17
  129. package/src/instructor/dto/update-instructor-skill.dto.ts +0 -18
  130. package/src/instructor/instructor-skill.service.ts +2 -97
  131. package/src/instructor/instructor.controller.ts +16 -0
  132. package/src/instructor/instructor.service.ts +87 -10
  133. package/src/lms.module.ts +1 -0
  134. package/src/training/dto/create-training.dto.ts +4 -0
  135. package/src/training/training.service.ts +104 -5
@@ -12,6 +12,80 @@ export class TrainingService {
12
12
  private readonly integrationApi: IntegrationDeveloperApiService,
13
13
  ) {}
14
14
 
15
+ private normalizeProgressMode(value?: string | null) {
16
+ if (!value) return undefined;
17
+ const normalized = value.trim().toLowerCase();
18
+
19
+ if (normalized === 'free' || normalized === 'livre') return 'free';
20
+ if (normalized === 'sequential' || normalized === 'sequencial') {
21
+ return 'sequential';
22
+ }
23
+
24
+ return undefined;
25
+ }
26
+
27
+ private progressModeToPt(value?: string | null) {
28
+ return this.normalizeProgressMode(value) === 'free' ? 'livre' : 'sequencial';
29
+ }
30
+
31
+ private async getTrainingExtras(ids: number[]) {
32
+ const extrasById = new Map<number, { progress_mode?: 'sequential' | 'free' | null }>();
33
+
34
+ const normalizedIds = ids
35
+ .map((id) => Number(id))
36
+ .filter((id) => Number.isInteger(id) && id > 0);
37
+
38
+ if (normalizedIds.length === 0) {
39
+ return extrasById;
40
+ }
41
+
42
+ try {
43
+ const rows = (await this.prisma.$queryRawUnsafe(
44
+ `
45
+ SELECT id, progress_mode
46
+ FROM learning_path
47
+ WHERE id IN (${normalizedIds.join(',')})
48
+ `,
49
+ )) as Array<{
50
+ id: number;
51
+ progress_mode: 'sequential' | 'free' | null;
52
+ }>;
53
+
54
+ for (const row of rows) {
55
+ extrasById.set(row.id, {
56
+ progress_mode: row.progress_mode,
57
+ });
58
+ }
59
+ } catch {
60
+ return extrasById;
61
+ }
62
+
63
+ return extrasById;
64
+ }
65
+
66
+ private async persistTrainingProgressMode(
67
+ id: number,
68
+ progressMode?: 'sequential' | 'free',
69
+ ) {
70
+ if (progressMode === undefined) {
71
+ return;
72
+ }
73
+
74
+ try {
75
+ await this.prisma.$executeRawUnsafe(
76
+ `
77
+ UPDATE learning_path
78
+ SET progress_mode = $1
79
+ WHERE id = $2
80
+ `,
81
+ progressMode,
82
+ id,
83
+ );
84
+ } catch {
85
+ // Some environments may still be behind the current learning_path schema.
86
+ }
87
+ }
88
+
15
89
  async list(params: {
16
90
  page?: number;
17
91
  pageSize?: number;
@@ -110,12 +184,14 @@ export class TrainingService {
110
184
  this.prisma.learning_path.count({ where }),
111
185
  ]);
112
186
 
187
+ const extrasById = await this.getTrainingExtras(paths.map((path) => path.id));
188
+
113
189
  return {
114
190
  total,
115
191
  page,
116
192
  pageSize,
117
193
  lastPage: Math.max(1, Math.ceil(total / pageSize)),
118
- data: paths.map((path) => this.mapTraining(path)),
194
+ data: paths.map((path) => this.mapTraining(path, extrasById.get(path.id))),
119
195
  };
120
196
  }
121
197
 
@@ -179,7 +255,9 @@ export class TrainingService {
179
255
  });
180
256
 
181
257
  if (!path) return null;
182
- return this.mapTraining(path);
258
+
259
+ const extrasById = await this.getTrainingExtras([id]);
260
+ return this.mapTraining(path, extrasById.get(id));
183
261
  }
184
262
 
185
263
  async create(dto: CreateTrainingDto) {
@@ -187,6 +265,8 @@ export class TrainingService {
187
265
  const stepItems = this.resolveIncomingSteps(dto);
188
266
  const normalizedLevel = this.normalizeLevel(dto.level) ?? 'beginner';
189
267
  const normalizedStatus = this.normalizeStatus(dto.status) ?? 'draft';
268
+ const normalizedProgressMode =
269
+ this.normalizeProgressMode(dto.progressMode) ?? 'sequential';
190
270
 
191
271
  const created = await this.prisma.learning_path.create({
192
272
  data: {
@@ -242,7 +322,14 @@ export class TrainingService {
242
322
  },
243
323
  });
244
324
 
245
- const trainingResult = this.mapTraining(created);
325
+ await this.persistTrainingProgressMode(created.id, normalizedProgressMode);
326
+
327
+ const extrasById = await this.getTrainingExtras([created.id]);
328
+
329
+ const trainingResult = this.mapTraining(
330
+ created,
331
+ extrasById.get(created.id),
332
+ );
246
333
 
247
334
  await this.integrationApi.publishEvent({
248
335
  eventName: 'lms.training.created',
@@ -262,6 +349,10 @@ export class TrainingService {
262
349
  dto.level !== undefined ? this.normalizeLevel(dto.level) : undefined;
263
350
  const normalizedStatus =
264
351
  dto.status !== undefined ? this.normalizeStatus(dto.status) : undefined;
352
+ const normalizedProgressMode =
353
+ dto.progressMode !== undefined
354
+ ? this.normalizeProgressMode(dto.progressMode)
355
+ : undefined;
265
356
 
266
357
  if (stepsWereProvided) {
267
358
  await this.prisma.learning_path_step.deleteMany({
@@ -329,7 +420,11 @@ export class TrainingService {
329
420
  },
330
421
  });
331
422
 
332
- const updateTrainingResult = this.mapTraining(updated);
423
+ await this.persistTrainingProgressMode(id, normalizedProgressMode);
424
+
425
+ const extrasById = await this.getTrainingExtras([id]);
426
+
427
+ const updateTrainingResult = this.mapTraining(updated, extrasById.get(id));
333
428
 
334
429
  await this.integrationApi.publishEvent({
335
430
  eventName: 'lms.training.updated',
@@ -356,7 +451,10 @@ export class TrainingService {
356
451
  return { success: true };
357
452
  }
358
453
 
359
- private mapTraining(path: any) {
454
+ private mapTraining(
455
+ path: any,
456
+ extras?: { progress_mode?: 'sequential' | 'free' | null },
457
+ ) {
360
458
  const steps = [...(path.learning_path_step ?? [])].sort(
361
459
  (a: any, b: any) => (a?.order ?? 0) - (b?.order ?? 0),
362
460
  );
@@ -419,6 +517,7 @@ export class TrainingService {
419
517
  courseIds,
420
518
  examIds,
421
519
  items,
520
+ progressionMode: this.progressModeToPt(extras?.progress_mode),
422
521
  cargaTotal,
423
522
  alunos: path._count?.learning_path_enrollment ?? 0,
424
523
  status: this.statusToPt(path.status),