@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,267 +2,413 @@ 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 {
|
|
7
|
+
GetCourseDetailsParams,
|
|
8
|
+
GetCourseDetailsResult,
|
|
9
|
+
CourseDetailsData,
|
|
10
|
+
CourseModule,
|
|
11
|
+
CourseLesson,
|
|
12
|
+
CourseInstructor,
|
|
13
|
+
CourseStats,
|
|
14
|
+
CourseDetailsSummary,
|
|
15
|
+
} from '../interfaces';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Raw API shape for a course response from LearnWorlds
|
|
19
|
+
*/
|
|
20
|
+
interface LWApiCourseResponse {
|
|
21
|
+
success?: boolean;
|
|
22
|
+
data?: LWApiCourseData;
|
|
23
|
+
message?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LWApiCourseData {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
slug?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
short_description?: string;
|
|
32
|
+
status?: string;
|
|
33
|
+
price?: number;
|
|
34
|
+
original_price?: number;
|
|
35
|
+
currency?: string;
|
|
36
|
+
level?: string;
|
|
37
|
+
language?: string;
|
|
38
|
+
duration?: number;
|
|
39
|
+
total_enrollments?: number;
|
|
40
|
+
average_rating?: number;
|
|
41
|
+
total_ratings?: number;
|
|
42
|
+
tags?: string[];
|
|
43
|
+
categories?: string[];
|
|
44
|
+
image_url?: string;
|
|
45
|
+
video_url?: string;
|
|
46
|
+
certificate_enabled?: boolean;
|
|
47
|
+
created_at?: string;
|
|
48
|
+
updated_at?: string;
|
|
49
|
+
published_at?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Raw API shape for sections/modules response
|
|
54
|
+
*/
|
|
55
|
+
interface LWApiSectionsResponse {
|
|
56
|
+
success?: boolean;
|
|
57
|
+
data?: LWApiModuleData[] | { data: LWApiModuleData[] };
|
|
58
|
+
message?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface LWApiModuleData {
|
|
62
|
+
id: string;
|
|
63
|
+
title: string;
|
|
64
|
+
description?: string;
|
|
65
|
+
order?: number;
|
|
66
|
+
position?: number;
|
|
67
|
+
duration?: number;
|
|
68
|
+
total_lessons?: number;
|
|
69
|
+
lessons?: LWApiLessonData[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface LWApiLessonData {
|
|
73
|
+
id: string;
|
|
74
|
+
title: string;
|
|
75
|
+
type?: string;
|
|
76
|
+
duration?: number;
|
|
77
|
+
order?: number;
|
|
78
|
+
position?: number;
|
|
79
|
+
is_free?: boolean;
|
|
80
|
+
has_video?: boolean;
|
|
81
|
+
has_quiz?: boolean;
|
|
82
|
+
has_assignment?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Raw API shape for instructors response
|
|
87
|
+
*/
|
|
88
|
+
interface LWApiInstructorsResponse {
|
|
89
|
+
success?: boolean;
|
|
90
|
+
data?: LWApiInstructorData[] | { data: LWApiInstructorData[] };
|
|
91
|
+
message?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface LWApiInstructorData {
|
|
95
|
+
id: string;
|
|
96
|
+
name?: string;
|
|
97
|
+
first_name?: string;
|
|
98
|
+
last_name?: string;
|
|
99
|
+
email?: string;
|
|
100
|
+
bio?: string;
|
|
101
|
+
title?: string;
|
|
102
|
+
image_url?: string;
|
|
103
|
+
avatar_url?: string;
|
|
104
|
+
total_courses?: number;
|
|
105
|
+
total_students?: number;
|
|
106
|
+
average_rating?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Raw API shape for stats response
|
|
111
|
+
*/
|
|
112
|
+
interface LWApiStatsResponse {
|
|
113
|
+
success?: boolean;
|
|
114
|
+
data?: {
|
|
115
|
+
total_enrollments?: number;
|
|
116
|
+
active_students?: number;
|
|
117
|
+
completion_rate?: number;
|
|
118
|
+
average_progress?: number;
|
|
119
|
+
average_time_to_complete?: number;
|
|
120
|
+
total_revenue?: number;
|
|
121
|
+
};
|
|
122
|
+
message?: string;
|
|
123
|
+
}
|
|
5
124
|
|
|
6
125
|
/**
|
|
7
126
|
* Action to retrieve comprehensive course details including curriculum structure
|
|
8
127
|
*/
|
|
9
128
|
@RegisterClass(BaseAction, 'GetLearnWorldsCourseDetailsAction')
|
|
10
129
|
export class GetLearnWorldsCourseDetailsAction extends LearnWorldsBaseAction {
|
|
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
|
-
const course = courseResponse.data;
|
|
53
|
-
const courseDetails: any = {
|
|
54
|
-
id: course.id,
|
|
55
|
-
title: course.title,
|
|
56
|
-
slug: course.slug,
|
|
57
|
-
description: course.description,
|
|
58
|
-
shortDescription: course.short_description,
|
|
59
|
-
status: course.status || 'published',
|
|
60
|
-
price: course.price || 0,
|
|
61
|
-
originalPrice: course.original_price,
|
|
62
|
-
currency: course.currency || 'USD',
|
|
63
|
-
level: course.level || 'all',
|
|
64
|
-
language: course.language || 'en',
|
|
65
|
-
duration: course.duration,
|
|
66
|
-
durationText: this.formatDuration(course.duration),
|
|
67
|
-
totalEnrollments: course.total_enrollments || 0,
|
|
68
|
-
averageRating: course.average_rating,
|
|
69
|
-
totalRatings: course.total_ratings || 0,
|
|
70
|
-
tags: course.tags || [],
|
|
71
|
-
categories: course.categories || [],
|
|
72
|
-
imageUrl: course.image_url,
|
|
73
|
-
videoUrl: course.video_url,
|
|
74
|
-
certificateEnabled: course.certificate_enabled || false,
|
|
75
|
-
createdAt: course.created_at,
|
|
76
|
-
updatedAt: course.updated_at,
|
|
77
|
-
publishedAt: course.published_at
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// Get curriculum/modules if requested
|
|
81
|
-
if (includeModules) {
|
|
82
|
-
const modulesResponse = await this.makeLearnWorldsRequest(
|
|
83
|
-
`/courses/${courseId}/sections`,
|
|
84
|
-
'GET',
|
|
85
|
-
null,
|
|
86
|
-
ContextUser
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
if (modulesResponse.success && modulesResponse.data) {
|
|
90
|
-
courseDetails.modules = this.formatModules(modulesResponse.data.data || modulesResponse.data);
|
|
91
|
-
courseDetails.totalModules = courseDetails.modules.length;
|
|
92
|
-
courseDetails.totalLessons = courseDetails.modules.reduce((sum: number, module: any) =>
|
|
93
|
-
sum + (module.lessons?.length || 0), 0
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Get instructors if requested
|
|
99
|
-
if (includeInstructors) {
|
|
100
|
-
const instructorsResponse = await this.makeLearnWorldsRequest(
|
|
101
|
-
`/courses/${courseId}/instructors`,
|
|
102
|
-
'GET',
|
|
103
|
-
null,
|
|
104
|
-
ContextUser
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
if (instructorsResponse.success && instructorsResponse.data) {
|
|
108
|
-
courseDetails.instructors = this.formatInstructors(instructorsResponse.data.data || instructorsResponse.data);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Get additional stats if requested
|
|
113
|
-
if (includeStats) {
|
|
114
|
-
const statsResponse = await this.makeLearnWorldsRequest(
|
|
115
|
-
`/courses/${courseId}/stats`,
|
|
116
|
-
'GET',
|
|
117
|
-
null,
|
|
118
|
-
ContextUser
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
if (statsResponse.success && statsResponse.data) {
|
|
122
|
-
courseDetails.stats = {
|
|
123
|
-
totalEnrollments: statsResponse.data.total_enrollments || courseDetails.totalEnrollments,
|
|
124
|
-
activeStudents: statsResponse.data.active_students || 0,
|
|
125
|
-
completionRate: statsResponse.data.completion_rate || 0,
|
|
126
|
-
averageProgressPercentage: statsResponse.data.average_progress || 0,
|
|
127
|
-
averageTimeToComplete: statsResponse.data.average_time_to_complete,
|
|
128
|
-
totalRevenue: statsResponse.data.total_revenue || 0
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Create summary
|
|
134
|
-
const summary = {
|
|
135
|
-
courseId: courseDetails.id,
|
|
136
|
-
title: courseDetails.title,
|
|
137
|
-
status: courseDetails.status,
|
|
138
|
-
level: courseDetails.level,
|
|
139
|
-
duration: courseDetails.durationText,
|
|
140
|
-
totalModules: courseDetails.totalModules || 0,
|
|
141
|
-
totalLessons: courseDetails.totalLessons || 0,
|
|
142
|
-
totalEnrollments: courseDetails.totalEnrollments,
|
|
143
|
-
averageRating: courseDetails.averageRating || 0,
|
|
144
|
-
certificateEnabled: courseDetails.certificateEnabled,
|
|
145
|
-
price: courseDetails.price,
|
|
146
|
-
currency: courseDetails.currency
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// Update output parameters
|
|
150
|
-
const outputParams = [...Params];
|
|
151
|
-
const courseDetailsParam = outputParams.find(p => p.Name === 'CourseDetails');
|
|
152
|
-
if (courseDetailsParam) {
|
|
153
|
-
courseDetailsParam.Value = courseDetails;
|
|
154
|
-
}
|
|
155
|
-
const summaryParam = outputParams.find(p => p.Name === 'Summary');
|
|
156
|
-
if (summaryParam) {
|
|
157
|
-
summaryParam.Value = summary;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
Success: true,
|
|
162
|
-
ResultCode: 'SUCCESS',
|
|
163
|
-
Message: 'Course details retrieved successfully',
|
|
164
|
-
Params: outputParams
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
} catch (error) {
|
|
168
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
169
|
-
return {
|
|
170
|
-
Success: false,
|
|
171
|
-
ResultCode: 'EXECUTION_ERROR',
|
|
172
|
-
Message: `Error retrieving course details: ${errorMessage}`,
|
|
173
|
-
Params
|
|
174
|
-
};
|
|
175
|
-
}
|
|
130
|
+
/**
|
|
131
|
+
* Metadata about this action
|
|
132
|
+
*/
|
|
133
|
+
public get Description(): string {
|
|
134
|
+
return 'Retrieves comprehensive details about a specific LearnWorlds course including curriculum structure';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Typed public method for direct (non-framework) callers.
|
|
139
|
+
* Sets company context, fetches course details, and returns a strongly-typed result.
|
|
140
|
+
* Throws on error.
|
|
141
|
+
*/
|
|
142
|
+
public async GetCourseDetails(params: GetCourseDetailsParams, contextUser: UserInfo): Promise<GetCourseDetailsResult> {
|
|
143
|
+
this.SetCompanyContext(params.CompanyID);
|
|
144
|
+
|
|
145
|
+
const {
|
|
146
|
+
CourseID: courseId,
|
|
147
|
+
IncludeModules: includeModules = true,
|
|
148
|
+
IncludeInstructors: includeInstructors = true,
|
|
149
|
+
IncludeStats: includeStats = true,
|
|
150
|
+
} = params;
|
|
151
|
+
|
|
152
|
+
if (!courseId) {
|
|
153
|
+
throw new Error('CourseID is required');
|
|
154
|
+
}
|
|
155
|
+
this.validatePathSegment(courseId, 'CourseID');
|
|
156
|
+
|
|
157
|
+
// Get course details
|
|
158
|
+
const courseResponse = await this.makeLearnWorldsRequest<LWApiCourseResponse>(`/courses/${courseId}`, 'GET', null, contextUser);
|
|
159
|
+
|
|
160
|
+
if (!courseResponse.success || !courseResponse.data) {
|
|
161
|
+
throw new Error(courseResponse.message || 'Failed to retrieve course details');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const course = courseResponse.data;
|
|
165
|
+
const courseDetails = this.buildCourseDetails(course);
|
|
166
|
+
|
|
167
|
+
if (includeModules) {
|
|
168
|
+
await this.attachModules(courseId, courseDetails, contextUser);
|
|
176
169
|
}
|
|
177
170
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
*/
|
|
181
|
-
private formatModules(modules: any[]): any[] {
|
|
182
|
-
return modules.map(module => ({
|
|
183
|
-
id: module.id,
|
|
184
|
-
title: module.title,
|
|
185
|
-
description: module.description,
|
|
186
|
-
order: module.order || module.position || 0,
|
|
187
|
-
duration: module.duration,
|
|
188
|
-
durationText: this.formatDuration(module.duration),
|
|
189
|
-
totalLessons: module.total_lessons || module.lessons?.length || 0,
|
|
190
|
-
lessons: module.lessons?.map((lesson: any) => ({
|
|
191
|
-
id: lesson.id,
|
|
192
|
-
title: lesson.title,
|
|
193
|
-
type: lesson.type || 'video',
|
|
194
|
-
duration: lesson.duration,
|
|
195
|
-
durationText: this.formatDuration(lesson.duration),
|
|
196
|
-
order: lesson.order || lesson.position || 0,
|
|
197
|
-
isFree: lesson.is_free || false,
|
|
198
|
-
hasVideo: lesson.has_video || false,
|
|
199
|
-
hasQuiz: lesson.has_quiz || false,
|
|
200
|
-
hasAssignment: lesson.has_assignment || false
|
|
201
|
-
})) || []
|
|
202
|
-
})).sort((a, b) => a.order - b.order);
|
|
171
|
+
if (includeInstructors) {
|
|
172
|
+
await this.attachInstructors(courseId, courseDetails, contextUser);
|
|
203
173
|
}
|
|
204
174
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
*/
|
|
208
|
-
private formatInstructors(instructors: any[]): any[] {
|
|
209
|
-
return instructors.map(instructor => ({
|
|
210
|
-
id: instructor.id,
|
|
211
|
-
name: instructor.name || `${instructor.first_name || ''} ${instructor.last_name || ''}`.trim(),
|
|
212
|
-
email: instructor.email,
|
|
213
|
-
bio: instructor.bio,
|
|
214
|
-
title: instructor.title,
|
|
215
|
-
imageUrl: instructor.image_url || instructor.avatar_url,
|
|
216
|
-
totalCourses: instructor.total_courses || 0,
|
|
217
|
-
totalStudents: instructor.total_students || 0,
|
|
218
|
-
averageRating: instructor.average_rating || 0
|
|
219
|
-
}));
|
|
175
|
+
if (includeStats) {
|
|
176
|
+
await this.attachStats(courseId, courseDetails, contextUser);
|
|
220
177
|
}
|
|
221
178
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
{
|
|
249
|
-
Name: 'CourseDetails',
|
|
250
|
-
Type: 'Output',
|
|
251
|
-
Value: null
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
Name: 'Summary',
|
|
255
|
-
Type: 'Output',
|
|
256
|
-
Value: null
|
|
257
|
-
}
|
|
258
|
-
];
|
|
259
|
-
return [...baseParams, ...specificParams];
|
|
179
|
+
const summary = this.buildCourseSummary(courseDetails);
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
CourseDetails: courseDetails,
|
|
183
|
+
Summary: summary,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Framework entry-point – thin wrapper around the typed public method.
|
|
189
|
+
*/
|
|
190
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
191
|
+
const { Params, ContextUser } = params;
|
|
192
|
+
this.params = Params;
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
const typedParams = this.extractGetCourseDetailsParams(Params);
|
|
196
|
+
const result = await this.GetCourseDetails(typedParams, ContextUser);
|
|
197
|
+
|
|
198
|
+
this.setOutputParam(Params, 'CourseDetails', result.CourseDetails);
|
|
199
|
+
this.setOutputParam(Params, 'Summary', result.Summary);
|
|
200
|
+
|
|
201
|
+
return this.buildSuccessResult('Course details retrieved successfully', Params);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
const msg = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
204
|
+
return this.buildErrorResult('ERROR', `Error retrieving course details: ${msg}`, Params);
|
|
260
205
|
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Extract typed params from framework ActionParam[]
|
|
210
|
+
*/
|
|
211
|
+
private extractGetCourseDetailsParams(params: ActionParam[]): GetCourseDetailsParams {
|
|
212
|
+
return {
|
|
213
|
+
CompanyID: this.getRequiredStringParam(params, 'CompanyID'),
|
|
214
|
+
CourseID: this.getRequiredStringParam(params, 'CourseID'),
|
|
215
|
+
IncludeModules: this.getOptionalBooleanParam(params, 'IncludeModules', true),
|
|
216
|
+
IncludeInstructors: this.getOptionalBooleanParam(params, 'IncludeInstructors', true),
|
|
217
|
+
IncludeStats: this.getOptionalBooleanParam(params, 'IncludeStats', true),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Build the base course details from raw API data
|
|
223
|
+
*/
|
|
224
|
+
private buildCourseDetails(course: LWApiCourseData): CourseDetailsData {
|
|
225
|
+
return {
|
|
226
|
+
id: course.id,
|
|
227
|
+
title: course.title,
|
|
228
|
+
slug: course.slug,
|
|
229
|
+
description: course.description,
|
|
230
|
+
shortDescription: course.short_description,
|
|
231
|
+
status: course.status || 'published',
|
|
232
|
+
price: course.price || 0,
|
|
233
|
+
originalPrice: course.original_price,
|
|
234
|
+
currency: course.currency || 'USD',
|
|
235
|
+
level: course.level || 'all',
|
|
236
|
+
language: course.language || 'en',
|
|
237
|
+
duration: course.duration,
|
|
238
|
+
durationText: this.formatDuration(course.duration || 0),
|
|
239
|
+
totalEnrollments: course.total_enrollments || 0,
|
|
240
|
+
averageRating: course.average_rating,
|
|
241
|
+
totalRatings: course.total_ratings || 0,
|
|
242
|
+
tags: course.tags || [],
|
|
243
|
+
categories: course.categories || [],
|
|
244
|
+
imageUrl: course.image_url,
|
|
245
|
+
videoUrl: course.video_url,
|
|
246
|
+
certificateEnabled: course.certificate_enabled || false,
|
|
247
|
+
createdAt: course.created_at,
|
|
248
|
+
updatedAt: course.updated_at,
|
|
249
|
+
publishedAt: course.published_at,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
261
252
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Fetch and attach modules/curriculum to course details
|
|
255
|
+
*/
|
|
256
|
+
private async attachModules(courseId: string, courseDetails: CourseDetailsData, contextUser: UserInfo): Promise<void> {
|
|
257
|
+
const modulesResponse = await this.makeLearnWorldsRequest<LWApiSectionsResponse>(`/courses/${courseId}/sections`, 'GET', null, contextUser);
|
|
258
|
+
|
|
259
|
+
if (modulesResponse.success && modulesResponse.data) {
|
|
260
|
+
const rawModules = Array.isArray(modulesResponse.data) ? modulesResponse.data : (modulesResponse.data as { data: LWApiModuleData[] }).data || [];
|
|
261
|
+
|
|
262
|
+
courseDetails.modules = this.formatModules(rawModules);
|
|
263
|
+
courseDetails.totalModules = courseDetails.modules.length;
|
|
264
|
+
courseDetails.totalLessons = courseDetails.modules.reduce((sum, mod) => sum + (mod.lessons?.length || 0), 0);
|
|
267
265
|
}
|
|
268
|
-
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Fetch and attach instructors to course details
|
|
270
|
+
*/
|
|
271
|
+
private async attachInstructors(courseId: string, courseDetails: CourseDetailsData, contextUser: UserInfo): Promise<void> {
|
|
272
|
+
const instructorsResponse = await this.makeLearnWorldsRequest<LWApiInstructorsResponse>(`/courses/${courseId}/instructors`, 'GET', null, contextUser);
|
|
273
|
+
|
|
274
|
+
if (instructorsResponse.success && instructorsResponse.data) {
|
|
275
|
+
const rawInstructors = Array.isArray(instructorsResponse.data)
|
|
276
|
+
? instructorsResponse.data
|
|
277
|
+
: (instructorsResponse.data as { data: LWApiInstructorData[] }).data || [];
|
|
278
|
+
|
|
279
|
+
courseDetails.instructors = this.formatInstructors(rawInstructors);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Fetch and attach stats to course details
|
|
285
|
+
*/
|
|
286
|
+
private async attachStats(courseId: string, courseDetails: CourseDetailsData, contextUser: UserInfo): Promise<void> {
|
|
287
|
+
const statsResponse = await this.makeLearnWorldsRequest<LWApiStatsResponse>(`/courses/${courseId}/stats`, 'GET', null, contextUser);
|
|
288
|
+
|
|
289
|
+
if (statsResponse.success && statsResponse.data) {
|
|
290
|
+
const statsData = statsResponse.data;
|
|
291
|
+
courseDetails.stats = {
|
|
292
|
+
totalEnrollments: statsData.total_enrollments || courseDetails.totalEnrollments,
|
|
293
|
+
activeStudents: statsData.active_students || 0,
|
|
294
|
+
completionRate: statsData.completion_rate || 0,
|
|
295
|
+
averageProgressPercentage: statsData.average_progress || 0,
|
|
296
|
+
averageTimeToComplete: statsData.average_time_to_complete,
|
|
297
|
+
totalRevenue: statsData.total_revenue || 0,
|
|
298
|
+
} satisfies CourseStats;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Format course modules/sections data
|
|
304
|
+
*/
|
|
305
|
+
private formatModules(modules: LWApiModuleData[]): CourseModule[] {
|
|
306
|
+
return modules
|
|
307
|
+
.map((module) => ({
|
|
308
|
+
id: module.id,
|
|
309
|
+
title: module.title,
|
|
310
|
+
description: module.description,
|
|
311
|
+
order: module.order || module.position || 0,
|
|
312
|
+
duration: module.duration,
|
|
313
|
+
durationText: this.formatDuration(module.duration || 0),
|
|
314
|
+
totalLessons: module.total_lessons || module.lessons?.length || 0,
|
|
315
|
+
lessons: this.formatLessons(module.lessons || []),
|
|
316
|
+
}))
|
|
317
|
+
.sort((a, b) => a.order - b.order);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Format lesson data within a module
|
|
322
|
+
*/
|
|
323
|
+
private formatLessons(lessons: LWApiLessonData[]): CourseLesson[] {
|
|
324
|
+
return lessons.map((lesson) => ({
|
|
325
|
+
id: lesson.id,
|
|
326
|
+
title: lesson.title,
|
|
327
|
+
type: lesson.type || 'video',
|
|
328
|
+
duration: lesson.duration,
|
|
329
|
+
durationText: this.formatDuration(lesson.duration || 0),
|
|
330
|
+
order: lesson.order || lesson.position || 0,
|
|
331
|
+
isFree: lesson.is_free || false,
|
|
332
|
+
hasVideo: lesson.has_video || false,
|
|
333
|
+
hasQuiz: lesson.has_quiz || false,
|
|
334
|
+
hasAssignment: lesson.has_assignment || false,
|
|
335
|
+
}));
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Format instructor data
|
|
340
|
+
*/
|
|
341
|
+
private formatInstructors(instructors: LWApiInstructorData[]): CourseInstructor[] {
|
|
342
|
+
return instructors.map((instructor) => ({
|
|
343
|
+
id: instructor.id,
|
|
344
|
+
name: instructor.name || `${instructor.first_name || ''} ${instructor.last_name || ''}`.trim(),
|
|
345
|
+
email: instructor.email,
|
|
346
|
+
bio: instructor.bio,
|
|
347
|
+
title: instructor.title,
|
|
348
|
+
imageUrl: instructor.image_url || instructor.avatar_url,
|
|
349
|
+
totalCourses: instructor.total_courses || 0,
|
|
350
|
+
totalStudents: instructor.total_students || 0,
|
|
351
|
+
averageRating: instructor.average_rating || 0,
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Build a summary from the course details
|
|
357
|
+
*/
|
|
358
|
+
private buildCourseSummary(courseDetails: CourseDetailsData): CourseDetailsSummary {
|
|
359
|
+
return {
|
|
360
|
+
courseId: courseDetails.id,
|
|
361
|
+
title: courseDetails.title,
|
|
362
|
+
status: courseDetails.status,
|
|
363
|
+
level: courseDetails.level,
|
|
364
|
+
duration: courseDetails.durationText,
|
|
365
|
+
totalModules: courseDetails.totalModules || 0,
|
|
366
|
+
totalLessons: courseDetails.totalLessons || 0,
|
|
367
|
+
totalEnrollments: courseDetails.totalEnrollments,
|
|
368
|
+
averageRating: courseDetails.averageRating || 0,
|
|
369
|
+
certificateEnabled: courseDetails.certificateEnabled,
|
|
370
|
+
price: courseDetails.price,
|
|
371
|
+
currency: courseDetails.currency,
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Define the parameters this action expects
|
|
377
|
+
*/
|
|
378
|
+
public get Params(): ActionParam[] {
|
|
379
|
+
const baseParams = this.getCommonLMSParams();
|
|
380
|
+
const specificParams: ActionParam[] = [
|
|
381
|
+
{
|
|
382
|
+
Name: 'CourseID',
|
|
383
|
+
Type: 'Input',
|
|
384
|
+
Value: null,
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
Name: 'IncludeModules',
|
|
388
|
+
Type: 'Input',
|
|
389
|
+
Value: true,
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
Name: 'IncludeInstructors',
|
|
393
|
+
Type: 'Input',
|
|
394
|
+
Value: true,
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
Name: 'IncludeStats',
|
|
398
|
+
Type: 'Input',
|
|
399
|
+
Value: true,
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
Name: 'CourseDetails',
|
|
403
|
+
Type: 'Output',
|
|
404
|
+
Value: null,
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
Name: 'Summary',
|
|
408
|
+
Type: 'Output',
|
|
409
|
+
Value: null,
|
|
410
|
+
},
|
|
411
|
+
];
|
|
412
|
+
return [...baseParams, ...specificParams];
|
|
413
|
+
}
|
|
414
|
+
}
|