@hed-hog/lms 0.0.319 → 0.0.320
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/class-group/class-group.controller.d.ts +65 -2
- package/dist/class-group/class-group.controller.d.ts.map +1 -1
- package/dist/class-group/class-group.controller.js +35 -0
- package/dist/class-group/class-group.controller.js.map +1 -1
- package/dist/class-group/class-group.service.d.ts +67 -2
- package/dist/class-group/class-group.service.d.ts.map +1 -1
- package/dist/class-group/class-group.service.js +164 -13
- package/dist/class-group/class-group.service.js.map +1 -1
- package/dist/class-group/dto/create-class-group.dto.d.ts.map +1 -1
- package/dist/class-group/dto/create-class-group.dto.js +2 -1
- package/dist/class-group/dto/create-class-group.dto.js.map +1 -1
- package/dist/class-group/dto/material.dto.d.ts +18 -0
- package/dist/class-group/dto/material.dto.d.ts.map +1 -0
- package/dist/class-group/dto/material.dto.js +86 -0
- package/dist/class-group/dto/material.dto.js.map +1 -0
- package/dist/course/course.service.d.ts +2 -0
- package/dist/course/course.service.d.ts.map +1 -1
- package/dist/course/course.service.js +27 -2
- package/dist/course/course.service.js.map +1 -1
- package/dist/course/dto/create-course.dto.d.ts +2 -2
- package/dist/course/dto/create-course.dto.d.ts.map +1 -1
- package/dist/course/dto/create-course.dto.js.map +1 -1
- package/dist/enterprise/enterprise.controller.d.ts +7 -1
- package/dist/enterprise/enterprise.controller.d.ts.map +1 -1
- package/dist/enterprise/enterprise.controller.js +72 -2
- package/dist/enterprise/enterprise.controller.js.map +1 -1
- package/dist/enterprise/enterprise.module.d.ts.map +1 -1
- package/dist/enterprise/enterprise.module.js +2 -1
- package/dist/enterprise/enterprise.module.js.map +1 -1
- package/dist/enterprise/enterprise.service.d.ts +3 -0
- package/dist/enterprise/enterprise.service.d.ts.map +1 -1
- package/dist/enterprise/enterprise.service.js +84 -1
- package/dist/enterprise/enterprise.service.js.map +1 -1
- package/dist/enterprise/training/enterprise-training.module.d.ts +3 -0
- package/dist/enterprise/training/enterprise-training.module.d.ts.map +1 -0
- package/dist/enterprise/training/enterprise-training.module.js +40 -0
- package/dist/enterprise/training/enterprise-training.module.js.map +1 -0
- package/dist/enterprise/training/training-admin.controller.d.ts +525 -0
- package/dist/enterprise/training/training-admin.controller.d.ts.map +1 -0
- package/dist/enterprise/training/training-admin.controller.js +385 -0
- package/dist/enterprise/training/training-admin.controller.js.map +1 -0
- package/dist/enterprise/training/training-admin.service.d.ts +582 -0
- package/dist/enterprise/training/training-admin.service.d.ts.map +1 -0
- package/dist/enterprise/training/training-admin.service.js +2283 -0
- package/dist/enterprise/training/training-admin.service.js.map +1 -0
- package/dist/enterprise/training/training-instructor.controller.d.ts +260 -0
- package/dist/enterprise/training/training-instructor.controller.d.ts.map +1 -0
- package/dist/enterprise/training/training-instructor.controller.js +199 -0
- package/dist/enterprise/training/training-instructor.controller.js.map +1 -0
- package/dist/enterprise/training/training-instructor.service.d.ts +280 -0
- package/dist/enterprise/training/training-instructor.service.d.ts.map +1 -0
- package/dist/enterprise/training/training-instructor.service.js +1218 -0
- package/dist/enterprise/training/training-instructor.service.js.map +1 -0
- package/dist/enterprise/training/training-student.controller.d.ts +168 -0
- package/dist/enterprise/training/training-student.controller.d.ts.map +1 -0
- package/dist/enterprise/training/training-student.controller.js +104 -0
- package/dist/enterprise/training/training-student.controller.js.map +1 -0
- package/dist/enterprise/training/training-student.service.d.ts +185 -0
- package/dist/enterprise/training/training-student.service.d.ts.map +1 -0
- package/dist/enterprise/training/training-student.service.js +674 -0
- package/dist/enterprise/training/training-student.service.js.map +1 -0
- package/dist/enterprise/training/training-viewer.controller.d.ts +298 -0
- package/dist/enterprise/training/training-viewer.controller.d.ts.map +1 -0
- package/dist/enterprise/training/training-viewer.controller.js +178 -0
- package/dist/enterprise/training/training-viewer.controller.js.map +1 -0
- package/dist/evaluation/dto/create-evaluation-topic.dto.d.ts +18 -0
- package/dist/evaluation/dto/create-evaluation-topic.dto.d.ts.map +1 -0
- package/dist/evaluation/dto/create-evaluation-topic.dto.js +59 -0
- package/dist/evaluation/dto/create-evaluation-topic.dto.js.map +1 -0
- package/dist/evaluation/dto/update-evaluation-topic.dto.d.ts +6 -0
- package/dist/evaluation/dto/update-evaluation-topic.dto.d.ts.map +1 -0
- package/dist/evaluation/dto/update-evaluation-topic.dto.js +9 -0
- package/dist/evaluation/dto/update-evaluation-topic.dto.js.map +1 -0
- package/dist/evaluation/evaluation.controller.d.ts +66 -0
- package/dist/evaluation/evaluation.controller.d.ts.map +1 -1
- package/dist/evaluation/evaluation.controller.js +73 -0
- package/dist/evaluation/evaluation.controller.js.map +1 -1
- package/dist/evaluation/evaluation.service.d.ts +71 -0
- package/dist/evaluation/evaluation.service.d.ts.map +1 -1
- package/dist/evaluation/evaluation.service.js +121 -0
- package/dist/evaluation/evaluation.service.js.map +1 -1
- package/dist/instructor/instructor.service.js +6 -6
- package/dist/instructor/instructor.service.js.map +1 -1
- package/dist/lms.module.d.ts.map +1 -1
- package/dist/lms.module.js +3 -0
- package/dist/lms.module.js.map +1 -1
- package/hedhog/data/menu.yaml +19 -2
- package/hedhog/data/route.yaml +730 -0
- package/hedhog/frontend/app/_components/class-form-sheet.tsx.ejs +74 -8
- package/hedhog/frontend/app/_components/course-avatar.tsx.ejs +27 -47
- package/hedhog/frontend/app/classes/[id]/_components/event-summary-popover.tsx.ejs +15 -15
- package/hedhog/frontend/app/classes/[id]/_components/quick-create-session-popover.tsx.ejs +5 -5
- package/hedhog/frontend/app/classes/[id]/page.tsx.ejs +2141 -308
- package/hedhog/frontend/app/classes/page.tsx.ejs +8 -7
- package/hedhog/frontend/app/courses/[id]/page.tsx.ejs +21 -8
- package/hedhog/frontend/app/courses/[id]/structure/_components/editor-course.tsx.ejs +10 -6
- package/hedhog/frontend/app/evaluations/_components/evaluation-topic-form-sheet.tsx.ejs +201 -0
- package/hedhog/frontend/app/evaluations/_components/evaluation-topic-types.ts.ejs +49 -0
- package/hedhog/frontend/app/evaluations/page.tsx.ejs +621 -1250
- package/hedhog/frontend/app/instructors/page.tsx.ejs +22 -20
- package/hedhog/frontend/app/reports/evaluations/page.tsx.ejs +1278 -0
- package/hedhog/frontend/messages/en.json +98 -7
- package/hedhog/frontend/messages/pt.json +98 -7
- package/hedhog/table/course_class_group_material.yaml +45 -0
- package/package.json +8 -8
- package/src/class-group/class-group.controller.ts +30 -0
- package/src/class-group/class-group.service.ts +176 -5
- package/src/class-group/dto/create-class-group.dto.ts +8 -8
- package/src/class-group/dto/material.dto.ts +69 -0
- package/src/course/course.service.ts +54 -21
- package/src/course/dto/create-course.dto.ts +8 -8
- package/src/enterprise/enterprise.controller.ts +62 -1
- package/src/enterprise/enterprise.module.ts +2 -1
- package/src/enterprise/enterprise.service.ts +84 -1
- package/src/enterprise/training/enterprise-training.module.ts +27 -0
- package/src/enterprise/training/training-admin.controller.ts +278 -0
- package/src/enterprise/training/training-admin.service.ts +2523 -0
- package/src/enterprise/training/training-instructor.controller.ts +141 -0
- package/src/enterprise/training/training-instructor.service.ts +1303 -0
- package/src/enterprise/training/training-student.controller.ts +65 -0
- package/src/enterprise/training/training-student.service.ts +762 -0
- package/src/enterprise/training/training-viewer.controller.ts +115 -0
- package/src/evaluation/dto/create-evaluation-topic.dto.ts +48 -0
- package/src/evaluation/dto/update-evaluation-topic.dto.ts +6 -0
- package/src/evaluation/evaluation.controller.ts +63 -1
- package/src/evaluation/evaluation.service.ts +150 -1
- package/src/instructor/instructor.service.ts +4 -4
- package/src/lms.module.ts +3 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Role, User } from '@hed-hog/api';
|
|
2
|
+
import { Controller, Get, Param, ParseIntPipe, Query } from '@nestjs/common';
|
|
3
|
+
import { TrainingAdminService } from './training-admin.service';
|
|
4
|
+
|
|
5
|
+
@Role()
|
|
6
|
+
@Controller('lms/enterprise/training/viewer')
|
|
7
|
+
export class TrainingViewerController {
|
|
8
|
+
constructor(private readonly trainingAdminService: TrainingAdminService) {}
|
|
9
|
+
|
|
10
|
+
@Get()
|
|
11
|
+
getDashboard(@User('id') userId: number) {
|
|
12
|
+
return this.trainingAdminService.getDashboard(userId);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Get('courses/stats')
|
|
16
|
+
getCourseStats(@User('id') userId: number) {
|
|
17
|
+
return this.trainingAdminService.getCourseStats(userId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Get('courses/:courseId')
|
|
21
|
+
getCourseDetail(
|
|
22
|
+
@User('id') userId: number,
|
|
23
|
+
@Param('courseId', ParseIntPipe) courseId: number,
|
|
24
|
+
) {
|
|
25
|
+
return this.trainingAdminService.getCourseDetail(userId, courseId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Get('courses')
|
|
29
|
+
getCourses(
|
|
30
|
+
@User('id') userId: number,
|
|
31
|
+
@Query('page', new ParseIntPipe({ optional: true })) page?: number,
|
|
32
|
+
@Query('pageSize', new ParseIntPipe({ optional: true })) pageSize?: number,
|
|
33
|
+
@Query('search') search?: string,
|
|
34
|
+
@Query('level') level?: string,
|
|
35
|
+
@Query('category') category?: string,
|
|
36
|
+
) {
|
|
37
|
+
return this.trainingAdminService.getCourses(userId, { page, pageSize, search, level, category });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@Get('class-groups')
|
|
41
|
+
getClassGroups(
|
|
42
|
+
@User('id') userId: number,
|
|
43
|
+
@Query('enterpriseId', new ParseIntPipe({ optional: true })) enterpriseId?: number,
|
|
44
|
+
@Query('search') search?: string,
|
|
45
|
+
@Query('status') status?: string,
|
|
46
|
+
@Query('deliveryMode') deliveryMode?: string,
|
|
47
|
+
) {
|
|
48
|
+
return this.trainingAdminService.getClassGroups(userId, {
|
|
49
|
+
enterpriseId,
|
|
50
|
+
search,
|
|
51
|
+
status,
|
|
52
|
+
deliveryMode,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@Get('class-groups/:id')
|
|
57
|
+
getClassGroupDetail(
|
|
58
|
+
@User('id') userId: number,
|
|
59
|
+
@Param('id', ParseIntPipe) classGroupId: number,
|
|
60
|
+
) {
|
|
61
|
+
return this.trainingAdminService.getClassGroupDetail(userId, classGroupId);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Get('class-groups/:id/students')
|
|
65
|
+
getClassGroupStudents(
|
|
66
|
+
@User('id') userId: number,
|
|
67
|
+
@Param('id', ParseIntPipe) classGroupId: number,
|
|
68
|
+
@Query('page', new ParseIntPipe({ optional: true })) page?: number,
|
|
69
|
+
@Query('pageSize', new ParseIntPipe({ optional: true })) pageSize?: number,
|
|
70
|
+
@Query('search') search?: string,
|
|
71
|
+
@Query('status') status?: string,
|
|
72
|
+
) {
|
|
73
|
+
return this.trainingAdminService.getClassGroupStudents(userId, classGroupId, { page, pageSize, search, status });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Get('class-groups/:id/sessions')
|
|
77
|
+
getClassGroupSessions(
|
|
78
|
+
@User('id') userId: number,
|
|
79
|
+
@Param('id', ParseIntPipe) classGroupId: number,
|
|
80
|
+
) {
|
|
81
|
+
return this.trainingAdminService.getClassGroupSessions(userId, classGroupId);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@Get('class-groups/:id/materials')
|
|
85
|
+
getClassGroupMaterials(
|
|
86
|
+
@User('id') userId: number,
|
|
87
|
+
@Param('id', ParseIntPipe) classGroupId: number,
|
|
88
|
+
) {
|
|
89
|
+
return this.trainingAdminService.getClassGroupMaterials(userId, classGroupId);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Get('students/stats')
|
|
93
|
+
getStudentStats(@User('id') userId: number) {
|
|
94
|
+
return this.trainingAdminService.getStudentStats(userId);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Get('students/:personId')
|
|
98
|
+
getStudentDetail(
|
|
99
|
+
@User('id') userId: number,
|
|
100
|
+
@Param('personId', ParseIntPipe) personId: number,
|
|
101
|
+
) {
|
|
102
|
+
return this.trainingAdminService.getStudentDetail(userId, personId);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Get('students')
|
|
106
|
+
getStudents(
|
|
107
|
+
@User('id') userId: number,
|
|
108
|
+
@Query('page', new ParseIntPipe({ optional: true })) page?: number,
|
|
109
|
+
@Query('pageSize', new ParseIntPipe({ optional: true })) pageSize?: number,
|
|
110
|
+
@Query('search') search?: string,
|
|
111
|
+
@Query('status') status?: string,
|
|
112
|
+
) {
|
|
113
|
+
return this.trainingAdminService.getStudents(userId, { page, pageSize, search, status });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IsArray,
|
|
3
|
+
IsBoolean,
|
|
4
|
+
IsEnum,
|
|
5
|
+
IsInt,
|
|
6
|
+
IsNotEmpty,
|
|
7
|
+
IsOptional,
|
|
8
|
+
IsString,
|
|
9
|
+
MaxLength,
|
|
10
|
+
Min,
|
|
11
|
+
} from 'class-validator';
|
|
12
|
+
|
|
13
|
+
export enum EvaluationTargetType {
|
|
14
|
+
COURSE = 'course',
|
|
15
|
+
COURSE_LESSON = 'course_lesson',
|
|
16
|
+
COURSE_CLASS_SESSION = 'course_class_session',
|
|
17
|
+
QUESTION = 'question',
|
|
18
|
+
EXAM = 'exam',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class CreateEvaluationTopicDto {
|
|
22
|
+
@IsString()
|
|
23
|
+
@IsNotEmpty()
|
|
24
|
+
@MaxLength(255)
|
|
25
|
+
name: string;
|
|
26
|
+
|
|
27
|
+
@IsString()
|
|
28
|
+
@IsOptional()
|
|
29
|
+
description?: string;
|
|
30
|
+
|
|
31
|
+
@IsEnum(EvaluationTargetType)
|
|
32
|
+
targetType: EvaluationTargetType;
|
|
33
|
+
|
|
34
|
+
@IsInt()
|
|
35
|
+
@Min(0)
|
|
36
|
+
@IsOptional()
|
|
37
|
+
order?: number;
|
|
38
|
+
|
|
39
|
+
@IsBoolean()
|
|
40
|
+
@IsOptional()
|
|
41
|
+
isActive?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class ReorderTopicsDto {
|
|
45
|
+
@IsArray()
|
|
46
|
+
@IsInt({ each: true })
|
|
47
|
+
ids: number[];
|
|
48
|
+
}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { Role } from '@hed-hog/api';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Body,
|
|
4
|
+
Controller,
|
|
5
|
+
Delete,
|
|
6
|
+
Get,
|
|
7
|
+
Param,
|
|
8
|
+
ParseIntPipe,
|
|
9
|
+
Patch,
|
|
10
|
+
Post,
|
|
11
|
+
Query,
|
|
12
|
+
} from '@nestjs/common';
|
|
13
|
+
import {
|
|
14
|
+
CreateEvaluationTopicDto,
|
|
15
|
+
ReorderTopicsDto,
|
|
16
|
+
} from './dto/create-evaluation-topic.dto';
|
|
17
|
+
import { UpdateEvaluationTopicDto } from './dto/update-evaluation-topic.dto';
|
|
3
18
|
import { EvaluationService } from './evaluation.service';
|
|
4
19
|
|
|
5
20
|
@Role()
|
|
@@ -17,6 +32,53 @@ export class EvaluationController {
|
|
|
17
32
|
return this.evaluationService.filterOptions();
|
|
18
33
|
}
|
|
19
34
|
|
|
35
|
+
// ── Topics ──────────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
@Get('topics')
|
|
38
|
+
listTopics(
|
|
39
|
+
@Query('page') page?: string,
|
|
40
|
+
@Query('pageSize') pageSize?: string,
|
|
41
|
+
@Query('search') search?: string,
|
|
42
|
+
@Query('targetType') targetType?: string,
|
|
43
|
+
) {
|
|
44
|
+
return this.evaluationService.listTopics({
|
|
45
|
+
page: page ? Number(page) : 1,
|
|
46
|
+
pageSize: pageSize ? Number(pageSize) : 20,
|
|
47
|
+
search,
|
|
48
|
+
targetType,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Post('topics')
|
|
53
|
+
createTopic(@Body() dto: CreateEvaluationTopicDto) {
|
|
54
|
+
return this.evaluationService.createTopic(dto);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Get('topics/:id')
|
|
58
|
+
getTopicById(@Param('id', ParseIntPipe) id: number) {
|
|
59
|
+
return this.evaluationService.getTopicById(id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Patch('topics/reorder')
|
|
63
|
+
reorderTopics(@Body() dto: ReorderTopicsDto) {
|
|
64
|
+
return this.evaluationService.reorderTopics(dto.ids);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@Patch('topics/:id')
|
|
68
|
+
updateTopic(
|
|
69
|
+
@Param('id', ParseIntPipe) id: number,
|
|
70
|
+
@Body() dto: UpdateEvaluationTopicDto,
|
|
71
|
+
) {
|
|
72
|
+
return this.evaluationService.updateTopic(id, dto);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Delete('topics/:id')
|
|
76
|
+
deleteTopic(@Param('id', ParseIntPipe) id: number) {
|
|
77
|
+
return this.evaluationService.deleteTopic(id);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Ratings ─────────────────────────────────────────────────────────────────
|
|
81
|
+
|
|
20
82
|
@Get()
|
|
21
83
|
list(
|
|
22
84
|
@Query('page') page?: string,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { PrismaService } from '@hed-hog/api-prisma';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Injectable,
|
|
4
|
+
NotFoundException,
|
|
5
|
+
UnprocessableEntityException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import {
|
|
8
|
+
CreateEvaluationTopicDto,
|
|
9
|
+
EvaluationTargetType,
|
|
10
|
+
} from './dto/create-evaluation-topic.dto';
|
|
11
|
+
import { UpdateEvaluationTopicDto } from './dto/update-evaluation-topic.dto';
|
|
3
12
|
|
|
4
13
|
@Injectable()
|
|
5
14
|
export class EvaluationService {
|
|
@@ -391,4 +400,144 @@ export class EvaluationService {
|
|
|
391
400
|
.map((r) => ({ id: r.person!.id, label: r.person!.name })),
|
|
392
401
|
};
|
|
393
402
|
}
|
|
403
|
+
|
|
404
|
+
// ── Topics CRUD ─────────────────────────────────────────────────────────────
|
|
405
|
+
|
|
406
|
+
async listTopics(params: {
|
|
407
|
+
page?: number;
|
|
408
|
+
pageSize?: number;
|
|
409
|
+
search?: string;
|
|
410
|
+
targetType?: string;
|
|
411
|
+
}) {
|
|
412
|
+
const page = Math.max(Number(params.page) || 1, 1);
|
|
413
|
+
const pageSize = Math.max(Number(params.pageSize) || 20, 1);
|
|
414
|
+
const skip = (page - 1) * pageSize;
|
|
415
|
+
|
|
416
|
+
const where: any = {};
|
|
417
|
+
|
|
418
|
+
if (params.targetType && Object.values(EvaluationTargetType).includes(params.targetType as EvaluationTargetType)) {
|
|
419
|
+
where.target_type = params.targetType;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (params.search) {
|
|
423
|
+
where.OR = [
|
|
424
|
+
{ name: { contains: params.search, mode: 'insensitive' } },
|
|
425
|
+
{ description: { contains: params.search, mode: 'insensitive' } },
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const [topics, total] = await Promise.all([
|
|
430
|
+
this.prisma.evaluation_topic.findMany({
|
|
431
|
+
where,
|
|
432
|
+
skip,
|
|
433
|
+
take: pageSize,
|
|
434
|
+
orderBy: [{ target_type: 'asc' }, { order: 'asc' }, { name: 'asc' }],
|
|
435
|
+
include: {
|
|
436
|
+
_count: { select: { evaluation_rating: true } },
|
|
437
|
+
},
|
|
438
|
+
}),
|
|
439
|
+
this.prisma.evaluation_topic.count({ where }),
|
|
440
|
+
]);
|
|
441
|
+
|
|
442
|
+
return {
|
|
443
|
+
total,
|
|
444
|
+
page,
|
|
445
|
+
pageSize,
|
|
446
|
+
lastPage: Math.max(1, Math.ceil(total / pageSize)),
|
|
447
|
+
data: topics.map((t) => ({
|
|
448
|
+
id: t.id,
|
|
449
|
+
name: t.name,
|
|
450
|
+
description: t.description ?? null,
|
|
451
|
+
targetType: t.target_type,
|
|
452
|
+
order: t.order,
|
|
453
|
+
isActive: t.is_active,
|
|
454
|
+
ratingCount: t._count.evaluation_rating,
|
|
455
|
+
createdAt: t.created_at,
|
|
456
|
+
updatedAt: t.updated_at,
|
|
457
|
+
})),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async getTopicById(id: number) {
|
|
462
|
+
const topic = await this.prisma.evaluation_topic.findUnique({
|
|
463
|
+
where: { id },
|
|
464
|
+
include: {
|
|
465
|
+
_count: { select: { evaluation_rating: true } },
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
if (!topic) {
|
|
470
|
+
throw new NotFoundException(`Evaluation topic #${id} not found`);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return {
|
|
474
|
+
id: topic.id,
|
|
475
|
+
name: topic.name,
|
|
476
|
+
description: topic.description ?? null,
|
|
477
|
+
targetType: topic.target_type,
|
|
478
|
+
order: topic.order,
|
|
479
|
+
isActive: topic.is_active,
|
|
480
|
+
ratingCount: topic._count.evaluation_rating,
|
|
481
|
+
createdAt: topic.created_at,
|
|
482
|
+
updatedAt: topic.updated_at,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
async createTopic(dto: CreateEvaluationTopicDto) {
|
|
487
|
+
const data: any = {
|
|
488
|
+
name: dto.name,
|
|
489
|
+
target_type: dto.targetType,
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
if (dto.description !== undefined) data.description = dto.description;
|
|
493
|
+
if (dto.order !== undefined) data.order = dto.order;
|
|
494
|
+
if (dto.isActive !== undefined) data.is_active = dto.isActive;
|
|
495
|
+
|
|
496
|
+
return this.prisma.evaluation_topic.create({ data });
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
async updateTopic(id: number, dto: UpdateEvaluationTopicDto) {
|
|
500
|
+
await this.getTopicById(id);
|
|
501
|
+
|
|
502
|
+
const data: any = {};
|
|
503
|
+
if (dto.name !== undefined) data.name = dto.name;
|
|
504
|
+
if (dto.description !== undefined) data.description = dto.description;
|
|
505
|
+
if (dto.targetType !== undefined) data.target_type = dto.targetType;
|
|
506
|
+
if (dto.order !== undefined) data.order = dto.order;
|
|
507
|
+
if (dto.isActive !== undefined) data.is_active = dto.isActive;
|
|
508
|
+
|
|
509
|
+
return this.prisma.evaluation_topic.update({ where: { id }, data });
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
async reorderTopics(ids: number[]) {
|
|
513
|
+
await this.prisma.$transaction(
|
|
514
|
+
ids.map((id, index) =>
|
|
515
|
+
this.prisma.evaluation_topic.update({
|
|
516
|
+
where: { id },
|
|
517
|
+
data: { order: index },
|
|
518
|
+
}),
|
|
519
|
+
),
|
|
520
|
+
);
|
|
521
|
+
return { reordered: ids.length };
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
async deleteTopic(id: number) {
|
|
525
|
+
const topic = await this.prisma.evaluation_topic.findUnique({
|
|
526
|
+
where: { id },
|
|
527
|
+
include: { _count: { select: { evaluation_rating: true } } },
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
if (!topic) {
|
|
531
|
+
throw new NotFoundException(`Evaluation topic #${id} not found`);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
if (topic._count.evaluation_rating > 0) {
|
|
535
|
+
throw new UnprocessableEntityException(
|
|
536
|
+
`Cannot delete topic with ${topic._count.evaluation_rating} existing rating(s).`,
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
await this.prisma.evaluation_topic.delete({ where: { id } });
|
|
541
|
+
return { deleted: true };
|
|
542
|
+
}
|
|
394
543
|
}
|
|
@@ -130,9 +130,9 @@ export class InstructorService {
|
|
|
130
130
|
userId: personUser?.user_id ?? null,
|
|
131
131
|
hasTrainingAccess: (personUser?.user?.role_user?.length ?? 0) > 0,
|
|
132
132
|
status: row.status,
|
|
133
|
-
qualificationSlugs: row.instructor_qualification_assignment
|
|
133
|
+
qualificationSlugs: [...new Set(row.instructor_qualification_assignment
|
|
134
134
|
.map((assignment) => assignment.instructor_qualification.slug)
|
|
135
|
-
.sort(),
|
|
135
|
+
.sort())],
|
|
136
136
|
};
|
|
137
137
|
})
|
|
138
138
|
.sort((left, right) => left.name.localeCompare(right.name)),
|
|
@@ -393,9 +393,9 @@ export class InstructorService {
|
|
|
393
393
|
'WHATSAPP',
|
|
394
394
|
]),
|
|
395
395
|
status: instructor.status,
|
|
396
|
-
qualificationSlugs: instructor.instructor_qualification_assignment
|
|
396
|
+
qualificationSlugs: [...new Set(instructor.instructor_qualification_assignment
|
|
397
397
|
.map((assignment) => assignment.instructor_qualification.slug)
|
|
398
|
-
.sort(),
|
|
398
|
+
.sort())],
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
401
|
|
package/src/lms.module.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ClassGroupModule } from './class-group/class-group.module';
|
|
|
8
8
|
import { CourseModule } from './course/course.module';
|
|
9
9
|
import { LmsDashboardModule } from './dashboard/dashboard.module';
|
|
10
10
|
import { EnterpriseModule } from './enterprise/enterprise.module';
|
|
11
|
+
import { EnterpriseTrainingModule } from './enterprise/training/enterprise-training.module';
|
|
11
12
|
import { EvaluationModule } from './evaluation/evaluation.module';
|
|
12
13
|
import { ExamModule } from './exam/exam.module';
|
|
13
14
|
import { InstructorModule } from './instructor/instructor.module';
|
|
@@ -25,6 +26,7 @@ import { TrainingModule } from './training/training.module';
|
|
|
25
26
|
forwardRef(() => CourseModule),
|
|
26
27
|
forwardRef(() => LmsDashboardModule),
|
|
27
28
|
forwardRef(() => EnterpriseModule),
|
|
29
|
+
forwardRef(() => EnterpriseTrainingModule),
|
|
28
30
|
forwardRef(() => EvaluationModule),
|
|
29
31
|
forwardRef(() => ExamModule),
|
|
30
32
|
forwardRef(() => InstructorModule),
|
|
@@ -37,6 +39,7 @@ import { TrainingModule } from './training/training.module';
|
|
|
37
39
|
forwardRef(() => CourseModule),
|
|
38
40
|
forwardRef(() => LmsDashboardModule),
|
|
39
41
|
forwardRef(() => EnterpriseModule),
|
|
42
|
+
forwardRef(() => EnterpriseTrainingModule),
|
|
40
43
|
forwardRef(() => EvaluationModule),
|
|
41
44
|
forwardRef(() => ExamModule),
|
|
42
45
|
forwardRef(() => InstructorModule),
|