@memberjunction/actions-bizapps-lms 5.3.1 → 5.4.1
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +26 -0
- package/LEARNWORLDS_SIDECAR_PLAN.md +845 -0
- package/dist/base/base-lms.action.d.ts +26 -4
- package/dist/base/base-lms.action.d.ts.map +1 -1
- package/dist/base/base-lms.action.js +73 -17
- package/dist/base/base-lms.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/attach-tags.action.d.ts +26 -0
- package/dist/providers/learnworlds/actions/attach-tags.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/attach-tags.action.js +79 -0
- package/dist/providers/learnworlds/actions/attach-tags.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/create-user.action.d.ts +24 -1
- package/dist/providers/learnworlds/actions/create-user.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/create-user.action.js +166 -142
- package/dist/providers/learnworlds/actions/create-user.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/detach-tags.action.d.ts +26 -0
- package/dist/providers/learnworlds/actions/detach-tags.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/detach-tags.action.js +79 -0
- package/dist/providers/learnworlds/actions/detach-tags.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/enroll-user.action.d.ts +31 -3
- package/dist/providers/learnworlds/actions/enroll-user.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/enroll-user.action.js +179 -125
- package/dist/providers/learnworlds/actions/enroll-user.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-bulk-data.action.d.ts +79 -0
- package/dist/providers/learnworlds/actions/get-bulk-data.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-bulk-data.action.js +359 -0
- package/dist/providers/learnworlds/actions/get-bulk-data.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.d.ts +34 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.js +107 -0
- package/dist/providers/learnworlds/actions/get-bundles.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/get-certificates.action.d.ts +33 -2
- package/dist/providers/learnworlds/actions/get-certificates.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-certificates.action.js +311 -244
- package/dist/providers/learnworlds/actions/get-certificates.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts +14 -14
- package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-analytics.action.js +234 -226
- package/dist/providers/learnworlds/actions/get-course-analytics.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-details.action.d.ts +42 -6
- package/dist/providers/learnworlds/actions/get-course-details.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-course-details.action.js +182 -148
- package/dist/providers/learnworlds/actions/get-course-details.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-courses.action.d.ts +29 -82
- package/dist/providers/learnworlds/actions/get-courses.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-courses.action.js +188 -207
- package/dist/providers/learnworlds/actions/get-courses.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts +22 -2
- package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-quiz-results.action.js +316 -294
- package/dist/providers/learnworlds/actions/get-quiz-results.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-details.action.d.ts +23 -59
- package/dist/providers/learnworlds/actions/get-user-details.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-details.action.js +113 -114
- package/dist/providers/learnworlds/actions/get-user-details.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts +43 -5
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.js +191 -147
- package/dist/providers/learnworlds/actions/get-user-enrollments.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts +21 -92
- package/dist/providers/learnworlds/actions/get-user-progress.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-user-progress.action.js +145 -166
- package/dist/providers/learnworlds/actions/get-user-progress.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/get-users.action.d.ts +14 -28
- package/dist/providers/learnworlds/actions/get-users.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/get-users.action.js +122 -143
- package/dist/providers/learnworlds/actions/get-users.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/index.d.ts +7 -0
- package/dist/providers/learnworlds/actions/index.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/index.js +7 -0
- package/dist/providers/learnworlds/actions/index.js.map +1 -1
- package/dist/providers/learnworlds/actions/onboard-learner.action.d.ts +53 -0
- package/dist/providers/learnworlds/actions/onboard-learner.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/onboard-learner.action.js +236 -0
- package/dist/providers/learnworlds/actions/onboard-learner.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/sso-login.action.d.ts +35 -0
- package/dist/providers/learnworlds/actions/sso-login.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/sso-login.action.js +101 -0
- package/dist/providers/learnworlds/actions/sso-login.action.js.map +1 -0
- package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts +12 -1
- package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/actions/update-user-progress.action.js +167 -210
- package/dist/providers/learnworlds/actions/update-user-progress.action.js.map +1 -1
- package/dist/providers/learnworlds/actions/update-user.action.d.ts +39 -0
- package/dist/providers/learnworlds/actions/update-user.action.d.ts.map +1 -0
- package/dist/providers/learnworlds/actions/update-user.action.js +168 -0
- package/dist/providers/learnworlds/actions/update-user.action.js.map +1 -0
- package/dist/providers/learnworlds/index.d.ts +1 -0
- package/dist/providers/learnworlds/index.d.ts.map +1 -1
- package/dist/providers/learnworlds/index.js +2 -0
- package/dist/providers/learnworlds/index.js.map +1 -1
- package/dist/providers/learnworlds/interfaces/bundle.types.d.ts +16 -0
- package/dist/providers/learnworlds/interfaces/bundle.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/bundle.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/bundle.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.d.ts +66 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/certificate.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/common.types.d.ts +221 -0
- package/dist/providers/learnworlds/interfaces/common.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/common.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/common.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/course.types.d.ts +393 -0
- package/dist/providers/learnworlds/interfaces/course.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/course.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/course.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.d.ts +165 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/enrollment.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/index.d.ts +12 -0
- package/dist/providers/learnworlds/interfaces/index.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/index.js +13 -0
- package/dist/providers/learnworlds/interfaces/index.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.d.ts +39 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/onboarding.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.d.ts +108 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/quiz.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/sso.types.d.ts +18 -0
- package/dist/providers/learnworlds/interfaces/sso.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/sso.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/sso.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/sync.types.d.ts +44 -0
- package/dist/providers/learnworlds/interfaces/sync.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/sync.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/sync.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/tag.types.d.ts +17 -0
- package/dist/providers/learnworlds/interfaces/tag.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/tag.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/tag.types.js.map +1 -0
- package/dist/providers/learnworlds/interfaces/user.types.d.ts +198 -0
- package/dist/providers/learnworlds/interfaces/user.types.d.ts.map +1 -0
- package/dist/providers/learnworlds/interfaces/user.types.js +2 -0
- package/dist/providers/learnworlds/interfaces/user.types.js.map +1 -0
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts +111 -7
- package/dist/providers/learnworlds/learnworlds-base.action.d.ts.map +1 -1
- package/dist/providers/learnworlds/learnworlds-base.action.js +293 -56
- package/dist/providers/learnworlds/learnworlds-base.action.js.map +1 -1
- package/package.json +8 -7
- package/src/__tests__/attach-tags.action.test.ts +137 -0
- package/src/__tests__/create-user.action.test.ts +311 -0
- package/src/__tests__/detach-tags.action.test.ts +136 -0
- package/src/__tests__/enroll-user.action.test.ts +283 -0
- package/src/__tests__/get-bulk-data.action.test.ts +649 -0
- package/src/__tests__/get-bundles.action.test.ts +215 -0
- package/src/__tests__/lms.test.ts +275 -184
- package/src/__tests__/onboard-learner.action.test.ts +455 -0
- package/src/__tests__/sso-login.action.test.ts +256 -0
- package/src/__tests__/update-user.action.test.ts +350 -0
- package/src/base/base-lms.action.ts +226 -163
- package/src/providers/learnworlds/actions/attach-tags.action.ts +90 -0
- package/src/providers/learnworlds/actions/create-user.action.ts +291 -235
- package/src/providers/learnworlds/actions/detach-tags.action.ts +90 -0
- package/src/providers/learnworlds/actions/enroll-user.action.ts +326 -220
- package/src/providers/learnworlds/actions/get-bulk-data.action.ts +438 -0
- package/src/providers/learnworlds/actions/get-bundles.action.ts +139 -0
- package/src/providers/learnworlds/actions/get-certificates.action.ts +499 -309
- package/src/providers/learnworlds/actions/get-course-analytics.action.ts +470 -337
- package/src/providers/learnworlds/actions/get-course-details.action.ts +395 -249
- package/src/providers/learnworlds/actions/get-courses.action.ts +508 -565
- package/src/providers/learnworlds/actions/get-quiz-results.action.ts +606 -381
- package/src/providers/learnworlds/actions/get-user-details.action.ts +335 -349
- package/src/providers/learnworlds/actions/get-user-enrollments.action.ts +328 -228
- package/src/providers/learnworlds/actions/get-user-progress.action.ts +522 -571
- package/src/providers/learnworlds/actions/get-users.action.ts +231 -282
- package/src/providers/learnworlds/actions/index.ts +8 -1
- package/src/providers/learnworlds/actions/onboard-learner.action.ts +286 -0
- package/src/providers/learnworlds/actions/sso-login.action.ts +116 -0
- package/src/providers/learnworlds/actions/update-user-progress.action.ts +301 -263
- package/src/providers/learnworlds/actions/update-user.action.ts +181 -0
- package/src/providers/learnworlds/index.ts +4 -1
- package/src/providers/learnworlds/interfaces/bundle.types.ts +17 -0
- package/src/providers/learnworlds/interfaces/certificate.types.ts +69 -0
- package/src/providers/learnworlds/interfaces/common.types.ts +233 -0
- package/src/providers/learnworlds/interfaces/course.types.ts +411 -0
- package/src/providers/learnworlds/interfaces/enrollment.types.ts +176 -0
- package/src/providers/learnworlds/interfaces/index.ts +12 -0
- package/src/providers/learnworlds/interfaces/onboarding.types.ts +41 -0
- package/src/providers/learnworlds/interfaces/quiz.types.ts +118 -0
- package/src/providers/learnworlds/interfaces/sso.types.ts +19 -0
- package/src/providers/learnworlds/interfaces/sync.types.ts +46 -0
- package/src/providers/learnworlds/interfaces/tag.types.ts +18 -0
- package/src/providers/learnworlds/interfaces/user.types.ts +204 -0
- package/src/providers/learnworlds/learnworlds-base.action.ts +468 -210
- package/tsconfig.json +1 -1
- package/dist/__tests__/lms.test.d.ts +0 -2
- package/dist/__tests__/lms.test.d.ts.map +0 -1
- package/dist/__tests__/lms.test.js +0 -232
- package/dist/__tests__/lms.test.js.map +0 -1
|
@@ -2,111 +2,86 @@ import { RegisterClass } from '@memberjunction/global';
|
|
|
2
2
|
import { LearnWorldsBaseAction } from '../learnworlds-base.action';
|
|
3
3
|
import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
4
4
|
import { BaseAction } from '@memberjunction/actions';
|
|
5
|
+
import { UserInfo } from '@memberjunction/core';
|
|
6
|
+
import { GetCoursesParams, GetCoursesResult, CourseCatalogSummary, LearnWorldsCourse } from '../interfaces';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* Raw course shape returned by the LearnWorlds API (snake_case).
|
|
10
|
+
* Kept file-local because it is an API implementation detail.
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*/
|
|
83
|
-
export interface CourseCatalogSummary {
|
|
84
|
-
totalCourses: number;
|
|
85
|
-
publishedCourses: number;
|
|
86
|
-
draftCourses: number;
|
|
87
|
-
freeCourses: number;
|
|
88
|
-
paidCourses: number;
|
|
89
|
-
|
|
90
|
-
categoryCounts: Record<string, number>;
|
|
91
|
-
levelCounts: Record<string, number>;
|
|
92
|
-
languageCounts: Record<string, number>;
|
|
93
|
-
|
|
94
|
-
enrollmentStats: {
|
|
95
|
-
totalEnrollments: number;
|
|
96
|
-
averageEnrollmentsPerCourse: number;
|
|
97
|
-
mostPopularCourses: Array<{
|
|
98
|
-
id: string;
|
|
99
|
-
title: string;
|
|
100
|
-
enrollments: number;
|
|
101
|
-
}>;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
priceStats: {
|
|
105
|
-
averagePrice: number;
|
|
106
|
-
minPrice: number;
|
|
107
|
-
maxPrice: number;
|
|
108
|
-
currency: string;
|
|
109
|
-
};
|
|
12
|
+
interface LWApiCourse {
|
|
13
|
+
id?: string;
|
|
14
|
+
_id?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
subtitle?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
short_description?: string;
|
|
19
|
+
excerpt?: string;
|
|
20
|
+
status?: string;
|
|
21
|
+
visibility?: string;
|
|
22
|
+
access_type?: string;
|
|
23
|
+
is_active?: boolean;
|
|
24
|
+
is_free?: boolean;
|
|
25
|
+
price?: number;
|
|
26
|
+
currency?: string;
|
|
27
|
+
original_price?: number;
|
|
28
|
+
category_id?: string;
|
|
29
|
+
category?: { id?: string; name?: string };
|
|
30
|
+
category_name?: string;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
level?: string;
|
|
33
|
+
difficulty?: string;
|
|
34
|
+
language?: string;
|
|
35
|
+
duration?: number;
|
|
36
|
+
estimated_duration?: number;
|
|
37
|
+
thumbnail_url?: string;
|
|
38
|
+
image?: string;
|
|
39
|
+
cover_image_url?: string;
|
|
40
|
+
cover_image?: string;
|
|
41
|
+
promo_video_url?: string;
|
|
42
|
+
video_url?: string;
|
|
43
|
+
instructor_id?: string;
|
|
44
|
+
instructor?: { id?: string; name?: string; bio?: string; avatar_url?: string };
|
|
45
|
+
instructor_name?: string;
|
|
46
|
+
instructor_bio?: string;
|
|
47
|
+
instructor_avatar?: string;
|
|
48
|
+
author_id?: string;
|
|
49
|
+
author_name?: string;
|
|
50
|
+
total_units?: number;
|
|
51
|
+
sections_count?: number;
|
|
52
|
+
total_lessons?: number;
|
|
53
|
+
lessons_count?: number;
|
|
54
|
+
total_quizzes?: number;
|
|
55
|
+
quizzes_count?: number;
|
|
56
|
+
total_assignments?: number;
|
|
57
|
+
assignments_count?: number;
|
|
58
|
+
total_duration?: number;
|
|
59
|
+
total_enrollments?: number;
|
|
60
|
+
students_count?: number;
|
|
61
|
+
active_enrollments?: number;
|
|
62
|
+
active_students?: number;
|
|
63
|
+
completion_rate?: number;
|
|
64
|
+
average_rating?: number;
|
|
65
|
+
rating?: number;
|
|
66
|
+
total_reviews?: number;
|
|
67
|
+
reviews_count?: number;
|
|
68
|
+
created?: string | number;
|
|
69
|
+
created_at?: string | number;
|
|
70
|
+
updated?: string | number;
|
|
71
|
+
updated_at?: string | number;
|
|
72
|
+
published_at?: string | number;
|
|
73
|
+
enrollment_start?: string | number;
|
|
74
|
+
enrollment_end?: string | number;
|
|
75
|
+
requires_approval?: boolean;
|
|
76
|
+
has_prerequisites?: boolean;
|
|
77
|
+
prerequisites?: string[];
|
|
78
|
+
certificate_available?: boolean;
|
|
79
|
+
has_certificate?: boolean;
|
|
80
|
+
objectives?: string[];
|
|
81
|
+
learning_objectives?: string[];
|
|
82
|
+
target_audience?: string[];
|
|
83
|
+
requirements?: string[];
|
|
84
|
+
prerequisites_text?: string[];
|
|
110
85
|
}
|
|
111
86
|
|
|
112
87
|
/**
|
|
@@ -114,480 +89,448 @@ export interface CourseCatalogSummary {
|
|
|
114
89
|
*/
|
|
115
90
|
@RegisterClass(BaseAction, 'GetLearnWorldsCoursesAction')
|
|
116
91
|
export class GetLearnWorldsCoursesAction extends LearnWorldsBaseAction {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Description of the action
|
|
94
|
+
*/
|
|
95
|
+
public get Description(): string {
|
|
96
|
+
return 'Retrieves the course catalog from LearnWorlds with filtering, search, and sorting options';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Typed public method for direct (non-framework) callers.
|
|
101
|
+
* Sets company context, fetches courses, and returns a strongly-typed result.
|
|
102
|
+
* Throws on error.
|
|
103
|
+
*/
|
|
104
|
+
public async GetCourses(params: GetCoursesParams, contextUser: UserInfo): Promise<GetCoursesResult> {
|
|
105
|
+
this.SetCompanyContext(params.CompanyID);
|
|
106
|
+
|
|
107
|
+
const queryParams = this.buildQueryParams(params);
|
|
108
|
+
|
|
109
|
+
const courses = await this.makeLearnWorldsPaginatedRequest<LWApiCourse>('courses', queryParams, contextUser);
|
|
110
|
+
|
|
111
|
+
const mappedCourses: LearnWorldsCourse[] = courses.map((course) => this.mapLearnWorldsCourse(course));
|
|
112
|
+
const summary = this.calculateCourseCatalogSummary(mappedCourses);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
Courses: mappedCourses,
|
|
116
|
+
TotalCount: mappedCourses.length,
|
|
117
|
+
Summary: summary,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Framework entry-point – thin wrapper around the typed public method.
|
|
123
|
+
*/
|
|
124
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
125
|
+
const { Params, ContextUser } = params;
|
|
126
|
+
this.params = Params;
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
const typedParams = this.extractGetCoursesParams(Params);
|
|
130
|
+
const result = await this.GetCourses(typedParams, ContextUser);
|
|
131
|
+
|
|
132
|
+
this.setOutputParam(Params, 'Courses', result.Courses);
|
|
133
|
+
this.setOutputParam(Params, 'TotalCount', result.TotalCount);
|
|
134
|
+
this.setOutputParam(Params, 'Summary', result.Summary);
|
|
135
|
+
|
|
136
|
+
return this.buildSuccessResult(`Successfully retrieved ${result.TotalCount} courses from LearnWorlds`, Params);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
const msg = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
139
|
+
return this.buildErrorResult('ERROR', msg, Params);
|
|
123
140
|
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Extract typed params from framework ActionParam[]
|
|
145
|
+
*/
|
|
146
|
+
private extractGetCoursesParams(params: ActionParam[]): GetCoursesParams {
|
|
147
|
+
return {
|
|
148
|
+
CompanyID: this.getRequiredStringParam(params, 'CompanyID'),
|
|
149
|
+
SearchText: this.getOptionalStringParam(params, 'SearchText'),
|
|
150
|
+
Status: this.getOptionalStringParam(params, 'Status'),
|
|
151
|
+
CategoryID: this.getOptionalStringParam(params, 'CategoryID'),
|
|
152
|
+
Level: this.getOptionalStringParam(params, 'Level'),
|
|
153
|
+
Language: this.getOptionalStringParam(params, 'Language'),
|
|
154
|
+
OnlyFree: this.getOptionalBooleanParam(params, 'OnlyFree', false),
|
|
155
|
+
MinPrice: this.getOptionalNumberParam(params, 'MinPrice', undefined),
|
|
156
|
+
MaxPrice: this.getOptionalNumberParam(params, 'MaxPrice', undefined),
|
|
157
|
+
Tags: this.getOptionalStringParam(params, 'Tags'),
|
|
158
|
+
InstructorID: this.getOptionalStringParam(params, 'InstructorID'),
|
|
159
|
+
CreatedAfter: this.getOptionalStringParam(params, 'CreatedAfter'),
|
|
160
|
+
CreatedBefore: this.getOptionalStringParam(params, 'CreatedBefore'),
|
|
161
|
+
SortBy: this.getOptionalStringParam(params, 'SortBy'),
|
|
162
|
+
SortOrder: (this.getOptionalStringParam(params, 'SortOrder') || 'desc') as 'asc' | 'desc',
|
|
163
|
+
IncludeEnrollmentStats: this.getOptionalBooleanParam(params, 'IncludeEnrollmentStats', true),
|
|
164
|
+
MaxResults: this.getOptionalNumberParam(params, 'MaxResults', LearnWorldsBaseAction.LW_MAX_PAGE_SIZE),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
124
167
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const contextUser = params.ContextUser;
|
|
131
|
-
if (!contextUser) {
|
|
132
|
-
return {
|
|
133
|
-
Success: false,
|
|
134
|
-
ResultCode: 'ERROR',
|
|
135
|
-
Message: 'Context user is required for LearnWorlds API calls'
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Store params for base class methods
|
|
140
|
-
this.params = params.Params;
|
|
141
|
-
|
|
142
|
-
// Build query parameters
|
|
143
|
-
const queryParams: Record<string, any> = {};
|
|
144
|
-
|
|
145
|
-
// Search filter
|
|
146
|
-
const searchText = this.getParamValue(params.Params, 'SearchText');
|
|
147
|
-
if (searchText) {
|
|
148
|
-
queryParams.search = searchText;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Status filter
|
|
152
|
-
const status = this.getParamValue(params.Params, 'Status');
|
|
153
|
-
if (status) {
|
|
154
|
-
queryParams.status = status;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Category filter
|
|
158
|
-
const categoryId = this.getParamValue(params.Params, 'CategoryID');
|
|
159
|
-
if (categoryId) {
|
|
160
|
-
queryParams.category_id = categoryId;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Level filter
|
|
164
|
-
const level = this.getParamValue(params.Params, 'Level');
|
|
165
|
-
if (level) {
|
|
166
|
-
queryParams.level = level;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Language filter
|
|
170
|
-
const language = this.getParamValue(params.Params, 'Language');
|
|
171
|
-
if (language) {
|
|
172
|
-
queryParams.language = language;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Price filters
|
|
176
|
-
const onlyFree = this.getParamValue(params.Params, 'OnlyFree');
|
|
177
|
-
if (onlyFree) {
|
|
178
|
-
queryParams.is_free = true;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const minPrice = this.getParamValue(params.Params, 'MinPrice');
|
|
182
|
-
if (minPrice !== null && minPrice !== undefined) {
|
|
183
|
-
queryParams.min_price = minPrice;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const maxPrice = this.getParamValue(params.Params, 'MaxPrice');
|
|
187
|
-
if (maxPrice !== null && maxPrice !== undefined) {
|
|
188
|
-
queryParams.max_price = maxPrice;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Tags filter
|
|
192
|
-
const tags = this.getParamValue(params.Params, 'Tags');
|
|
193
|
-
if (tags) {
|
|
194
|
-
queryParams.tags = tags;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Instructor filter
|
|
198
|
-
const instructorId = this.getParamValue(params.Params, 'InstructorID');
|
|
199
|
-
if (instructorId) {
|
|
200
|
-
queryParams.instructor_id = instructorId;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Date filters
|
|
204
|
-
const createdAfter = this.getParamValue(params.Params, 'CreatedAfter');
|
|
205
|
-
if (createdAfter) {
|
|
206
|
-
queryParams.created_after = this.formatLearnWorldsDate(new Date(createdAfter));
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const createdBefore = this.getParamValue(params.Params, 'CreatedBefore');
|
|
210
|
-
if (createdBefore) {
|
|
211
|
-
queryParams.created_before = this.formatLearnWorldsDate(new Date(createdBefore));
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Sorting
|
|
215
|
-
const sortBy = this.getParamValue(params.Params, 'SortBy') || 'created';
|
|
216
|
-
const sortOrder = this.getParamValue(params.Params, 'SortOrder') || 'desc';
|
|
217
|
-
queryParams.sort = `${sortOrder === 'asc' ? '' : '-'}${sortBy}`;
|
|
218
|
-
|
|
219
|
-
// Include extra data
|
|
220
|
-
const includeEnrollmentStats = this.getParamValue(params.Params, 'IncludeEnrollmentStats') ?? true;
|
|
221
|
-
if (includeEnrollmentStats) {
|
|
222
|
-
queryParams.include = 'enrollment_stats';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// Limit for pagination
|
|
226
|
-
const maxResults = this.getParamValue(params.Params, 'MaxResults') || 100;
|
|
227
|
-
queryParams.limit = Math.min(maxResults, 100);
|
|
228
|
-
|
|
229
|
-
// Make the API request
|
|
230
|
-
const courses = await this.makeLearnWorldsPaginatedRequest<any>(
|
|
231
|
-
'courses',
|
|
232
|
-
queryParams,
|
|
233
|
-
contextUser
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
// Map to our interface
|
|
237
|
-
const mappedCourses: LearnWorldsCourse[] = courses.map(course => this.mapLearnWorldsCourse(course));
|
|
238
|
-
|
|
239
|
-
// Calculate summary
|
|
240
|
-
const summary = this.calculateCourseCatalogSummary(mappedCourses);
|
|
241
|
-
|
|
242
|
-
// Create output parameters
|
|
243
|
-
if (!params.Params.find(p => p.Name === 'Courses')) {
|
|
244
|
-
params.Params.push({
|
|
245
|
-
Name: 'Courses',
|
|
246
|
-
Type: 'Output',
|
|
247
|
-
Value: mappedCourses
|
|
248
|
-
});
|
|
249
|
-
} else {
|
|
250
|
-
params.Params.find(p => p.Name === 'Courses')!.Value = mappedCourses;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (!params.Params.find(p => p.Name === 'TotalCount')) {
|
|
254
|
-
params.Params.push({
|
|
255
|
-
Name: 'TotalCount',
|
|
256
|
-
Type: 'Output',
|
|
257
|
-
Value: mappedCourses.length
|
|
258
|
-
});
|
|
259
|
-
} else {
|
|
260
|
-
params.Params.find(p => p.Name === 'TotalCount')!.Value = mappedCourses.length;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (!params.Params.find(p => p.Name === 'Summary')) {
|
|
264
|
-
params.Params.push({
|
|
265
|
-
Name: 'Summary',
|
|
266
|
-
Type: 'Output',
|
|
267
|
-
Value: summary
|
|
268
|
-
});
|
|
269
|
-
} else {
|
|
270
|
-
params.Params.find(p => p.Name === 'Summary')!.Value = summary;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
Success: true,
|
|
275
|
-
ResultCode: 'SUCCESS',
|
|
276
|
-
Message: `Successfully retrieved ${mappedCourses.length} courses from LearnWorlds`
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
} catch (error) {
|
|
280
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
281
|
-
return {
|
|
282
|
-
Success: false,
|
|
283
|
-
ResultCode: 'ERROR',
|
|
284
|
-
Message: errorMessage
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
}
|
|
168
|
+
/**
|
|
169
|
+
* Build query parameters for the LearnWorlds API request
|
|
170
|
+
*/
|
|
171
|
+
private buildQueryParams(params: GetCoursesParams): Record<string, string | number | boolean> {
|
|
172
|
+
const queryParams: Record<string, string | number | boolean> = {};
|
|
288
173
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
*/
|
|
292
|
-
private mapLearnWorldsCourse(lwCourse: any): LearnWorldsCourse {
|
|
293
|
-
return {
|
|
294
|
-
id: lwCourse.id || lwCourse._id,
|
|
295
|
-
title: lwCourse.title,
|
|
296
|
-
subtitle: lwCourse.subtitle,
|
|
297
|
-
description: lwCourse.description,
|
|
298
|
-
shortDescription: lwCourse.short_description || lwCourse.excerpt,
|
|
299
|
-
|
|
300
|
-
status: this.mapCourseStatus(lwCourse.status),
|
|
301
|
-
visibility: this.mapCourseVisibility(lwCourse.visibility || lwCourse.access_type),
|
|
302
|
-
isActive: lwCourse.is_active !== false,
|
|
303
|
-
isFree: lwCourse.is_free || lwCourse.price === 0,
|
|
304
|
-
|
|
305
|
-
price: lwCourse.price,
|
|
306
|
-
currency: lwCourse.currency || 'USD',
|
|
307
|
-
originalPrice: lwCourse.original_price,
|
|
308
|
-
discountPercentage: this.calculateDiscountPercentage(lwCourse.original_price, lwCourse.price),
|
|
309
|
-
|
|
310
|
-
categoryId: lwCourse.category_id || lwCourse.category?.id,
|
|
311
|
-
categoryName: lwCourse.category_name || lwCourse.category?.name,
|
|
312
|
-
tags: lwCourse.tags || [],
|
|
313
|
-
level: this.mapCourseLevel(lwCourse.level || lwCourse.difficulty),
|
|
314
|
-
language: lwCourse.language || 'en',
|
|
315
|
-
duration: lwCourse.duration || lwCourse.estimated_duration,
|
|
316
|
-
|
|
317
|
-
thumbnailUrl: lwCourse.thumbnail_url || lwCourse.image,
|
|
318
|
-
coverImageUrl: lwCourse.cover_image_url || lwCourse.cover_image,
|
|
319
|
-
promoVideoUrl: lwCourse.promo_video_url || lwCourse.video_url,
|
|
320
|
-
|
|
321
|
-
instructorId: lwCourse.instructor_id || lwCourse.instructor?.id || lwCourse.author_id,
|
|
322
|
-
instructorName: lwCourse.instructor_name || lwCourse.instructor?.name || lwCourse.author_name,
|
|
323
|
-
instructorBio: lwCourse.instructor_bio || lwCourse.instructor?.bio,
|
|
324
|
-
instructorAvatarUrl: lwCourse.instructor_avatar || lwCourse.instructor?.avatar_url,
|
|
325
|
-
|
|
326
|
-
totalUnits: lwCourse.total_units || lwCourse.sections_count || 0,
|
|
327
|
-
totalLessons: lwCourse.total_lessons || lwCourse.lessons_count || 0,
|
|
328
|
-
totalQuizzes: lwCourse.total_quizzes || lwCourse.quizzes_count || 0,
|
|
329
|
-
totalAssignments: lwCourse.total_assignments || lwCourse.assignments_count || 0,
|
|
330
|
-
estimatedDuration: lwCourse.estimated_duration || lwCourse.total_duration,
|
|
331
|
-
|
|
332
|
-
totalEnrollments: lwCourse.total_enrollments || lwCourse.students_count || 0,
|
|
333
|
-
activeEnrollments: lwCourse.active_enrollments || lwCourse.active_students || 0,
|
|
334
|
-
completionRate: lwCourse.completion_rate || 0,
|
|
335
|
-
averageRating: lwCourse.average_rating || lwCourse.rating,
|
|
336
|
-
totalReviews: lwCourse.total_reviews || lwCourse.reviews_count,
|
|
337
|
-
|
|
338
|
-
createdAt: this.parseLearnWorldsDate(lwCourse.created || lwCourse.created_at),
|
|
339
|
-
updatedAt: this.parseLearnWorldsDate(lwCourse.updated || lwCourse.updated_at),
|
|
340
|
-
publishedAt: lwCourse.published_at ? this.parseLearnWorldsDate(lwCourse.published_at) : undefined,
|
|
341
|
-
enrollmentStartDate: lwCourse.enrollment_start ? this.parseLearnWorldsDate(lwCourse.enrollment_start) : undefined,
|
|
342
|
-
enrollmentEndDate: lwCourse.enrollment_end ? this.parseLearnWorldsDate(lwCourse.enrollment_end) : undefined,
|
|
343
|
-
|
|
344
|
-
requiresApproval: lwCourse.requires_approval || false,
|
|
345
|
-
hasPrerequisites: lwCourse.has_prerequisites || false,
|
|
346
|
-
prerequisites: lwCourse.prerequisites || [],
|
|
347
|
-
certificateAvailable: lwCourse.certificate_available || lwCourse.has_certificate || false,
|
|
348
|
-
|
|
349
|
-
objectives: lwCourse.objectives || lwCourse.learning_objectives || [],
|
|
350
|
-
targetAudience: lwCourse.target_audience || [],
|
|
351
|
-
requirements: lwCourse.requirements || lwCourse.prerequisites_text || []
|
|
352
|
-
};
|
|
174
|
+
if (params.SearchText) {
|
|
175
|
+
queryParams.search = params.SearchText;
|
|
353
176
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
* Map course status
|
|
357
|
-
*/
|
|
358
|
-
private mapCourseStatus(status: string): 'published' | 'draft' | 'coming_soon' {
|
|
359
|
-
const statusMap: Record<string, 'published' | 'draft' | 'coming_soon'> = {
|
|
360
|
-
'published': 'published',
|
|
361
|
-
'active': 'published',
|
|
362
|
-
'draft': 'draft',
|
|
363
|
-
'unpublished': 'draft',
|
|
364
|
-
'coming_soon': 'coming_soon',
|
|
365
|
-
'upcoming': 'coming_soon'
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
return statusMap[status?.toLowerCase()] || 'draft';
|
|
177
|
+
if (params.Status) {
|
|
178
|
+
queryParams.status = params.Status;
|
|
369
179
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
180
|
+
if (params.CategoryID) {
|
|
181
|
+
queryParams.category_id = params.CategoryID;
|
|
182
|
+
}
|
|
183
|
+
if (params.Level) {
|
|
184
|
+
queryParams.level = params.Level;
|
|
185
|
+
}
|
|
186
|
+
if (params.Language) {
|
|
187
|
+
queryParams.language = params.Language;
|
|
188
|
+
}
|
|
189
|
+
if (params.OnlyFree) {
|
|
190
|
+
queryParams.is_free = true;
|
|
191
|
+
}
|
|
192
|
+
if (params.MinPrice != null && params.MinPrice > 0) {
|
|
193
|
+
queryParams.min_price = params.MinPrice;
|
|
194
|
+
}
|
|
195
|
+
if (params.MaxPrice != null && params.MaxPrice > 0) {
|
|
196
|
+
queryParams.max_price = params.MaxPrice;
|
|
197
|
+
}
|
|
198
|
+
if (params.Tags) {
|
|
199
|
+
queryParams.tags = params.Tags;
|
|
200
|
+
}
|
|
201
|
+
if (params.InstructorID) {
|
|
202
|
+
queryParams.instructor_id = params.InstructorID;
|
|
203
|
+
}
|
|
204
|
+
if (params.CreatedAfter) {
|
|
205
|
+
queryParams.created_after = this.formatLearnWorldsDate(new Date(params.CreatedAfter));
|
|
206
|
+
}
|
|
207
|
+
if (params.CreatedBefore) {
|
|
208
|
+
queryParams.created_before = this.formatLearnWorldsDate(new Date(params.CreatedBefore));
|
|
385
209
|
}
|
|
386
210
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
'introductory': 'beginner',
|
|
395
|
-
'intermediate': 'intermediate',
|
|
396
|
-
'medium': 'intermediate',
|
|
397
|
-
'advanced': 'advanced',
|
|
398
|
-
'expert': 'advanced',
|
|
399
|
-
'all': 'all',
|
|
400
|
-
'any': 'all',
|
|
401
|
-
'mixed': 'all'
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
return levelMap[level?.toLowerCase()] || 'all';
|
|
211
|
+
const sortBy = params.SortBy || 'created';
|
|
212
|
+
const sortOrder = params.SortOrder || 'desc';
|
|
213
|
+
queryParams.sort = `${sortOrder === 'asc' ? '' : '-'}${sortBy}`;
|
|
214
|
+
|
|
215
|
+
const includeEnrollmentStats = params.IncludeEnrollmentStats ?? true;
|
|
216
|
+
if (includeEnrollmentStats) {
|
|
217
|
+
queryParams.include = 'enrollment_stats';
|
|
405
218
|
}
|
|
406
219
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
220
|
+
const maxResults = params.MaxResults || 100;
|
|
221
|
+
queryParams.limit = Math.min(maxResults, 100);
|
|
222
|
+
|
|
223
|
+
return queryParams;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Map LearnWorlds course data to our interface
|
|
228
|
+
*/
|
|
229
|
+
private mapLearnWorldsCourse(lwCourse: LWApiCourse): LearnWorldsCourse {
|
|
230
|
+
return {
|
|
231
|
+
id: lwCourse.id || lwCourse._id || '',
|
|
232
|
+
title: lwCourse.title,
|
|
233
|
+
subtitle: lwCourse.subtitle,
|
|
234
|
+
description: lwCourse.description,
|
|
235
|
+
shortDescription: lwCourse.short_description || lwCourse.excerpt,
|
|
236
|
+
|
|
237
|
+
status: this.mapCourseStatus(lwCourse.status || ''),
|
|
238
|
+
visibility: this.mapCourseVisibility(lwCourse.visibility || lwCourse.access_type || ''),
|
|
239
|
+
isActive: lwCourse.is_active !== false,
|
|
240
|
+
isFree: lwCourse.is_free || lwCourse.price === 0 || false,
|
|
241
|
+
|
|
242
|
+
price: lwCourse.price,
|
|
243
|
+
currency: lwCourse.currency || 'USD',
|
|
244
|
+
originalPrice: lwCourse.original_price,
|
|
245
|
+
discountPercentage: this.calculateDiscountPercentage(lwCourse.original_price, lwCourse.price),
|
|
246
|
+
|
|
247
|
+
categoryId: lwCourse.category_id || lwCourse.category?.id,
|
|
248
|
+
categoryName: lwCourse.category_name || lwCourse.category?.name,
|
|
249
|
+
tags: lwCourse.tags || [],
|
|
250
|
+
level: this.mapCourseLevel(lwCourse.level || lwCourse.difficulty || ''),
|
|
251
|
+
language: lwCourse.language || 'en',
|
|
252
|
+
duration: lwCourse.duration || lwCourse.estimated_duration,
|
|
253
|
+
|
|
254
|
+
thumbnailUrl: lwCourse.thumbnail_url || lwCourse.image,
|
|
255
|
+
coverImageUrl: lwCourse.cover_image_url || lwCourse.cover_image,
|
|
256
|
+
promoVideoUrl: lwCourse.promo_video_url || lwCourse.video_url,
|
|
257
|
+
|
|
258
|
+
instructorId: lwCourse.instructor_id || lwCourse.instructor?.id || lwCourse.author_id,
|
|
259
|
+
instructorName: lwCourse.instructor_name || lwCourse.instructor?.name || lwCourse.author_name,
|
|
260
|
+
instructorBio: lwCourse.instructor_bio || lwCourse.instructor?.bio,
|
|
261
|
+
instructorAvatarUrl: lwCourse.instructor_avatar || lwCourse.instructor?.avatar_url,
|
|
262
|
+
|
|
263
|
+
totalUnits: lwCourse.total_units || lwCourse.sections_count || 0,
|
|
264
|
+
totalLessons: lwCourse.total_lessons || lwCourse.lessons_count || 0,
|
|
265
|
+
totalQuizzes: lwCourse.total_quizzes || lwCourse.quizzes_count || 0,
|
|
266
|
+
totalAssignments: lwCourse.total_assignments || lwCourse.assignments_count || 0,
|
|
267
|
+
estimatedDuration: lwCourse.estimated_duration || lwCourse.total_duration,
|
|
268
|
+
|
|
269
|
+
totalEnrollments: lwCourse.total_enrollments || lwCourse.students_count || 0,
|
|
270
|
+
activeEnrollments: lwCourse.active_enrollments || lwCourse.active_students || 0,
|
|
271
|
+
completionRate: lwCourse.completion_rate || 0,
|
|
272
|
+
averageRating: lwCourse.average_rating || lwCourse.rating,
|
|
273
|
+
totalReviews: lwCourse.total_reviews || lwCourse.reviews_count,
|
|
274
|
+
|
|
275
|
+
createdAt: this.parseLearnWorldsDate(lwCourse.created || lwCourse.created_at || ''),
|
|
276
|
+
updatedAt: this.parseLearnWorldsDate(lwCourse.updated || lwCourse.updated_at || ''),
|
|
277
|
+
publishedAt: lwCourse.published_at ? this.parseLearnWorldsDate(lwCourse.published_at) : undefined,
|
|
278
|
+
enrollmentStartDate: lwCourse.enrollment_start ? this.parseLearnWorldsDate(lwCourse.enrollment_start) : undefined,
|
|
279
|
+
enrollmentEndDate: lwCourse.enrollment_end ? this.parseLearnWorldsDate(lwCourse.enrollment_end) : undefined,
|
|
280
|
+
|
|
281
|
+
requiresApproval: lwCourse.requires_approval || false,
|
|
282
|
+
hasPrerequisites: lwCourse.has_prerequisites || false,
|
|
283
|
+
prerequisites: lwCourse.prerequisites || [],
|
|
284
|
+
certificateAvailable: lwCourse.certificate_available || lwCourse.has_certificate || false,
|
|
285
|
+
|
|
286
|
+
objectives: lwCourse.objectives || lwCourse.learning_objectives || [],
|
|
287
|
+
targetAudience: lwCourse.target_audience || [],
|
|
288
|
+
requirements: lwCourse.requirements || lwCourse.prerequisites_text || [],
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Map course status
|
|
294
|
+
*/
|
|
295
|
+
private mapCourseStatus(status: string): 'published' | 'draft' | 'coming_soon' {
|
|
296
|
+
const statusMap: Record<string, 'published' | 'draft' | 'coming_soon'> = {
|
|
297
|
+
published: 'published',
|
|
298
|
+
active: 'published',
|
|
299
|
+
draft: 'draft',
|
|
300
|
+
unpublished: 'draft',
|
|
301
|
+
coming_soon: 'coming_soon',
|
|
302
|
+
upcoming: 'coming_soon',
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
return statusMap[status?.toLowerCase()] || 'draft';
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Map course visibility
|
|
310
|
+
*/
|
|
311
|
+
private mapCourseVisibility(visibility: string): 'public' | 'private' | 'hidden' {
|
|
312
|
+
const visibilityMap: Record<string, 'public' | 'private' | 'hidden'> = {
|
|
313
|
+
public: 'public',
|
|
314
|
+
open: 'public',
|
|
315
|
+
private: 'private',
|
|
316
|
+
closed: 'private',
|
|
317
|
+
hidden: 'hidden',
|
|
318
|
+
unlisted: 'hidden',
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
return visibilityMap[visibility?.toLowerCase()] || 'public';
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Map course level
|
|
326
|
+
*/
|
|
327
|
+
private mapCourseLevel(level: string): 'beginner' | 'intermediate' | 'advanced' | 'all' {
|
|
328
|
+
const levelMap: Record<string, 'beginner' | 'intermediate' | 'advanced' | 'all'> = {
|
|
329
|
+
beginner: 'beginner',
|
|
330
|
+
basic: 'beginner',
|
|
331
|
+
introductory: 'beginner',
|
|
332
|
+
intermediate: 'intermediate',
|
|
333
|
+
medium: 'intermediate',
|
|
334
|
+
advanced: 'advanced',
|
|
335
|
+
expert: 'advanced',
|
|
336
|
+
all: 'all',
|
|
337
|
+
any: 'all',
|
|
338
|
+
mixed: 'all',
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
return levelMap[level?.toLowerCase()] || 'all';
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Calculate discount percentage
|
|
346
|
+
*/
|
|
347
|
+
private calculateDiscountPercentage(originalPrice?: number, currentPrice?: number): number | undefined {
|
|
348
|
+
if (!originalPrice || !currentPrice || originalPrice <= currentPrice) {
|
|
349
|
+
return undefined;
|
|
416
350
|
}
|
|
417
351
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
id: c.id,
|
|
483
|
-
title: c.title,
|
|
484
|
-
enrollments: c.totalEnrollments
|
|
485
|
-
}));
|
|
486
|
-
|
|
487
|
-
// Calculate price statistics for paid courses
|
|
488
|
-
const paidCourses = courses.filter(c => !c.isFree && c.price !== undefined);
|
|
489
|
-
if (paidCourses.length > 0) {
|
|
490
|
-
const prices = paidCourses.map(c => c.price!);
|
|
491
|
-
summary.priceStats = {
|
|
492
|
-
averagePrice: Math.round(prices.reduce((sum, p) => sum + p, 0) / prices.length),
|
|
493
|
-
minPrice: Math.min(...prices),
|
|
494
|
-
maxPrice: Math.max(...prices),
|
|
495
|
-
currency: paidCourses[0].currency || 'USD'
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
return summary;
|
|
352
|
+
return Math.round(((originalPrice - currentPrice) / originalPrice) * 100);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Calculate course catalog summary
|
|
357
|
+
*/
|
|
358
|
+
private calculateCourseCatalogSummary(courses: LearnWorldsCourse[]): CourseCatalogSummary {
|
|
359
|
+
const summary: CourseCatalogSummary = {
|
|
360
|
+
totalCourses: courses.length,
|
|
361
|
+
publishedCourses: courses.filter((c) => c.status === 'published').length,
|
|
362
|
+
draftCourses: courses.filter((c) => c.status === 'draft').length,
|
|
363
|
+
freeCourses: courses.filter((c) => c.isFree).length,
|
|
364
|
+
paidCourses: courses.filter((c) => !c.isFree).length,
|
|
365
|
+
|
|
366
|
+
categoryCounts: {},
|
|
367
|
+
levelCounts: {},
|
|
368
|
+
languageCounts: {},
|
|
369
|
+
|
|
370
|
+
enrollmentStats: {
|
|
371
|
+
totalEnrollments: 0,
|
|
372
|
+
averageEnrollmentsPerCourse: 0,
|
|
373
|
+
mostPopularCourses: [],
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
priceStats: {
|
|
377
|
+
averagePrice: 0,
|
|
378
|
+
minPrice: 0,
|
|
379
|
+
maxPrice: 0,
|
|
380
|
+
currency: 'USD',
|
|
381
|
+
},
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
this.populateCategoryCounts(courses, summary);
|
|
385
|
+
this.populateEnrollmentStats(courses, summary);
|
|
386
|
+
this.populatePriceStats(courses, summary);
|
|
387
|
+
|
|
388
|
+
return summary;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Populate category, level, and language counts in the summary
|
|
393
|
+
*/
|
|
394
|
+
private populateCategoryCounts(courses: LearnWorldsCourse[], summary: CourseCatalogSummary): void {
|
|
395
|
+
courses.forEach((course) => {
|
|
396
|
+
if (course.categoryName) {
|
|
397
|
+
summary.categoryCounts[course.categoryName] = (summary.categoryCounts[course.categoryName] || 0) + 1;
|
|
398
|
+
}
|
|
399
|
+
if (course.level) {
|
|
400
|
+
summary.levelCounts[course.level] = (summary.levelCounts[course.level] || 0) + 1;
|
|
401
|
+
}
|
|
402
|
+
if (course.language) {
|
|
403
|
+
summary.languageCounts[course.language] = (summary.languageCounts[course.language] || 0) + 1;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
summary.enrollmentStats.totalEnrollments += course.totalEnrollments;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Populate enrollment statistics in the summary
|
|
412
|
+
*/
|
|
413
|
+
private populateEnrollmentStats(courses: LearnWorldsCourse[], summary: CourseCatalogSummary): void {
|
|
414
|
+
if (courses.length > 0) {
|
|
415
|
+
summary.enrollmentStats.averageEnrollmentsPerCourse = Math.round(summary.enrollmentStats.totalEnrollments / courses.length);
|
|
500
416
|
}
|
|
501
417
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
Type: 'Input',
|
|
527
|
-
Value: null
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
Name: 'Language',
|
|
531
|
-
Type: 'Input',
|
|
532
|
-
Value: null
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
Name: 'OnlyFree',
|
|
536
|
-
Type: 'Input',
|
|
537
|
-
Value: false
|
|
538
|
-
},
|
|
539
|
-
{
|
|
540
|
-
Name: 'MinPrice',
|
|
541
|
-
Type: 'Input',
|
|
542
|
-
Value: null
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
Name: 'MaxPrice',
|
|
546
|
-
Type: 'Input',
|
|
547
|
-
Value: null
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
Name: 'Tags',
|
|
551
|
-
Type: 'Input',
|
|
552
|
-
Value: null
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
Name: 'InstructorID',
|
|
556
|
-
Type: 'Input',
|
|
557
|
-
Value: null
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
Name: 'CreatedAfter',
|
|
561
|
-
Type: 'Input',
|
|
562
|
-
Value: null
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
Name: 'CreatedBefore',
|
|
566
|
-
Type: 'Input',
|
|
567
|
-
Value: null
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
Name: 'SortBy',
|
|
571
|
-
Type: 'Input',
|
|
572
|
-
Value: 'created'
|
|
573
|
-
},
|
|
574
|
-
{
|
|
575
|
-
Name: 'SortOrder',
|
|
576
|
-
Type: 'Input',
|
|
577
|
-
Value: 'desc'
|
|
578
|
-
},
|
|
579
|
-
{
|
|
580
|
-
Name: 'IncludeEnrollmentStats',
|
|
581
|
-
Type: 'Input',
|
|
582
|
-
Value: true
|
|
583
|
-
},
|
|
584
|
-
{
|
|
585
|
-
Name: 'MaxResults',
|
|
586
|
-
Type: 'Input',
|
|
587
|
-
Value: 100
|
|
588
|
-
}
|
|
589
|
-
];
|
|
590
|
-
|
|
591
|
-
return [...baseParams, ...specificParams];
|
|
418
|
+
summary.enrollmentStats.mostPopularCourses = courses
|
|
419
|
+
.filter((c) => c.totalEnrollments > 0)
|
|
420
|
+
.sort((a, b) => b.totalEnrollments - a.totalEnrollments)
|
|
421
|
+
.slice(0, 5)
|
|
422
|
+
.map((c) => ({
|
|
423
|
+
id: c.id,
|
|
424
|
+
title: c.title,
|
|
425
|
+
enrollments: c.totalEnrollments,
|
|
426
|
+
}));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Populate price statistics in the summary
|
|
431
|
+
*/
|
|
432
|
+
private populatePriceStats(courses: LearnWorldsCourse[], summary: CourseCatalogSummary): void {
|
|
433
|
+
const paidCourses = courses.filter((c) => !c.isFree && c.price !== undefined);
|
|
434
|
+
if (paidCourses.length > 0) {
|
|
435
|
+
const prices = paidCourses.map((c) => c.price!);
|
|
436
|
+
summary.priceStats = {
|
|
437
|
+
averagePrice: Math.round(prices.reduce((sum, p) => sum + p, 0) / prices.length),
|
|
438
|
+
minPrice: Math.min(...prices),
|
|
439
|
+
maxPrice: Math.max(...prices),
|
|
440
|
+
currency: paidCourses[0].currency || 'USD',
|
|
441
|
+
};
|
|
592
442
|
}
|
|
593
|
-
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Define the parameters for this action
|
|
447
|
+
*/
|
|
448
|
+
public get Params(): ActionParam[] {
|
|
449
|
+
const baseParams = this.getCommonLMSParams();
|
|
450
|
+
|
|
451
|
+
const specificParams: ActionParam[] = [
|
|
452
|
+
{
|
|
453
|
+
Name: 'SearchText',
|
|
454
|
+
Type: 'Input',
|
|
455
|
+
Value: null,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
Name: 'Status',
|
|
459
|
+
Type: 'Input',
|
|
460
|
+
Value: null,
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
Name: 'CategoryID',
|
|
464
|
+
Type: 'Input',
|
|
465
|
+
Value: null,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
Name: 'Level',
|
|
469
|
+
Type: 'Input',
|
|
470
|
+
Value: null,
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
Name: 'Language',
|
|
474
|
+
Type: 'Input',
|
|
475
|
+
Value: null,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
Name: 'OnlyFree',
|
|
479
|
+
Type: 'Input',
|
|
480
|
+
Value: false,
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
Name: 'MinPrice',
|
|
484
|
+
Type: 'Input',
|
|
485
|
+
Value: null,
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
Name: 'MaxPrice',
|
|
489
|
+
Type: 'Input',
|
|
490
|
+
Value: null,
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
Name: 'Tags',
|
|
494
|
+
Type: 'Input',
|
|
495
|
+
Value: null,
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
Name: 'InstructorID',
|
|
499
|
+
Type: 'Input',
|
|
500
|
+
Value: null,
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
Name: 'CreatedAfter',
|
|
504
|
+
Type: 'Input',
|
|
505
|
+
Value: null,
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
Name: 'CreatedBefore',
|
|
509
|
+
Type: 'Input',
|
|
510
|
+
Value: null,
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
Name: 'SortBy',
|
|
514
|
+
Type: 'Input',
|
|
515
|
+
Value: 'created',
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
Name: 'SortOrder',
|
|
519
|
+
Type: 'Input',
|
|
520
|
+
Value: 'desc',
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
Name: 'IncludeEnrollmentStats',
|
|
524
|
+
Type: 'Input',
|
|
525
|
+
Value: true,
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
Name: 'MaxResults',
|
|
529
|
+
Type: 'Input',
|
|
530
|
+
Value: 100,
|
|
531
|
+
},
|
|
532
|
+
];
|
|
533
|
+
|
|
534
|
+
return [...baseParams, ...specificParams];
|
|
535
|
+
}
|
|
536
|
+
}
|