@memberjunction/actions-bizapps-lms 5.3.0 → 5.4.0
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,319 +2,268 @@ 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
|
-
|
|
6
|
-
|
|
7
|
-
* Interface for a LearnWorlds user
|
|
8
|
-
*/
|
|
9
|
-
export interface LearnWorldsUser {
|
|
10
|
-
id: string;
|
|
11
|
-
email: string;
|
|
12
|
-
username: string;
|
|
13
|
-
firstName?: string;
|
|
14
|
-
lastName?: string;
|
|
15
|
-
fullName?: string;
|
|
16
|
-
status: 'active' | 'inactive' | 'suspended';
|
|
17
|
-
role: string;
|
|
18
|
-
createdAt: Date;
|
|
19
|
-
lastLoginAt?: Date;
|
|
20
|
-
tags?: string[];
|
|
21
|
-
customFields?: Record<string, any>;
|
|
22
|
-
totalCourses?: number;
|
|
23
|
-
completedCourses?: number;
|
|
24
|
-
inProgressCourses?: number;
|
|
25
|
-
totalTimeSpent?: number;
|
|
26
|
-
avatarUrl?: string;
|
|
27
|
-
bio?: string;
|
|
28
|
-
location?: string;
|
|
29
|
-
timezone?: string;
|
|
30
|
-
}
|
|
5
|
+
import { UserInfo } from '@memberjunction/core';
|
|
6
|
+
import { GetUsersParams, GetUsersResult, UsersSummary, LearnWorldsUser, LWApiUser } from '../interfaces';
|
|
31
7
|
|
|
32
8
|
/**
|
|
33
9
|
* Action to retrieve users from LearnWorlds LMS
|
|
34
10
|
*/
|
|
35
11
|
@RegisterClass(BaseAction, 'GetLearnWorldsUsersAction')
|
|
36
12
|
export class GetLearnWorldsUsersAction extends LearnWorldsBaseAction {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
* Description of the action
|
|
15
|
+
*/
|
|
16
|
+
public get Description(): string {
|
|
17
|
+
return 'Retrieves users (students, instructors, admins) from LearnWorlds LMS with filtering and search options';
|
|
18
|
+
}
|
|
44
19
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!contextUser) {
|
|
52
|
-
return {
|
|
53
|
-
Success: false,
|
|
54
|
-
ResultCode: 'ERROR',
|
|
55
|
-
Message: 'Context user is required for LearnWorlds API calls'
|
|
56
|
-
};
|
|
57
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* Typed public method for direct (non-framework) callers.
|
|
22
|
+
* Throws on failure.
|
|
23
|
+
*/
|
|
24
|
+
public async GetUsers(params: GetUsersParams, contextUser: UserInfo): Promise<GetUsersResult> {
|
|
25
|
+
this.SetCompanyContext(params.CompanyID);
|
|
58
26
|
|
|
59
|
-
|
|
60
|
-
|
|
27
|
+
// Build query parameters
|
|
28
|
+
const queryParams: Record<string, string | number | boolean> = {};
|
|
61
29
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
30
|
+
if (params.SearchText) {
|
|
31
|
+
queryParams.search = params.SearchText;
|
|
32
|
+
}
|
|
33
|
+
if (params.Role) {
|
|
34
|
+
queryParams.role = params.Role;
|
|
35
|
+
}
|
|
36
|
+
if (params.Status) {
|
|
37
|
+
queryParams.status = params.Status;
|
|
38
|
+
}
|
|
39
|
+
if (params.Tags) {
|
|
40
|
+
queryParams.tags = params.Tags;
|
|
41
|
+
}
|
|
42
|
+
if (params.CreatedAfter) {
|
|
43
|
+
queryParams.created_after = this.formatLearnWorldsDate(new Date(params.CreatedAfter));
|
|
44
|
+
}
|
|
45
|
+
if (params.CreatedBefore) {
|
|
46
|
+
queryParams.created_before = this.formatLearnWorldsDate(new Date(params.CreatedBefore));
|
|
47
|
+
}
|
|
70
48
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
49
|
+
// Sorting
|
|
50
|
+
const sortBy = params.SortBy || 'created';
|
|
51
|
+
const sortOrder = params.SortOrder || 'desc';
|
|
52
|
+
queryParams.sort = `${sortOrder === 'asc' ? '' : '-'}${sortBy}`;
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
54
|
+
// Include course stats
|
|
55
|
+
if (params.IncludeCourseStats) {
|
|
56
|
+
queryParams.include = 'course_stats';
|
|
57
|
+
}
|
|
82
58
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
queryParams.tags = tags;
|
|
87
|
-
}
|
|
59
|
+
// Limit for pagination
|
|
60
|
+
const maxResults = params.MaxResults || 100;
|
|
61
|
+
queryParams.limit = Math.min(maxResults, 100); // LearnWorlds max is usually 100
|
|
88
62
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (createdAfter) {
|
|
92
|
-
queryParams.created_after = this.formatLearnWorldsDate(new Date(createdAfter));
|
|
93
|
-
}
|
|
63
|
+
// Make the API request
|
|
64
|
+
const users = await this.makeLearnWorldsPaginatedRequest<LWApiUser>('users', queryParams, contextUser);
|
|
94
65
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
queryParams.created_before = this.formatLearnWorldsDate(new Date(createdBefore));
|
|
98
|
-
}
|
|
66
|
+
// Map to our interface
|
|
67
|
+
const mappedUsers: LearnWorldsUser[] = users.map((user) => this.mapLearnWorldsUser(user));
|
|
99
68
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const sortOrder = this.getParamValue(params.Params, 'SortOrder') || 'desc';
|
|
103
|
-
queryParams.sort = `${sortOrder === 'asc' ? '' : '-'}${sortBy}`;
|
|
69
|
+
// Calculate summary
|
|
70
|
+
const summary = this.calculateUserSummary(mappedUsers);
|
|
104
71
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
72
|
+
return {
|
|
73
|
+
Users: mappedUsers,
|
|
74
|
+
TotalCount: mappedUsers.length,
|
|
75
|
+
Summary: summary,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
110
78
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Framework entry point -- delegates to the typed public method.
|
|
81
|
+
*/
|
|
82
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
83
|
+
const { Params, ContextUser } = params;
|
|
84
|
+
this.params = Params;
|
|
114
85
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
contextUser
|
|
120
|
-
);
|
|
86
|
+
try {
|
|
87
|
+
if (!ContextUser) {
|
|
88
|
+
return this.buildErrorResult('ERROR', 'Context user is required for LearnWorlds API calls', Params);
|
|
89
|
+
}
|
|
121
90
|
|
|
122
|
-
|
|
123
|
-
|
|
91
|
+
const typedParams = this.extractGetUsersParams(Params);
|
|
92
|
+
const result = await this.GetUsers(typedParams, ContextUser);
|
|
124
93
|
|
|
125
|
-
|
|
126
|
-
|
|
94
|
+
this.setOutputParam(Params, 'Users', result.Users);
|
|
95
|
+
this.setOutputParam(Params, 'TotalCount', result.TotalCount);
|
|
96
|
+
this.setOutputParam(Params, 'Summary', result.Summary);
|
|
127
97
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
} else {
|
|
136
|
-
params.Params.find(p => p.Name === 'Users')!.Value = mappedUsers;
|
|
137
|
-
}
|
|
98
|
+
return this.buildSuccessResult(`Successfully retrieved ${result.TotalCount} users from LearnWorlds`, Params);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const msg = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
101
|
+
return this.buildErrorResult('ERROR', msg, Params);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
138
104
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Extract typed params from the generic ActionParam array
|
|
107
|
+
*/
|
|
108
|
+
private extractGetUsersParams(params: ActionParam[]): GetUsersParams {
|
|
109
|
+
return {
|
|
110
|
+
CompanyID: this.getRequiredStringParam(params, 'CompanyID'),
|
|
111
|
+
SearchText: this.getOptionalStringParam(params, 'SearchText'),
|
|
112
|
+
Role: this.getOptionalStringParam(params, 'Role'),
|
|
113
|
+
Status: this.getOptionalStringParam(params, 'Status'),
|
|
114
|
+
Tags: this.getOptionalStringParam(params, 'Tags'),
|
|
115
|
+
CreatedAfter: this.getOptionalStringParam(params, 'CreatedAfter'),
|
|
116
|
+
CreatedBefore: this.getOptionalStringParam(params, 'CreatedBefore'),
|
|
117
|
+
SortBy: this.getOptionalStringParam(params, 'SortBy') || 'created',
|
|
118
|
+
SortOrder: (this.getOptionalStringParam(params, 'SortOrder') || 'desc') as 'asc' | 'desc',
|
|
119
|
+
IncludeCourseStats: this.getOptionalBooleanParam(params, 'IncludeCourseStats', false),
|
|
120
|
+
MaxResults: this.getOptionalNumberParam(params, 'MaxResults', LearnWorldsBaseAction.LW_MAX_PAGE_SIZE),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
148
123
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Map a raw LearnWorlds API user to our typed interface
|
|
126
|
+
*/
|
|
127
|
+
private mapLearnWorldsUser(lwUser: LWApiUser): LearnWorldsUser {
|
|
128
|
+
return {
|
|
129
|
+
id: lwUser.id || lwUser._id || '',
|
|
130
|
+
email: lwUser.email,
|
|
131
|
+
username: lwUser.username || lwUser.email,
|
|
132
|
+
firstName: lwUser.first_name,
|
|
133
|
+
lastName: lwUser.last_name,
|
|
134
|
+
fullName: lwUser.full_name || `${lwUser.first_name || ''} ${lwUser.last_name || ''}`.trim(),
|
|
135
|
+
status: this.mapUserStatus(lwUser.status || 'active'),
|
|
136
|
+
role: lwUser.role || 'student',
|
|
137
|
+
createdAt: this.parseLearnWorldsDate(lwUser.created || lwUser.created_at || ''),
|
|
138
|
+
lastLoginAt: lwUser.last_login ? this.parseLearnWorldsDate(lwUser.last_login) : undefined,
|
|
139
|
+
tags: lwUser.tags || [],
|
|
140
|
+
customFields: lwUser.custom_fields || {},
|
|
141
|
+
totalCourses: lwUser.course_stats?.total || 0,
|
|
142
|
+
completedCourses: lwUser.course_stats?.completed || 0,
|
|
143
|
+
inProgressCourses: lwUser.course_stats?.in_progress || 0,
|
|
144
|
+
totalTimeSpent: lwUser.course_stats?.total_time_spent || 0,
|
|
145
|
+
avatarUrl: lwUser.avatar_url,
|
|
146
|
+
bio: lwUser.bio,
|
|
147
|
+
location: lwUser.location,
|
|
148
|
+
timezone: lwUser.timezone,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
158
151
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Calculate summary statistics from the mapped user list
|
|
154
|
+
*/
|
|
155
|
+
private calculateUserSummary(users: LearnWorldsUser[]): UsersSummary {
|
|
156
|
+
const usersByRole: Record<string, number> = {};
|
|
157
|
+
let totalTimeSpent = 0;
|
|
164
158
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
ResultCode: 'ERROR',
|
|
170
|
-
Message: errorMessage
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
159
|
+
users.forEach((user) => {
|
|
160
|
+
usersByRole[user.role] = (usersByRole[user.role] || 0) + 1;
|
|
161
|
+
totalTimeSpent += user.totalTimeSpent || 0;
|
|
162
|
+
});
|
|
174
163
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
id: lwUser.id || lwUser._id,
|
|
181
|
-
email: lwUser.email,
|
|
182
|
-
username: lwUser.username || lwUser.email,
|
|
183
|
-
firstName: lwUser.first_name,
|
|
184
|
-
lastName: lwUser.last_name,
|
|
185
|
-
fullName: lwUser.full_name || `${lwUser.first_name || ''} ${lwUser.last_name || ''}`.trim(),
|
|
186
|
-
status: this.mapUserStatus(lwUser.status || 'active'),
|
|
187
|
-
role: lwUser.role || 'student',
|
|
188
|
-
createdAt: this.parseLearnWorldsDate(lwUser.created || lwUser.created_at),
|
|
189
|
-
lastLoginAt: lwUser.last_login ? this.parseLearnWorldsDate(lwUser.last_login) : undefined,
|
|
190
|
-
tags: lwUser.tags || [],
|
|
191
|
-
customFields: lwUser.custom_fields || {},
|
|
192
|
-
totalCourses: lwUser.course_stats?.total || 0,
|
|
193
|
-
completedCourses: lwUser.course_stats?.completed || 0,
|
|
194
|
-
inProgressCourses: lwUser.course_stats?.in_progress || 0,
|
|
195
|
-
totalTimeSpent: lwUser.course_stats?.total_time_spent || 0,
|
|
196
|
-
avatarUrl: lwUser.avatar_url,
|
|
197
|
-
bio: lwUser.bio,
|
|
198
|
-
location: lwUser.location,
|
|
199
|
-
timezone: lwUser.timezone
|
|
200
|
-
};
|
|
164
|
+
let averageCoursesPerUser = 0;
|
|
165
|
+
if (users.length > 0) {
|
|
166
|
+
const totalCourses = users.reduce((sum, u) => sum + (u.totalCourses || 0), 0);
|
|
167
|
+
averageCoursesPerUser = totalCourses / users.length;
|
|
201
168
|
}
|
|
202
169
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
averageCoursesPerUser: 0,
|
|
214
|
-
totalTimeSpent: 0,
|
|
215
|
-
mostActiveUsers: [] as any[],
|
|
216
|
-
recentSignups: [] as any[]
|
|
217
|
-
};
|
|
170
|
+
// Find most active users (by completed courses)
|
|
171
|
+
const mostActiveUsers: Array<{ id: string; name: string; completedCourses?: number }> = users
|
|
172
|
+
.filter((u) => u.completedCourses && u.completedCourses > 0)
|
|
173
|
+
.sort((a, b) => (b.completedCourses || 0) - (a.completedCourses || 0))
|
|
174
|
+
.slice(0, 5)
|
|
175
|
+
.map((u) => ({
|
|
176
|
+
id: u.id,
|
|
177
|
+
name: u.fullName || u.email,
|
|
178
|
+
completedCourses: u.completedCourses,
|
|
179
|
+
}));
|
|
218
180
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
summary.totalTimeSpent += user.totalTimeSpent || 0;
|
|
223
|
-
});
|
|
181
|
+
// Find recent signups (last 30 days)
|
|
182
|
+
const thirtyDaysAgo = new Date();
|
|
183
|
+
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);
|
|
224
184
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
185
|
+
const recentSignups: Array<{ id: string; name: string; signupDate: Date }> = users
|
|
186
|
+
.filter((u) => u.createdAt > thirtyDaysAgo)
|
|
187
|
+
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
|
|
188
|
+
.slice(0, 10)
|
|
189
|
+
.map((u) => ({
|
|
190
|
+
id: u.id,
|
|
191
|
+
name: u.fullName || u.email,
|
|
192
|
+
signupDate: u.createdAt,
|
|
193
|
+
}));
|
|
230
194
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
195
|
+
return {
|
|
196
|
+
totalUsers: users.length,
|
|
197
|
+
activeUsers: users.filter((u) => u.status === 'active').length,
|
|
198
|
+
inactiveUsers: users.filter((u) => u.status === 'inactive').length,
|
|
199
|
+
suspendedUsers: users.filter((u) => u.status === 'suspended').length,
|
|
200
|
+
usersByRole,
|
|
201
|
+
averageCoursesPerUser,
|
|
202
|
+
totalTimeSpent,
|
|
203
|
+
mostActiveUsers,
|
|
204
|
+
recentSignups,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
241
207
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.filter(u => u.createdAt > thirtyDaysAgo)
|
|
248
|
-
.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
|
|
249
|
-
.slice(0, 10)
|
|
250
|
-
.map(u => ({
|
|
251
|
-
id: u.id,
|
|
252
|
-
name: u.fullName || u.email,
|
|
253
|
-
signupDate: u.createdAt
|
|
254
|
-
}));
|
|
208
|
+
/**
|
|
209
|
+
* Define the parameters for this action
|
|
210
|
+
*/
|
|
211
|
+
public get Params(): ActionParam[] {
|
|
212
|
+
const baseParams = this.getCommonLMSParams();
|
|
255
213
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
Type: 'Input',
|
|
309
|
-
Value: true
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
Name: 'MaxResults',
|
|
313
|
-
Type: 'Input',
|
|
314
|
-
Value: 100
|
|
315
|
-
}
|
|
316
|
-
];
|
|
214
|
+
const specificParams: ActionParam[] = [
|
|
215
|
+
{
|
|
216
|
+
Name: 'SearchText',
|
|
217
|
+
Type: 'Input',
|
|
218
|
+
Value: null,
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
Name: 'Role',
|
|
222
|
+
Type: 'Input',
|
|
223
|
+
Value: null,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
Name: 'Status',
|
|
227
|
+
Type: 'Input',
|
|
228
|
+
Value: null,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
Name: 'Tags',
|
|
232
|
+
Type: 'Input',
|
|
233
|
+
Value: null,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
Name: 'CreatedAfter',
|
|
237
|
+
Type: 'Input',
|
|
238
|
+
Value: null,
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
Name: 'CreatedBefore',
|
|
242
|
+
Type: 'Input',
|
|
243
|
+
Value: null,
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
Name: 'SortBy',
|
|
247
|
+
Type: 'Input',
|
|
248
|
+
Value: 'created',
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
Name: 'SortOrder',
|
|
252
|
+
Type: 'Input',
|
|
253
|
+
Value: 'desc',
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
Name: 'IncludeCourseStats',
|
|
257
|
+
Type: 'Input',
|
|
258
|
+
Value: true,
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
Name: 'MaxResults',
|
|
262
|
+
Type: 'Input',
|
|
263
|
+
Value: 100,
|
|
264
|
+
},
|
|
265
|
+
];
|
|
317
266
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
267
|
+
return [...baseParams, ...specificParams];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -10,4 +10,11 @@ export * from './get-course-analytics.action';
|
|
|
10
10
|
export * from './create-user.action';
|
|
11
11
|
export * from './update-user-progress.action';
|
|
12
12
|
export * from './get-certificates.action';
|
|
13
|
-
export * from './get-quiz-results.action';
|
|
13
|
+
export * from './get-quiz-results.action';
|
|
14
|
+
export * from './sso-login.action';
|
|
15
|
+
export * from './update-user.action';
|
|
16
|
+
export * from './attach-tags.action';
|
|
17
|
+
export * from './detach-tags.action';
|
|
18
|
+
export * from './get-bundles.action';
|
|
19
|
+
export * from './onboard-learner.action';
|
|
20
|
+
export * from './get-bulk-data.action';
|