@hed-hog/lms 0.0.354 → 0.0.357
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/course/course-audio-transcription.service.d.ts.map +1 -1
- package/dist/course/course-audio-transcription.service.js +15 -7
- package/dist/course/course-audio-transcription.service.js.map +1 -1
- package/dist/course/course-structure.controller.d.ts +12 -0
- package/dist/course/course-structure.controller.d.ts.map +1 -1
- package/dist/course/course-structure.service.d.ts +22 -0
- package/dist/course/course-structure.service.d.ts.map +1 -1
- package/dist/course/course-structure.service.js +147 -18
- package/dist/course/course-structure.service.js.map +1 -1
- package/dist/course/course.service.d.ts +4 -2
- package/dist/course/course.service.d.ts.map +1 -1
- package/dist/course/course.service.js +61 -2
- package/dist/course/course.service.js.map +1 -1
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts +3 -0
- package/dist/course/dto/create-course-structure-lesson.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-structure-lesson.dto.js +15 -0
- package/dist/course/dto/create-course-structure-lesson.dto.js.map +1 -1
- package/dist/course/dto/create-course-structure-session.dto.d.ts +1 -0
- package/dist/course/dto/create-course-structure-session.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course-structure-session.dto.js +5 -0
- package/dist/course/dto/create-course-structure-session.dto.js.map +1 -1
- package/dist/enterprise/training/training-student.controller.d.ts +0 -95
- package/dist/enterprise/training/training-student.controller.d.ts.map +1 -1
- package/dist/enterprise/training/training-student.controller.js +1 -34
- package/dist/enterprise/training/training-student.controller.js.map +1 -1
- package/dist/enterprise/training/training-student.service.d.ts +63 -0
- package/dist/enterprise/training/training-student.service.d.ts.map +1 -1
- package/dist/enterprise/training/training-student.service.js +320 -4
- package/dist/enterprise/training/training-student.service.js.map +1 -1
- package/dist/lms.module.d.ts.map +1 -1
- package/dist/lms.module.js +2 -0
- package/dist/lms.module.js.map +1 -1
- package/dist/platforma/platforma.controller.d.ts +287 -0
- package/dist/platforma/platforma.controller.d.ts.map +1 -0
- package/dist/platforma/platforma.controller.js +147 -0
- package/dist/platforma/platforma.controller.js.map +1 -0
- package/hedhog/data/route.yaml +75 -9
- package/hedhog/frontend/app/_components/class-form-sheet.tsx.ejs +2 -2
- package/hedhog/frontend/app/_components/course-form-sheet.tsx.ejs +10 -13
- package/hedhog/frontend/app/classes/[id]/page.tsx.ejs +2 -2
- package/hedhog/frontend/app/courses/[id]/_components/course-edit-types.ts.ejs +1 -1
- package/hedhog/frontend/app/courses/[id]/structure/_components/confirm-dialog.tsx.ejs +17 -6
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +14 -7
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-lesson.tsx.ejs +92 -53
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-session.tsx.ejs +25 -60
- package/hedhog/frontend/app/courses/[id]/structure/_components/mock-data.ts.ejs +1 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/store.ts.ejs +11 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-context-menu.tsx.ejs +22 -0
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-lesson.tsx.ejs +79 -64
- package/hedhog/frontend/app/courses/[id]/structure/_components/tree-row-session.tsx.ejs +31 -14
- package/hedhog/frontend/app/courses/[id]/structure/_components/types.ts.ejs +3 -4
- package/hedhog/frontend/app/courses/[id]/structure/_data/adapters/course-structure.adapter.ts.ejs +28 -24
- package/hedhog/frontend/app/courses/[id]/structure/_data/types/api-course.types.ts.ejs +20 -0
- package/hedhog/frontend/app/courses/[id]/structure/_data/use-course-structure-mutations.ts.ejs +41 -6
- package/hedhog/frontend/app/courses/page.tsx.ejs +59 -15
- package/hedhog/frontend/app/enterprise/_components/enterprise-course-create-sheet.tsx.ejs +1 -1
- package/hedhog/frontend/app/enterprise/_components/enterprise-course-edit-sheet.tsx.ejs +2 -2
- package/hedhog/frontend/app/paths/page.tsx.ejs +1 -1
- package/hedhog/frontend/app/training/page.tsx.ejs +1 -1
- package/hedhog/frontend/messages/en.json +7 -2
- package/hedhog/frontend/messages/pt.json +7 -2
- package/hedhog/table/course_lesson.yaml +2 -2
- package/hedhog/table/course_module.yaml +3 -0
- package/package.json +9 -9
- package/src/course/course-audio-transcription.service.ts +21 -8
- package/src/course/course-structure.service.ts +204 -3
- package/src/course/course.service.ts +67 -1
- package/src/course/dto/create-course-structure-lesson.dto.ts +17 -0
- package/src/course/dto/create-course-structure-session.dto.ts +13 -1
- package/src/enterprise/training/training-student.controller.ts +3 -27
- package/src/enterprise/training/training-student.service.ts +350 -2
- package/src/lms.module.ts +2 -0
- package/src/platforma/platforma.controller.ts +92 -0
|
@@ -2,77 +2,6 @@ import { TrainingStudentService } from './training-student.service';
|
|
|
2
2
|
export declare class TrainingStudentController {
|
|
3
3
|
private readonly trainingStudentService;
|
|
4
4
|
constructor(trainingStudentService: TrainingStudentService);
|
|
5
|
-
getDashboard(userId: number, enterpriseId?: number): Promise<{
|
|
6
|
-
kpis: {
|
|
7
|
-
attendancePct: {
|
|
8
|
-
value: number;
|
|
9
|
-
change: any;
|
|
10
|
-
changeType: "percent";
|
|
11
|
-
};
|
|
12
|
-
overallProgress: {
|
|
13
|
-
value: number;
|
|
14
|
-
change: any;
|
|
15
|
-
changeType: "percent";
|
|
16
|
-
};
|
|
17
|
-
completedCourses: {
|
|
18
|
-
value: number;
|
|
19
|
-
change: any;
|
|
20
|
-
changeType: "absolute";
|
|
21
|
-
};
|
|
22
|
-
pendingEvaluations: {
|
|
23
|
-
value: number;
|
|
24
|
-
change: any;
|
|
25
|
-
changeType: "absolute";
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
myClasses: {
|
|
29
|
-
enrollmentId: number;
|
|
30
|
-
classGroupId: number;
|
|
31
|
-
courseId: number;
|
|
32
|
-
courseName: string;
|
|
33
|
-
hasCourseLogo: boolean;
|
|
34
|
-
className: string;
|
|
35
|
-
instructorName: string;
|
|
36
|
-
progress: number;
|
|
37
|
-
nextSession: {
|
|
38
|
-
date: Date;
|
|
39
|
-
time: string;
|
|
40
|
-
location: string;
|
|
41
|
-
};
|
|
42
|
-
status: import("@prisma/client").$Enums.course_class_group_status_d840783477_enum;
|
|
43
|
-
deliveryMode: import("@prisma/client").$Enums.course_class_group_delivery_mode_1f1dcad009_enum;
|
|
44
|
-
}[];
|
|
45
|
-
onDemandCourses: {
|
|
46
|
-
enrollmentId: number;
|
|
47
|
-
courseId: number;
|
|
48
|
-
courseName: string;
|
|
49
|
-
hasCourseLogo: boolean;
|
|
50
|
-
durationHours: any;
|
|
51
|
-
progress: number;
|
|
52
|
-
}[];
|
|
53
|
-
weeklySchedule: {
|
|
54
|
-
date: string;
|
|
55
|
-
sessions: {
|
|
56
|
-
sessionId: number;
|
|
57
|
-
time: string;
|
|
58
|
-
endTime: string;
|
|
59
|
-
className: string;
|
|
60
|
-
location: string;
|
|
61
|
-
}[];
|
|
62
|
-
}[];
|
|
63
|
-
ranking: {
|
|
64
|
-
position: number;
|
|
65
|
-
personId: number;
|
|
66
|
-
name: string;
|
|
67
|
-
progress: number;
|
|
68
|
-
isMe: boolean;
|
|
69
|
-
}[];
|
|
70
|
-
gamification: {
|
|
71
|
-
rankingPosition: number;
|
|
72
|
-
streak: number;
|
|
73
|
-
studyHoursThisWeek: number;
|
|
74
|
-
};
|
|
75
|
-
}>;
|
|
76
5
|
getClassGroups(userId: number, enterpriseId?: number, search?: string, status?: string, deliveryMode?: string): Promise<{
|
|
77
6
|
data: {
|
|
78
7
|
id: number;
|
|
@@ -164,29 +93,5 @@ export declare class TrainingStudentController {
|
|
|
164
93
|
comentario: any;
|
|
165
94
|
}[];
|
|
166
95
|
}>;
|
|
167
|
-
getStreak(userId: number, days?: number): Promise<{
|
|
168
|
-
currentStreak: number;
|
|
169
|
-
bestStreak: number;
|
|
170
|
-
totalActiveDays: number;
|
|
171
|
-
lastActivityDate: string;
|
|
172
|
-
days: {
|
|
173
|
-
date: string;
|
|
174
|
-
completed: boolean;
|
|
175
|
-
}[];
|
|
176
|
-
}>;
|
|
177
|
-
registerStreakActivity(userId: number, body?: {
|
|
178
|
-
activityType?: string;
|
|
179
|
-
source?: string;
|
|
180
|
-
activityDateKey?: string;
|
|
181
|
-
}): Promise<{
|
|
182
|
-
currentStreak: number;
|
|
183
|
-
bestStreak: number;
|
|
184
|
-
totalActiveDays: number;
|
|
185
|
-
lastActivityDate: string;
|
|
186
|
-
days: {
|
|
187
|
-
date: string;
|
|
188
|
-
completed: boolean;
|
|
189
|
-
}[];
|
|
190
|
-
}>;
|
|
191
96
|
}
|
|
192
97
|
//# sourceMappingURL=training-student.controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"training-student.controller.d.ts","sourceRoot":"","sources":["../../../src/enterprise/training/training-student.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,qBAEa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,sBAAsB;gBAAtB,sBAAsB,EAAE,sBAAsB;IAG3E,
|
|
1
|
+
{"version":3,"file":"training-student.controller.d.ts","sourceRoot":"","sources":["../../../src/enterprise/training/training-student.controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,qBAEa,yBAAyB;IACxB,OAAO,CAAC,QAAQ,CAAC,sBAAsB;gBAAtB,sBAAsB,EAAE,sBAAsB;IAG3E,cAAc,CACA,MAAM,EAAE,MAAM,EACmC,YAAY,CAAC,EAAE,MAAM,EACjE,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACT,YAAY,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;IAW9C,mBAAmB,CACL,MAAM,EAAE,MAAM,EACC,YAAY,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMjD,qBAAqB,CACP,MAAM,EAAE,MAAM,EACC,YAAY,EAAE,MAAM;;;;;;;;;;;IAMjD,sBAAsB,CACR,MAAM,EAAE,MAAM,EACC,YAAY,EAAE,MAAM;;;;;;;IAMjD,gBAAgB,CACF,MAAM,EAAE,MAAM,EACC,YAAY,EAAE,MAAM;;;;;;;;;;;;;CAIlD"}
|
|
@@ -20,9 +20,6 @@ let TrainingStudentController = class TrainingStudentController {
|
|
|
20
20
|
constructor(trainingStudentService) {
|
|
21
21
|
this.trainingStudentService = trainingStudentService;
|
|
22
22
|
}
|
|
23
|
-
getDashboard(userId, enterpriseId) {
|
|
24
|
-
return this.trainingStudentService.getDashboard(userId, enterpriseId);
|
|
25
|
-
}
|
|
26
23
|
getClassGroups(userId, enterpriseId, search, status, deliveryMode) {
|
|
27
24
|
return this.trainingStudentService.getClassGroups(userId, {
|
|
28
25
|
enterpriseId,
|
|
@@ -43,22 +40,8 @@ let TrainingStudentController = class TrainingStudentController {
|
|
|
43
40
|
getMyEvaluations(userId, classGroupId) {
|
|
44
41
|
return this.trainingStudentService.getMyEvaluations(userId, classGroupId);
|
|
45
42
|
}
|
|
46
|
-
getStreak(userId, days) {
|
|
47
|
-
return this.trainingStudentService.getStreak(userId, days);
|
|
48
|
-
}
|
|
49
|
-
registerStreakActivity(userId, body) {
|
|
50
|
-
return this.trainingStudentService.registerStreakActivity(userId, body);
|
|
51
|
-
}
|
|
52
43
|
};
|
|
53
44
|
exports.TrainingStudentController = TrainingStudentController;
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, common_1.Get)(),
|
|
56
|
-
__param(0, (0, api_1.User)('id')),
|
|
57
|
-
__param(1, (0, common_1.Query)('enterpriseId', new common_1.ParseIntPipe({ optional: true }))),
|
|
58
|
-
__metadata("design:type", Function),
|
|
59
|
-
__metadata("design:paramtypes", [Number, Number]),
|
|
60
|
-
__metadata("design:returntype", void 0)
|
|
61
|
-
], TrainingStudentController.prototype, "getDashboard", null);
|
|
62
45
|
__decorate([
|
|
63
46
|
(0, common_1.Get)('class-groups'),
|
|
64
47
|
__param(0, (0, api_1.User)('id')),
|
|
@@ -102,24 +85,8 @@ __decorate([
|
|
|
102
85
|
__metadata("design:paramtypes", [Number, Number]),
|
|
103
86
|
__metadata("design:returntype", void 0)
|
|
104
87
|
], TrainingStudentController.prototype, "getMyEvaluations", null);
|
|
105
|
-
__decorate([
|
|
106
|
-
(0, common_1.Get)('streak'),
|
|
107
|
-
__param(0, (0, api_1.User)('id')),
|
|
108
|
-
__param(1, (0, common_1.Query)('days', new common_1.ParseIntPipe({ optional: true }))),
|
|
109
|
-
__metadata("design:type", Function),
|
|
110
|
-
__metadata("design:paramtypes", [Number, Number]),
|
|
111
|
-
__metadata("design:returntype", void 0)
|
|
112
|
-
], TrainingStudentController.prototype, "getStreak", null);
|
|
113
|
-
__decorate([
|
|
114
|
-
(0, common_1.Post)('streak/activities'),
|
|
115
|
-
__param(0, (0, api_1.User)('id')),
|
|
116
|
-
__param(1, (0, common_1.Body)()),
|
|
117
|
-
__metadata("design:type", Function),
|
|
118
|
-
__metadata("design:paramtypes", [Number, Object]),
|
|
119
|
-
__metadata("design:returntype", void 0)
|
|
120
|
-
], TrainingStudentController.prototype, "registerStreakActivity", null);
|
|
121
88
|
exports.TrainingStudentController = TrainingStudentController = __decorate([
|
|
122
|
-
(0, api_1.
|
|
89
|
+
(0, api_1.NoRole)(),
|
|
123
90
|
(0, common_1.Controller)('lms/enterprise/training/student'),
|
|
124
91
|
__metadata("design:paramtypes", [training_student_service_1.TrainingStudentService])
|
|
125
92
|
], TrainingStudentController);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"training-student.controller.js","sourceRoot":"","sources":["../../../src/enterprise/training/training-student.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"training-student.controller.js","sourceRoot":"","sources":["../../../src/enterprise/training/training-student.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAA4C;AAC5C,2CAA6E;AAC7E,yEAAoE;AAI7D,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,YAA6B,sBAA8C;QAA9C,2BAAsB,GAAtB,sBAAsB,CAAwB;IAAG,CAAC;IAG/E,cAAc,CACA,MAAc,EACmC,YAAqB,EACjE,MAAe,EACf,MAAe,EACT,YAAqB;QAE5C,OAAO,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,MAAM,EAAE;YACxD,YAAY;YACZ,MAAM;YACN,MAAM;YACN,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAGD,mBAAmB,CACL,MAAc,EACC,YAAoB;QAE/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC/E,CAAC;IAGD,qBAAqB,CACP,MAAc,EACC,YAAoB;QAE/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjF,CAAC;IAGD,sBAAsB,CACR,MAAc,EACC,YAAoB;QAE/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,sBAAsB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAClF,CAAC;IAGD,gBAAgB,CACF,MAAc,EACC,YAAoB;QAE/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AAlDY,8DAAyB;AAIpC;IADC,IAAA,YAAG,EAAC,cAAc,CAAC;IAEjB,WAAA,IAAA,UAAI,EAAC,IAAI,CAAC,CAAA;IACV,WAAA,IAAA,cAAK,EAAC,cAAc,EAAE,IAAI,qBAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAC3D,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IACf,WAAA,IAAA,cAAK,EAAC,cAAc,CAAC,CAAA;;;;+DAQvB;AAGD;IADC,IAAA,YAAG,EAAC,kBAAkB,CAAC;IAErB,WAAA,IAAA,UAAI,EAAC,IAAI,CAAC,CAAA;IACV,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;oEAG3B;AAGD;IADC,IAAA,YAAG,EAAC,2BAA2B,CAAC;IAE9B,WAAA,IAAA,UAAI,EAAC,IAAI,CAAC,CAAA;IACV,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;sEAG3B;AAGD;IADC,IAAA,YAAG,EAAC,4BAA4B,CAAC;IAE/B,WAAA,IAAA,UAAI,EAAC,IAAI,CAAC,CAAA;IACV,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;uEAG3B;AAGD;IADC,IAAA,YAAG,EAAC,iCAAiC,CAAC;IAEpC,WAAA,IAAA,UAAI,EAAC,IAAI,CAAC,CAAA;IACV,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;;;;iEAG3B;oCAjDU,yBAAyB;IAFrC,IAAA,YAAM,GAAE;IACR,IAAA,mBAAU,EAAC,iCAAiC,CAAC;qCAES,iDAAsB;GADhE,yBAAyB,CAkDrC"}
|
|
@@ -2,6 +2,7 @@ import { PrismaService } from '@hed-hog/api-prisma';
|
|
|
2
2
|
export declare class TrainingStudentService {
|
|
3
3
|
private readonly prisma;
|
|
4
4
|
constructor(prisma: PrismaService);
|
|
5
|
+
private readonly courseCardsLimit;
|
|
5
6
|
registerStreakActivity(userId: number, payload?: {
|
|
6
7
|
activityType?: string;
|
|
7
8
|
source?: string;
|
|
@@ -26,7 +27,43 @@ export declare class TrainingStudentService {
|
|
|
26
27
|
completed: boolean;
|
|
27
28
|
}[];
|
|
28
29
|
}>;
|
|
30
|
+
getPublishedCourses(params: {
|
|
31
|
+
page?: number;
|
|
32
|
+
pageSize?: number;
|
|
33
|
+
search?: string;
|
|
34
|
+
category?: string;
|
|
35
|
+
sort?: string;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
data: {
|
|
38
|
+
id: number;
|
|
39
|
+
slug: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
durationHours: number;
|
|
43
|
+
level: import("@prisma/client").$Enums.course_level_de6adae713_enum;
|
|
44
|
+
lessons: number;
|
|
45
|
+
image: string;
|
|
46
|
+
categoryKey: string;
|
|
47
|
+
categoryLabel: string;
|
|
48
|
+
enrollmentCount: number;
|
|
49
|
+
updatedAt: Date;
|
|
50
|
+
}[];
|
|
51
|
+
categories: {
|
|
52
|
+
value: string;
|
|
53
|
+
label: string;
|
|
54
|
+
}[];
|
|
55
|
+
total: number;
|
|
56
|
+
page: number;
|
|
57
|
+
pageSize: number;
|
|
58
|
+
lastPage: number;
|
|
59
|
+
}>;
|
|
29
60
|
getDashboard(userId: number, enterpriseId?: number): Promise<{
|
|
61
|
+
user: {
|
|
62
|
+
id: number;
|
|
63
|
+
name: string;
|
|
64
|
+
email: string;
|
|
65
|
+
avatarId: number;
|
|
66
|
+
};
|
|
30
67
|
kpis: {
|
|
31
68
|
attendancePct: {
|
|
32
69
|
value: number;
|
|
@@ -74,6 +111,29 @@ export declare class TrainingStudentService {
|
|
|
74
111
|
durationHours: any;
|
|
75
112
|
progress: number;
|
|
76
113
|
}[];
|
|
114
|
+
courseCards: {
|
|
115
|
+
id: number;
|
|
116
|
+
slug: string;
|
|
117
|
+
title: string;
|
|
118
|
+
description: string;
|
|
119
|
+
image: string;
|
|
120
|
+
progress: number;
|
|
121
|
+
lessons: number;
|
|
122
|
+
durationHours: number;
|
|
123
|
+
inProgress: boolean;
|
|
124
|
+
source: "started";
|
|
125
|
+
}[] | {
|
|
126
|
+
id: number;
|
|
127
|
+
slug: string;
|
|
128
|
+
title: string;
|
|
129
|
+
description: string;
|
|
130
|
+
image: string;
|
|
131
|
+
progress: number;
|
|
132
|
+
lessons: number;
|
|
133
|
+
durationHours: number;
|
|
134
|
+
inProgress: boolean;
|
|
135
|
+
source: "on_demand";
|
|
136
|
+
}[];
|
|
77
137
|
weeklySchedule: {
|
|
78
138
|
date: string;
|
|
79
139
|
sessions: {
|
|
@@ -130,6 +190,9 @@ export declare class TrainingStudentService {
|
|
|
130
190
|
private getKpis;
|
|
131
191
|
private getMyClasses;
|
|
132
192
|
private getOnDemandCourses;
|
|
193
|
+
private getDashboardCourseCards;
|
|
194
|
+
private resolvePublishedCourseOrder;
|
|
195
|
+
private formatCategoryLabel;
|
|
133
196
|
private getWeeklySchedule;
|
|
134
197
|
private getRanking;
|
|
135
198
|
private getGamification;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"training-student.service.d.ts","sourceRoot":"","sources":["../../../src/enterprise/training/training-student.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBACa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"training-student.service.d.ts","sourceRoot":"","sources":["../../../src/enterprise/training/training-student.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBACa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAK;IAEhC,sBAAsB,CAC1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;IAiC1E,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,SAAK;;;;;;;;;;IA4BnC,mBAAmB,CAAC,MAAM,EAAE;QAChC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf;;;;;;;;;;;;;;;;;;;;;;;;IA0IK,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+GlD,cAAc,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;QACP,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,YAAY,CAAC,EAAE,MAAM,CAAC;KAClB;;;;;;;;;;;iCA0H2B,MAAM,GAAG,IAAI;;;;;;;;;;;;;;YAqBlC,OAAO;YAqEP,YAAY;YA6EZ,kBAAkB;YAgDlB,uBAAuB;IA+HrC,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,mBAAmB;YAUb,iBAAiB;YAwCjB,UAAU;YA0BV,eAAe;YAkDf,uBAAuB;YASvB,qBAAqB;IAU7B,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;;;;;;6BAmE7B,MAAM,GAAG,IAAI;uBACnB,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BlC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;;;;;;;;;sBAuCpC,MAAM,GAAG,IAAI;;IAKnC,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;;;;;;;IAkB3D,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;;;;;;;;;;;;;IA6B3D,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,wBAAwB;IAYhC,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,sBAAsB;IAoB9B,OAAO,CAAC,mBAAmB;IA0B3B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,UAAU;CAKnB"}
|
|
@@ -15,6 +15,7 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
let TrainingStudentService = class TrainingStudentService {
|
|
16
16
|
constructor(prisma) {
|
|
17
17
|
this.prisma = prisma;
|
|
18
|
+
this.courseCardsLimit = 4;
|
|
18
19
|
}
|
|
19
20
|
async registerStreakActivity(userId, payload) {
|
|
20
21
|
var _a;
|
|
@@ -68,8 +69,136 @@ let TrainingStudentService = class TrainingStudentService {
|
|
|
68
69
|
days: calendar,
|
|
69
70
|
};
|
|
70
71
|
}
|
|
72
|
+
async getPublishedCourses(params) {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
const page = Math.max(Number(params.page) || 1, 1);
|
|
75
|
+
const pageSize = Math.max(Number(params.pageSize) || 12, 1);
|
|
76
|
+
const skip = (page - 1) * pageSize;
|
|
77
|
+
const where = {
|
|
78
|
+
status: 'published',
|
|
79
|
+
is_listed: true,
|
|
80
|
+
};
|
|
81
|
+
const search = (_a = params.search) === null || _a === void 0 ? void 0 : _a.trim();
|
|
82
|
+
const category = (_b = params.category) === null || _b === void 0 ? void 0 : _b.trim();
|
|
83
|
+
const sort = (_c = params.sort) === null || _c === void 0 ? void 0 : _c.trim();
|
|
84
|
+
if (search) {
|
|
85
|
+
where.OR = [
|
|
86
|
+
{ title: { contains: search, mode: 'insensitive' } },
|
|
87
|
+
{ description: { contains: search, mode: 'insensitive' } },
|
|
88
|
+
{ slug: { contains: search, mode: 'insensitive' } },
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
if (category && category !== 'all') {
|
|
92
|
+
where.course_category = {
|
|
93
|
+
some: {
|
|
94
|
+
category: {
|
|
95
|
+
slug: category,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const orderBy = this.resolvePublishedCourseOrder(sort);
|
|
101
|
+
const [rows, total, categories] = await Promise.all([
|
|
102
|
+
this.prisma.course.findMany({
|
|
103
|
+
where,
|
|
104
|
+
skip,
|
|
105
|
+
take: pageSize,
|
|
106
|
+
orderBy,
|
|
107
|
+
select: {
|
|
108
|
+
id: true,
|
|
109
|
+
slug: true,
|
|
110
|
+
title: true,
|
|
111
|
+
description: true,
|
|
112
|
+
duration_hours: true,
|
|
113
|
+
level: true,
|
|
114
|
+
updated_at: true,
|
|
115
|
+
course_category: {
|
|
116
|
+
select: {
|
|
117
|
+
category: {
|
|
118
|
+
select: {
|
|
119
|
+
slug: true,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
course_image: {
|
|
125
|
+
where: { image_type: { slug: { in: ['course-banner', 'course-logo'] } } },
|
|
126
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
127
|
+
select: {
|
|
128
|
+
image_type: { select: { slug: true } },
|
|
129
|
+
file: { select: { location: true } },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
course_module: {
|
|
133
|
+
select: {
|
|
134
|
+
_count: {
|
|
135
|
+
select: {
|
|
136
|
+
course_lesson: true,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
_count: {
|
|
142
|
+
select: {
|
|
143
|
+
course_enrollment: true,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
this.prisma.course.count({ where }),
|
|
149
|
+
this.prisma.category.findMany({
|
|
150
|
+
where: {
|
|
151
|
+
course_category: {
|
|
152
|
+
some: {
|
|
153
|
+
course: {
|
|
154
|
+
status: 'published',
|
|
155
|
+
is_listed: true,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
select: {
|
|
161
|
+
slug: true,
|
|
162
|
+
},
|
|
163
|
+
orderBy: {
|
|
164
|
+
slug: 'asc',
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
]);
|
|
168
|
+
return {
|
|
169
|
+
data: rows.map((row) => {
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
171
|
+
const banner = row.course_image.find((image) => { var _a; return ((_a = image.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-banner'; });
|
|
172
|
+
const logo = row.course_image.find((image) => { var _a; return ((_a = image.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-logo'; });
|
|
173
|
+
const lessons = ((_a = row.course_module) !== null && _a !== void 0 ? _a : []).reduce((sum, module) => { var _a, _b; return sum + ((_b = (_a = module._count) === null || _a === void 0 ? void 0 : _a.course_lesson) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
174
|
+
const categorySlug = (_d = (_c = (_b = row.course_category[0]) === null || _b === void 0 ? void 0 : _b.category) === null || _c === void 0 ? void 0 : _c.slug) !== null && _d !== void 0 ? _d : null;
|
|
175
|
+
return {
|
|
176
|
+
id: row.id,
|
|
177
|
+
slug: row.slug,
|
|
178
|
+
title: row.title,
|
|
179
|
+
description: (_e = row.description) !== null && _e !== void 0 ? _e : '',
|
|
180
|
+
durationHours: (_f = row.duration_hours) !== null && _f !== void 0 ? _f : 0,
|
|
181
|
+
level: row.level,
|
|
182
|
+
lessons,
|
|
183
|
+
image: (_k = (_h = (_g = banner === null || banner === void 0 ? void 0 : banner.file) === null || _g === void 0 ? void 0 : _g.location) !== null && _h !== void 0 ? _h : (_j = logo === null || logo === void 0 ? void 0 : logo.file) === null || _j === void 0 ? void 0 : _j.location) !== null && _k !== void 0 ? _k : null,
|
|
184
|
+
categoryKey: categorySlug,
|
|
185
|
+
categoryLabel: this.formatCategoryLabel(categorySlug),
|
|
186
|
+
enrollmentCount: (_m = (_l = row._count) === null || _l === void 0 ? void 0 : _l.course_enrollment) !== null && _m !== void 0 ? _m : 0,
|
|
187
|
+
updatedAt: row.updated_at,
|
|
188
|
+
};
|
|
189
|
+
}),
|
|
190
|
+
categories: categories.map((item) => ({
|
|
191
|
+
value: item.slug,
|
|
192
|
+
label: this.formatCategoryLabel(item.slug),
|
|
193
|
+
})),
|
|
194
|
+
total,
|
|
195
|
+
page,
|
|
196
|
+
pageSize,
|
|
197
|
+
lastPage: Math.max(1, Math.ceil(total / pageSize)),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
71
200
|
async getDashboard(userId, enterpriseId) {
|
|
72
|
-
var _a;
|
|
201
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
73
202
|
const personUser = await this.prisma.person_user.findFirst({
|
|
74
203
|
where: { user_id: userId },
|
|
75
204
|
select: { person_id: true },
|
|
@@ -81,6 +210,35 @@ let TrainingStudentService = class TrainingStudentService {
|
|
|
81
210
|
const now = new Date();
|
|
82
211
|
const weekStart = this.startOfWeek(now);
|
|
83
212
|
const weekEnd = this.endOfDay(this.addDays(weekStart, 6));
|
|
213
|
+
const profile = await this.prisma.person.findUnique({
|
|
214
|
+
where: { id: personId },
|
|
215
|
+
select: {
|
|
216
|
+
id: true,
|
|
217
|
+
name: true,
|
|
218
|
+
avatar_id: true,
|
|
219
|
+
person_user: {
|
|
220
|
+
where: { user_id: userId },
|
|
221
|
+
take: 1,
|
|
222
|
+
select: {
|
|
223
|
+
user: {
|
|
224
|
+
select: {
|
|
225
|
+
id: true,
|
|
226
|
+
name: true,
|
|
227
|
+
photo_id: true,
|
|
228
|
+
user_identifier: {
|
|
229
|
+
where: { type: 'email' },
|
|
230
|
+
orderBy: [{ verified_at: 'desc' }, { created_at: 'asc' }],
|
|
231
|
+
take: 1,
|
|
232
|
+
select: { value: true },
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
const profileUser = (_c = (_b = (_a = profile === null || profile === void 0 ? void 0 : profile.person_user) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.user) !== null && _c !== void 0 ? _c : null;
|
|
241
|
+
const profileEmail = (_f = (_e = (_d = profileUser === null || profileUser === void 0 ? void 0 : profileUser.user_identifier) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.value) !== null && _f !== void 0 ? _f : null;
|
|
84
242
|
// Fetch all active enrollments for this student
|
|
85
243
|
const enrollments = await this.prisma.course_enrollment.findMany({
|
|
86
244
|
where: { person_id: personId, status: { not: 'cancelled' } },
|
|
@@ -110,22 +268,30 @@ let TrainingStudentService = class TrainingStudentService {
|
|
|
110
268
|
.map((e) => e.course_class_group_id)
|
|
111
269
|
.filter((id) => id != null);
|
|
112
270
|
const enrollmentIds = enrollments.map((e) => e.id);
|
|
113
|
-
const [kpis, myClasses, onDemandCourses, weeklySchedule, ranking, gamification] = await Promise.all([
|
|
271
|
+
const [kpis, myClasses, onDemandCourses, weeklySchedule, ranking, gamification, courseCards] = await Promise.all([
|
|
114
272
|
this.getKpis(personId, enrollments, enrollmentIds),
|
|
115
273
|
this.getMyClasses(classEnrollments, now),
|
|
116
274
|
this.getOnDemandCourses(onDemandEnrollments),
|
|
117
275
|
this.getWeeklySchedule(cgIds, weekStart, weekEnd),
|
|
118
276
|
this.getRanking(personId, cgIds),
|
|
119
277
|
this.getGamification(personId, enrollmentIds, weekStart, weekEnd),
|
|
278
|
+
this.getDashboardCourseCards(personId),
|
|
120
279
|
]);
|
|
121
280
|
const myRanking = ranking.find((r) => r.isMe);
|
|
122
281
|
return {
|
|
282
|
+
user: {
|
|
283
|
+
id: (_g = profileUser === null || profileUser === void 0 ? void 0 : profileUser.id) !== null && _g !== void 0 ? _g : userId,
|
|
284
|
+
name: (_j = (_h = profile === null || profile === void 0 ? void 0 : profile.name) !== null && _h !== void 0 ? _h : profileUser === null || profileUser === void 0 ? void 0 : profileUser.name) !== null && _j !== void 0 ? _j : null,
|
|
285
|
+
email: profileEmail,
|
|
286
|
+
avatarId: (_l = (_k = profile === null || profile === void 0 ? void 0 : profile.avatar_id) !== null && _k !== void 0 ? _k : profileUser === null || profileUser === void 0 ? void 0 : profileUser.photo_id) !== null && _l !== void 0 ? _l : null,
|
|
287
|
+
},
|
|
123
288
|
kpis,
|
|
124
289
|
myClasses,
|
|
125
290
|
onDemandCourses,
|
|
291
|
+
courseCards,
|
|
126
292
|
weeklySchedule,
|
|
127
293
|
ranking,
|
|
128
|
-
gamification: Object.assign(Object.assign({}, gamification), { rankingPosition: (
|
|
294
|
+
gamification: Object.assign(Object.assign({}, gamification), { rankingPosition: (_m = myRanking === null || myRanking === void 0 ? void 0 : myRanking.position) !== null && _m !== void 0 ? _m : null }),
|
|
129
295
|
};
|
|
130
296
|
}
|
|
131
297
|
async getClassGroups(userId, options = {}) {
|
|
@@ -367,7 +533,11 @@ let TrainingStudentService = class TrainingStudentService {
|
|
|
367
533
|
return [];
|
|
368
534
|
const courseIds = onDemandEnrollments.map((e) => e.course_id);
|
|
369
535
|
const courses = await this.prisma.course.findMany({
|
|
370
|
-
where: {
|
|
536
|
+
where: {
|
|
537
|
+
id: { in: courseIds },
|
|
538
|
+
status: 'published',
|
|
539
|
+
is_listed: true,
|
|
540
|
+
},
|
|
371
541
|
select: {
|
|
372
542
|
id: true,
|
|
373
543
|
title: true,
|
|
@@ -384,6 +554,9 @@ let TrainingStudentService = class TrainingStudentService {
|
|
|
384
554
|
return onDemandEnrollments.map((enrollment) => {
|
|
385
555
|
var _a, _b, _c, _d;
|
|
386
556
|
const course = courseById.get(enrollment.course_id);
|
|
557
|
+
if (!course) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
387
560
|
return {
|
|
388
561
|
enrollmentId: enrollment.id,
|
|
389
562
|
courseId: enrollment.course_id,
|
|
@@ -392,7 +565,150 @@ let TrainingStudentService = class TrainingStudentService {
|
|
|
392
565
|
durationHours: (_c = course === null || course === void 0 ? void 0 : course.duration_hours) !== null && _c !== void 0 ? _c : null,
|
|
393
566
|
progress: (_d = enrollment.progress_percent) !== null && _d !== void 0 ? _d : 0,
|
|
394
567
|
};
|
|
568
|
+
}).filter((course) => !!course);
|
|
569
|
+
}
|
|
570
|
+
async getDashboardCourseCards(personId) {
|
|
571
|
+
const startedEnrollments = await this.prisma.course_enrollment.findMany({
|
|
572
|
+
where: {
|
|
573
|
+
person_id: personId,
|
|
574
|
+
status: { not: 'cancelled' },
|
|
575
|
+
progress_percent: { gt: 0 },
|
|
576
|
+
course: {
|
|
577
|
+
status: 'published',
|
|
578
|
+
is_listed: true,
|
|
579
|
+
},
|
|
580
|
+
},
|
|
581
|
+
orderBy: [{ updated_at: 'desc' }, { enrolled_at: 'desc' }, { id: 'desc' }],
|
|
582
|
+
take: this.courseCardsLimit,
|
|
583
|
+
select: {
|
|
584
|
+
id: true,
|
|
585
|
+
progress_percent: true,
|
|
586
|
+
course: {
|
|
587
|
+
select: {
|
|
588
|
+
id: true,
|
|
589
|
+
slug: true,
|
|
590
|
+
title: true,
|
|
591
|
+
description: true,
|
|
592
|
+
duration_hours: true,
|
|
593
|
+
course_module: {
|
|
594
|
+
select: {
|
|
595
|
+
_count: {
|
|
596
|
+
select: {
|
|
597
|
+
course_lesson: true,
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
course_image: {
|
|
603
|
+
where: { image_type: { slug: { in: ['course-banner', 'course-logo'] } } },
|
|
604
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
605
|
+
select: {
|
|
606
|
+
image_type: { select: { slug: true } },
|
|
607
|
+
file: { select: { location: true } },
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
},
|
|
395
613
|
});
|
|
614
|
+
if (startedEnrollments.length > 0) {
|
|
615
|
+
return startedEnrollments.map((enrollment) => {
|
|
616
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
617
|
+
const course = enrollment.course;
|
|
618
|
+
const lessons = ((_a = course.course_module) !== null && _a !== void 0 ? _a : []).reduce((sum, module) => { var _a, _b; return sum + ((_b = (_a = module._count) === null || _a === void 0 ? void 0 : _a.course_lesson) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
619
|
+
const banner = course.course_image.find((image) => { var _a; return ((_a = image.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-banner'; });
|
|
620
|
+
const logo = course.course_image.find((image) => { var _a; return ((_a = image.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-logo'; });
|
|
621
|
+
return {
|
|
622
|
+
id: course.id,
|
|
623
|
+
slug: course.slug,
|
|
624
|
+
title: course.title,
|
|
625
|
+
description: (_b = course.description) !== null && _b !== void 0 ? _b : 'Continue de onde parou.',
|
|
626
|
+
image: (_f = (_d = (_c = banner === null || banner === void 0 ? void 0 : banner.file) === null || _c === void 0 ? void 0 : _c.location) !== null && _d !== void 0 ? _d : (_e = logo === null || logo === void 0 ? void 0 : logo.file) === null || _e === void 0 ? void 0 : _e.location) !== null && _f !== void 0 ? _f : null,
|
|
627
|
+
progress: (_g = enrollment.progress_percent) !== null && _g !== void 0 ? _g : 0,
|
|
628
|
+
lessons,
|
|
629
|
+
durationHours: (_h = course.duration_hours) !== null && _h !== void 0 ? _h : 0,
|
|
630
|
+
inProgress: true,
|
|
631
|
+
source: 'started',
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
const fallbackCourses = await this.prisma.course.findMany({
|
|
636
|
+
where: {
|
|
637
|
+
status: 'published',
|
|
638
|
+
is_listed: true,
|
|
639
|
+
offering_type: 'on_demand',
|
|
640
|
+
},
|
|
641
|
+
orderBy: [{ updated_at: 'desc' }, { created_at: 'desc' }, { id: 'desc' }],
|
|
642
|
+
take: this.courseCardsLimit,
|
|
643
|
+
select: {
|
|
644
|
+
id: true,
|
|
645
|
+
slug: true,
|
|
646
|
+
title: true,
|
|
647
|
+
description: true,
|
|
648
|
+
duration_hours: true,
|
|
649
|
+
course_module: {
|
|
650
|
+
select: {
|
|
651
|
+
_count: {
|
|
652
|
+
select: {
|
|
653
|
+
course_lesson: true,
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
course_image: {
|
|
659
|
+
where: { image_type: { slug: { in: ['course-banner', 'course-logo'] } } },
|
|
660
|
+
orderBy: [{ is_primary: 'desc' }, { order: 'asc' }],
|
|
661
|
+
select: {
|
|
662
|
+
image_type: { select: { slug: true } },
|
|
663
|
+
file: { select: { location: true } },
|
|
664
|
+
},
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
});
|
|
668
|
+
return fallbackCourses.map((course) => {
|
|
669
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
670
|
+
const lessons = ((_a = course.course_module) !== null && _a !== void 0 ? _a : []).reduce((sum, module) => { var _a, _b; return sum + ((_b = (_a = module._count) === null || _a === void 0 ? void 0 : _a.course_lesson) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
671
|
+
const banner = course.course_image.find((image) => { var _a; return ((_a = image.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-banner'; });
|
|
672
|
+
const logo = course.course_image.find((image) => { var _a; return ((_a = image.image_type) === null || _a === void 0 ? void 0 : _a.slug) === 'course-logo'; });
|
|
673
|
+
return {
|
|
674
|
+
id: course.id,
|
|
675
|
+
slug: course.slug,
|
|
676
|
+
title: course.title,
|
|
677
|
+
description: (_b = course.description) !== null && _b !== void 0 ? _b : 'Curso disponível para começar agora.',
|
|
678
|
+
image: (_f = (_d = (_c = banner === null || banner === void 0 ? void 0 : banner.file) === null || _c === void 0 ? void 0 : _c.location) !== null && _d !== void 0 ? _d : (_e = logo === null || logo === void 0 ? void 0 : logo.file) === null || _e === void 0 ? void 0 : _e.location) !== null && _f !== void 0 ? _f : null,
|
|
679
|
+
progress: 0,
|
|
680
|
+
lessons,
|
|
681
|
+
durationHours: (_g = course.duration_hours) !== null && _g !== void 0 ? _g : 0,
|
|
682
|
+
inProgress: false,
|
|
683
|
+
source: 'on_demand',
|
|
684
|
+
};
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
resolvePublishedCourseOrder(sort) {
|
|
688
|
+
switch (sort) {
|
|
689
|
+
case 'duracao':
|
|
690
|
+
return [{ duration_hours: 'asc' }, { updated_at: 'desc' }];
|
|
691
|
+
case 'populares':
|
|
692
|
+
return [{ course_enrollment: { _count: 'desc' } }, { updated_at: 'desc' }];
|
|
693
|
+
case 'recentes':
|
|
694
|
+
return [{ updated_at: 'desc' }, { created_at: 'desc' }];
|
|
695
|
+
case 'relevantes':
|
|
696
|
+
default:
|
|
697
|
+
return [
|
|
698
|
+
{ is_featured: 'desc' },
|
|
699
|
+
{ course_enrollment: { _count: 'desc' } },
|
|
700
|
+
{ updated_at: 'desc' },
|
|
701
|
+
];
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
formatCategoryLabel(slug) {
|
|
705
|
+
if (!slug)
|
|
706
|
+
return 'Sem categoria';
|
|
707
|
+
return slug
|
|
708
|
+
.split(/[-_\s]+/)
|
|
709
|
+
.filter(Boolean)
|
|
710
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
|
|
711
|
+
.join(' ');
|
|
396
712
|
}
|
|
397
713
|
async getWeeklySchedule(cgIds, weekStart, weekEnd) {
|
|
398
714
|
if (cgIds.length === 0)
|