@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,70 +2,72 @@ 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
|
+
GetUserDetailsParams,
|
|
8
|
+
GetUserDetailsResult,
|
|
9
|
+
LearnWorldsUserDetailsFull,
|
|
10
|
+
UserDetailEnrollment,
|
|
11
|
+
LWApiUser,
|
|
12
|
+
LWApiEnrollmentStatus,
|
|
13
|
+
LWApiProgressData,
|
|
14
|
+
} from '../interfaces';
|
|
5
15
|
|
|
6
16
|
/**
|
|
7
|
-
*
|
|
17
|
+
* Extended raw user shape returned by the LearnWorlds GET /users/{id} endpoint.
|
|
18
|
+
* Includes fields beyond the basic LWApiUser.
|
|
8
19
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
language?: string;
|
|
25
|
-
phone?: string;
|
|
26
|
-
tags?: string[];
|
|
27
|
-
customFields?: Record<string, any>;
|
|
28
|
-
|
|
29
|
-
// Learning statistics
|
|
30
|
-
totalCourses: number;
|
|
31
|
-
completedCourses: number;
|
|
32
|
-
inProgressCourses: number;
|
|
33
|
-
notStartedCourses: number;
|
|
34
|
-
totalTimeSpent: number;
|
|
35
|
-
averageCompletionRate: number;
|
|
36
|
-
lastActivityDate?: Date;
|
|
37
|
-
|
|
38
|
-
// Enrollment details
|
|
39
|
-
enrollments?: UserEnrollment[];
|
|
40
|
-
|
|
41
|
-
// Achievement data
|
|
42
|
-
totalCertificates: number;
|
|
43
|
-
totalBadges: number;
|
|
44
|
-
points?: number;
|
|
45
|
-
level?: string;
|
|
46
|
-
|
|
47
|
-
// Account settings
|
|
48
|
-
emailNotifications?: boolean;
|
|
49
|
-
twoFactorEnabled?: boolean;
|
|
50
|
-
agreedToTerms?: boolean;
|
|
51
|
-
marketingConsent?: boolean;
|
|
20
|
+
interface LWUserDetailsResponse extends LWApiUser {
|
|
21
|
+
profile_image?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
country?: string;
|
|
24
|
+
language?: string;
|
|
25
|
+
phone?: string;
|
|
26
|
+
last_activity?: string | number;
|
|
27
|
+
certificates_count?: number;
|
|
28
|
+
badges_count?: number;
|
|
29
|
+
points?: number;
|
|
30
|
+
level?: string;
|
|
31
|
+
email_notifications?: boolean;
|
|
32
|
+
two_factor_enabled?: boolean;
|
|
33
|
+
agreed_to_terms?: boolean;
|
|
34
|
+
marketing_consent?: boolean;
|
|
52
35
|
}
|
|
53
36
|
|
|
54
37
|
/**
|
|
55
|
-
*
|
|
38
|
+
* Raw enrollment shape from the LearnWorlds GET /users/{id}/enrollments endpoint
|
|
56
39
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
40
|
+
interface LWEnrollmentData extends LWApiEnrollmentStatus {
|
|
41
|
+
course_id?: string;
|
|
42
|
+
course?: { id?: string; title?: string };
|
|
43
|
+
course_title?: string;
|
|
44
|
+
enrolled_at?: string;
|
|
45
|
+
created?: string;
|
|
46
|
+
progress?: LWApiProgressData;
|
|
47
|
+
completed_at?: string;
|
|
48
|
+
expires_at?: string;
|
|
49
|
+
last_accessed_at?: string;
|
|
50
|
+
time_spent?: number;
|
|
51
|
+
certificate_url?: string;
|
|
52
|
+
grade?: number;
|
|
53
|
+
final_grade?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Raw enrollments list response
|
|
58
|
+
*/
|
|
59
|
+
interface LWEnrollmentsListResponse {
|
|
60
|
+
data?: LWEnrollmentData[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Raw stats response from the LearnWorlds stats endpoint
|
|
65
|
+
*/
|
|
66
|
+
interface LWStatsResponse {
|
|
67
|
+
total_time_spent?: number;
|
|
68
|
+
certificates_earned?: number;
|
|
69
|
+
badges_earned?: number;
|
|
70
|
+
points?: number;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
@@ -73,310 +75,294 @@ export interface UserEnrollment {
|
|
|
73
75
|
*/
|
|
74
76
|
@RegisterClass(BaseAction, 'GetLearnWorldsUserDetailsAction')
|
|
75
77
|
export class GetLearnWorldsUserDetailsAction extends LearnWorldsBaseAction {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Description of the action
|
|
80
|
+
*/
|
|
81
|
+
public get Description(): string {
|
|
82
|
+
return 'Retrieves comprehensive details about a specific user in LearnWorlds including profile, enrollments, progress, and achievements';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Typed public method for direct (non-framework) callers.
|
|
87
|
+
* Throws on failure.
|
|
88
|
+
*/
|
|
89
|
+
public async GetUserDetails(params: GetUserDetailsParams, contextUser: UserInfo): Promise<GetUserDetailsResult> {
|
|
90
|
+
this.SetCompanyContext(params.CompanyID);
|
|
91
|
+
|
|
92
|
+
if (!params.UserID) {
|
|
93
|
+
throw new Error('UserID parameter is required');
|
|
82
94
|
}
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Store params for base class methods
|
|
99
|
-
this.params = params.Params;
|
|
100
|
-
|
|
101
|
-
// Get user ID
|
|
102
|
-
const userId = this.getParamValue(params.Params, 'UserID');
|
|
103
|
-
if (!userId) {
|
|
104
|
-
return {
|
|
105
|
-
Success: false,
|
|
106
|
-
ResultCode: 'ERROR',
|
|
107
|
-
Message: 'UserID parameter is required'
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Include enrollments
|
|
112
|
-
const includeEnrollments = this.getParamValue(params.Params, 'IncludeEnrollments') ?? true;
|
|
113
|
-
const includeStats = this.getParamValue(params.Params, 'IncludeStats') ?? true;
|
|
114
|
-
|
|
115
|
-
// Make the API request for user details
|
|
116
|
-
const userResponse = await this.makeLearnWorldsRequest<any>(
|
|
117
|
-
`users/${userId}`,
|
|
118
|
-
'GET',
|
|
119
|
-
undefined,
|
|
120
|
-
contextUser
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
// Map basic user details
|
|
124
|
-
const userDetails = this.mapUserDetails(userResponse);
|
|
125
|
-
|
|
126
|
-
// Get enrollments if requested
|
|
127
|
-
if (includeEnrollments) {
|
|
128
|
-
const enrollmentsResponse = await this.makeLearnWorldsRequest<{
|
|
129
|
-
data: any[]
|
|
130
|
-
}>(
|
|
131
|
-
`users/${userId}/enrollments`,
|
|
132
|
-
'GET',
|
|
133
|
-
undefined,
|
|
134
|
-
contextUser
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
if (enrollmentsResponse.data) {
|
|
138
|
-
userDetails.enrollments = enrollmentsResponse.data.map(e => this.mapEnrollment(e));
|
|
139
|
-
|
|
140
|
-
// Calculate enrollment statistics
|
|
141
|
-
this.calculateEnrollmentStats(userDetails);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Get additional stats if requested
|
|
146
|
-
if (includeStats) {
|
|
147
|
-
try {
|
|
148
|
-
const statsResponse = await this.makeLearnWorldsRequest<any>(
|
|
149
|
-
`users/${userId}/stats`,
|
|
150
|
-
'GET',
|
|
151
|
-
undefined,
|
|
152
|
-
contextUser
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
if (statsResponse) {
|
|
156
|
-
this.mergeStatistics(userDetails, statsResponse);
|
|
157
|
-
}
|
|
158
|
-
} catch (error) {
|
|
159
|
-
// Stats endpoint might not be available for all plans
|
|
160
|
-
console.log('Stats endpoint not available:', error);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Create output parameters
|
|
165
|
-
if (!params.Params.find(p => p.Name === 'UserDetails')) {
|
|
166
|
-
params.Params.push({
|
|
167
|
-
Name: 'UserDetails',
|
|
168
|
-
Type: 'Output',
|
|
169
|
-
Value: userDetails
|
|
170
|
-
});
|
|
171
|
-
} else {
|
|
172
|
-
params.Params.find(p => p.Name === 'UserDetails')!.Value = userDetails;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (!params.Params.find(p => p.Name === 'Summary')) {
|
|
176
|
-
params.Params.push({
|
|
177
|
-
Name: 'Summary',
|
|
178
|
-
Type: 'Output',
|
|
179
|
-
Value: this.createUserSummary(userDetails)
|
|
180
|
-
});
|
|
181
|
-
} else {
|
|
182
|
-
params.Params.find(p => p.Name === 'Summary')!.Value = this.createUserSummary(userDetails);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return {
|
|
186
|
-
Success: true,
|
|
187
|
-
ResultCode: 'SUCCESS',
|
|
188
|
-
Message: `Successfully retrieved details for user ${userDetails.email}`
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
} catch (error) {
|
|
192
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
193
|
-
return {
|
|
194
|
-
Success: false,
|
|
195
|
-
ResultCode: 'ERROR',
|
|
196
|
-
Message: errorMessage
|
|
197
|
-
};
|
|
198
|
-
}
|
|
96
|
+
const includeEnrollments = params.IncludeEnrollments ?? true;
|
|
97
|
+
const includeStats = params.IncludeStats ?? true;
|
|
98
|
+
|
|
99
|
+
// Fetch the user from the API
|
|
100
|
+
const userResponse = await this.makeLearnWorldsRequest<LWUserDetailsResponse>(`users/${params.UserID}`, 'GET', undefined, contextUser);
|
|
101
|
+
|
|
102
|
+
// Map basic user details
|
|
103
|
+
const userDetails = this.mapUserDetails(userResponse);
|
|
104
|
+
|
|
105
|
+
// Get enrollments if requested
|
|
106
|
+
if (includeEnrollments) {
|
|
107
|
+
await this.loadEnrollments(userDetails, params.UserID, contextUser);
|
|
199
108
|
}
|
|
200
109
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
private mapUserDetails(lwUser: any): LearnWorldsUserDetails {
|
|
205
|
-
return {
|
|
206
|
-
id: lwUser.id || lwUser._id,
|
|
207
|
-
email: lwUser.email,
|
|
208
|
-
username: lwUser.username || lwUser.email,
|
|
209
|
-
firstName: lwUser.first_name,
|
|
210
|
-
lastName: lwUser.last_name,
|
|
211
|
-
fullName: lwUser.full_name || `${lwUser.first_name || ''} ${lwUser.last_name || ''}`.trim(),
|
|
212
|
-
status: this.mapUserStatus(lwUser.status || 'active'),
|
|
213
|
-
role: lwUser.role || 'student',
|
|
214
|
-
createdAt: this.parseLearnWorldsDate(lwUser.created || lwUser.created_at),
|
|
215
|
-
lastLoginAt: lwUser.last_login ? this.parseLearnWorldsDate(lwUser.last_login) : undefined,
|
|
216
|
-
avatarUrl: lwUser.avatar_url || lwUser.profile_image,
|
|
217
|
-
bio: lwUser.bio || lwUser.description,
|
|
218
|
-
location: lwUser.location || lwUser.country,
|
|
219
|
-
timezone: lwUser.timezone,
|
|
220
|
-
language: lwUser.language || 'en',
|
|
221
|
-
phone: lwUser.phone,
|
|
222
|
-
tags: lwUser.tags || [],
|
|
223
|
-
customFields: lwUser.custom_fields || {},
|
|
224
|
-
|
|
225
|
-
// Initialize statistics
|
|
226
|
-
totalCourses: 0,
|
|
227
|
-
completedCourses: 0,
|
|
228
|
-
inProgressCourses: 0,
|
|
229
|
-
notStartedCourses: 0,
|
|
230
|
-
totalTimeSpent: 0,
|
|
231
|
-
averageCompletionRate: 0,
|
|
232
|
-
lastActivityDate: lwUser.last_activity ? this.parseLearnWorldsDate(lwUser.last_activity) : undefined,
|
|
233
|
-
|
|
234
|
-
// Achievement data
|
|
235
|
-
totalCertificates: lwUser.certificates_count || 0,
|
|
236
|
-
totalBadges: lwUser.badges_count || 0,
|
|
237
|
-
points: lwUser.points || 0,
|
|
238
|
-
level: lwUser.level,
|
|
239
|
-
|
|
240
|
-
// Account settings
|
|
241
|
-
emailNotifications: lwUser.email_notifications,
|
|
242
|
-
twoFactorEnabled: lwUser.two_factor_enabled,
|
|
243
|
-
agreedToTerms: lwUser.agreed_to_terms,
|
|
244
|
-
marketingConsent: lwUser.marketing_consent
|
|
245
|
-
};
|
|
110
|
+
// Get additional stats if requested
|
|
111
|
+
if (includeStats) {
|
|
112
|
+
await this.loadStats(userDetails, params.UserID, contextUser);
|
|
246
113
|
}
|
|
247
114
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
115
|
+
// Build summary
|
|
116
|
+
const summary = this.createUserSummary(userDetails);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
UserDetails: userDetails,
|
|
120
|
+
Summary: summary,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Framework entry point -- delegates to the typed public method.
|
|
126
|
+
*/
|
|
127
|
+
protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
|
|
128
|
+
const { Params, ContextUser } = params;
|
|
129
|
+
this.params = Params;
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
if (!ContextUser) {
|
|
133
|
+
return this.buildErrorResult('ERROR', 'Context user is required for LearnWorlds API calls', Params);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const typedParams = this.extractGetUserDetailsParams(Params);
|
|
137
|
+
const result = await this.GetUserDetails(typedParams, ContextUser);
|
|
138
|
+
|
|
139
|
+
this.setOutputParam(Params, 'UserDetails', result.UserDetails);
|
|
140
|
+
this.setOutputParam(Params, 'Summary', result.Summary);
|
|
141
|
+
|
|
142
|
+
return this.buildSuccessResult(`Successfully retrieved details for user ${result.UserDetails.email}`, Params);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const msg = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
145
|
+
return this.buildErrorResult('ERROR', msg, Params);
|
|
267
146
|
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Extract typed params from the generic ActionParam array
|
|
151
|
+
*/
|
|
152
|
+
private extractGetUserDetailsParams(params: ActionParam[]): GetUserDetailsParams {
|
|
153
|
+
return {
|
|
154
|
+
CompanyID: this.getRequiredStringParam(params, 'CompanyID'),
|
|
155
|
+
UserID: this.getRequiredStringParam(params, 'UserID'),
|
|
156
|
+
IncludeEnrollments: this.getOptionalBooleanParam(params, 'IncludeEnrollments', true),
|
|
157
|
+
IncludeStats: this.getOptionalBooleanParam(params, 'IncludeStats', true),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
268
160
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Map LearnWorlds user data to detailed interface
|
|
163
|
+
*/
|
|
164
|
+
private mapUserDetails(lwUser: LWUserDetailsResponse): LearnWorldsUserDetailsFull {
|
|
165
|
+
return {
|
|
166
|
+
id: lwUser.id || lwUser._id || '',
|
|
167
|
+
email: lwUser.email,
|
|
168
|
+
username: lwUser.username || lwUser.email,
|
|
169
|
+
firstName: lwUser.first_name,
|
|
170
|
+
lastName: lwUser.last_name,
|
|
171
|
+
fullName: lwUser.full_name || `${lwUser.first_name || ''} ${lwUser.last_name || ''}`.trim(),
|
|
172
|
+
status: this.mapUserStatus(lwUser.status || 'active'),
|
|
173
|
+
role: lwUser.role || 'student',
|
|
174
|
+
createdAt: this.parseLearnWorldsDate(lwUser.created || lwUser.created_at || ''),
|
|
175
|
+
lastLoginAt: lwUser.last_login ? this.parseLearnWorldsDate(lwUser.last_login) : undefined,
|
|
176
|
+
avatarUrl: lwUser.avatar_url || lwUser.profile_image,
|
|
177
|
+
bio: lwUser.bio || lwUser.description,
|
|
178
|
+
location: lwUser.location || lwUser.country,
|
|
179
|
+
timezone: lwUser.timezone,
|
|
180
|
+
language: lwUser.language || 'en',
|
|
181
|
+
phone: lwUser.phone,
|
|
182
|
+
tags: lwUser.tags || [],
|
|
183
|
+
customFields: lwUser.custom_fields || {},
|
|
184
|
+
|
|
185
|
+
// Initialize statistics (overwritten by enrollment / stats loading)
|
|
186
|
+
totalCourses: 0,
|
|
187
|
+
completedCourses: 0,
|
|
188
|
+
inProgressCourses: 0,
|
|
189
|
+
notStartedCourses: 0,
|
|
190
|
+
totalTimeSpent: 0,
|
|
191
|
+
averageCompletionRate: 0,
|
|
192
|
+
lastActivityDate: lwUser.last_activity ? this.parseLearnWorldsDate(lwUser.last_activity) : undefined,
|
|
193
|
+
|
|
194
|
+
// Achievement data
|
|
195
|
+
totalCertificates: lwUser.certificates_count || 0,
|
|
196
|
+
totalBadges: lwUser.badges_count || 0,
|
|
197
|
+
points: lwUser.points || 0,
|
|
198
|
+
level: lwUser.level,
|
|
199
|
+
|
|
200
|
+
// Account settings
|
|
201
|
+
emailNotifications: lwUser.email_notifications,
|
|
202
|
+
twoFactorEnabled: lwUser.two_factor_enabled,
|
|
203
|
+
agreedToTerms: lwUser.agreed_to_terms,
|
|
204
|
+
marketingConsent: lwUser.marketing_consent,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Fetch and attach enrollment data to userDetails.
|
|
210
|
+
*/
|
|
211
|
+
private async loadEnrollments(userDetails: LearnWorldsUserDetailsFull, userId: string, contextUser: UserInfo): Promise<void> {
|
|
212
|
+
const enrollmentsResponse = await this.makeLearnWorldsRequest<LWEnrollmentsListResponse>(`users/${userId}/enrollments`, 'GET', undefined, contextUser);
|
|
213
|
+
|
|
214
|
+
if (enrollmentsResponse.data) {
|
|
215
|
+
userDetails.enrollments = enrollmentsResponse.data.map((e) => this.mapEnrollment(e));
|
|
216
|
+
this.calculateEnrollmentStats(userDetails);
|
|
293
217
|
}
|
|
218
|
+
}
|
|
294
219
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
if (stats.points !== undefined) {
|
|
309
|
-
userDetails.points = stats.points;
|
|
310
|
-
}
|
|
220
|
+
/**
|
|
221
|
+
* Fetch and merge additional stats into userDetails.
|
|
222
|
+
*/
|
|
223
|
+
private async loadStats(userDetails: LearnWorldsUserDetailsFull, userId: string, contextUser: UserInfo): Promise<void> {
|
|
224
|
+
try {
|
|
225
|
+
const statsResponse = await this.makeLearnWorldsRequest<LWStatsResponse>(`users/${userId}/stats`, 'GET', undefined, contextUser);
|
|
226
|
+
|
|
227
|
+
if (statsResponse) {
|
|
228
|
+
this.mergeStatistics(userDetails, statsResponse);
|
|
229
|
+
}
|
|
230
|
+
} catch {
|
|
231
|
+
// Stats endpoint might not be available for all plans
|
|
311
232
|
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Map raw enrollment data to our typed UserDetailEnrollment
|
|
237
|
+
*/
|
|
238
|
+
private mapEnrollment(enrollment: LWEnrollmentData): UserDetailEnrollment {
|
|
239
|
+
const progress = this.calculateProgress(enrollment.progress || {});
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
courseId: enrollment.course_id || enrollment.course?.id || '',
|
|
243
|
+
courseTitle: enrollment.course_title || enrollment.course?.title || 'Unknown Course',
|
|
244
|
+
enrolledAt: this.parseLearnWorldsDate(enrollment.enrolled_at || enrollment.created || ''),
|
|
245
|
+
status: this.mapLearnWorldsEnrollmentStatus(enrollment),
|
|
246
|
+
progress: progress.percentage,
|
|
247
|
+
completedAt: enrollment.completed_at ? this.parseLearnWorldsDate(enrollment.completed_at) : undefined,
|
|
248
|
+
expiresAt: enrollment.expires_at ? this.parseLearnWorldsDate(enrollment.expires_at) : undefined,
|
|
249
|
+
lastAccessedAt: enrollment.last_accessed_at ? this.parseLearnWorldsDate(enrollment.last_accessed_at) : undefined,
|
|
250
|
+
timeSpent: progress.timeSpent || enrollment.time_spent || 0,
|
|
251
|
+
certificateUrl: enrollment.certificate_url,
|
|
252
|
+
grade: enrollment.grade || enrollment.final_grade,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Calculate enrollment statistics and attach to userDetails
|
|
258
|
+
*/
|
|
259
|
+
private calculateEnrollmentStats(userDetails: LearnWorldsUserDetailsFull): void {
|
|
260
|
+
if (!userDetails.enrollments) return;
|
|
261
|
+
|
|
262
|
+
userDetails.totalCourses = userDetails.enrollments.length;
|
|
263
|
+
userDetails.completedCourses = userDetails.enrollments.filter((e) => e.status === 'completed').length;
|
|
264
|
+
userDetails.inProgressCourses = userDetails.enrollments.filter((e) => e.status === 'active' && e.progress > 0 && e.progress < 100).length;
|
|
265
|
+
userDetails.notStartedCourses = userDetails.enrollments.filter((e) => e.status === 'active' && e.progress === 0).length;
|
|
312
266
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
role: userDetails.role,
|
|
322
|
-
learningProgress: {
|
|
323
|
-
totalCourses: userDetails.totalCourses,
|
|
324
|
-
completedCourses: userDetails.completedCourses,
|
|
325
|
-
inProgressCourses: userDetails.inProgressCourses,
|
|
326
|
-
notStartedCourses: userDetails.notStartedCourses,
|
|
327
|
-
averageCompletionRate: userDetails.averageCompletionRate,
|
|
328
|
-
totalTimeSpent: this.formatDuration(userDetails.totalTimeSpent)
|
|
329
|
-
},
|
|
330
|
-
achievements: {
|
|
331
|
-
certificates: userDetails.totalCertificates,
|
|
332
|
-
badges: userDetails.totalBadges,
|
|
333
|
-
points: userDetails.points,
|
|
334
|
-
level: userDetails.level
|
|
335
|
-
},
|
|
336
|
-
engagement: {
|
|
337
|
-
accountAge: Math.floor((new Date().getTime() - userDetails.createdAt.getTime()) / (1000 * 60 * 60 * 24)),
|
|
338
|
-
lastLoginDaysAgo: userDetails.lastLoginAt ?
|
|
339
|
-
Math.floor((new Date().getTime() - userDetails.lastLoginAt.getTime()) / (1000 * 60 * 60 * 24)) : null,
|
|
340
|
-
lastActivityDaysAgo: userDetails.lastActivityDate ?
|
|
341
|
-
Math.floor((new Date().getTime() - userDetails.lastActivityDate.getTime()) / (1000 * 60 * 60 * 24)) : null
|
|
342
|
-
},
|
|
343
|
-
recentActivity: userDetails.enrollments ?
|
|
344
|
-
userDetails.enrollments
|
|
345
|
-
.filter(e => e.lastAccessedAt)
|
|
346
|
-
.sort((a, b) => (b.lastAccessedAt?.getTime() || 0) - (a.lastAccessedAt?.getTime() || 0))
|
|
347
|
-
.slice(0, 5)
|
|
348
|
-
.map(e => ({
|
|
349
|
-
courseTitle: e.courseTitle,
|
|
350
|
-
progress: e.progress,
|
|
351
|
-
lastAccessed: e.lastAccessedAt
|
|
352
|
-
})) : []
|
|
353
|
-
};
|
|
267
|
+
// Calculate total time spent
|
|
268
|
+
userDetails.totalTimeSpent = userDetails.enrollments.reduce((sum, e) => sum + e.timeSpent, 0);
|
|
269
|
+
|
|
270
|
+
// Calculate average completion rate
|
|
271
|
+
const activeEnrollments = userDetails.enrollments.filter((e) => e.status === 'active' || e.status === 'completed');
|
|
272
|
+
if (activeEnrollments.length > 0) {
|
|
273
|
+
const totalProgress = activeEnrollments.reduce((sum, e) => sum + e.progress, 0);
|
|
274
|
+
userDetails.averageCompletionRate = Math.round(totalProgress / activeEnrollments.length);
|
|
354
275
|
}
|
|
276
|
+
}
|
|
355
277
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
{
|
|
369
|
-
Name: 'IncludeEnrollments',
|
|
370
|
-
Type: 'Input',
|
|
371
|
-
Value: true
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
Name: 'IncludeStats',
|
|
375
|
-
Type: 'Input',
|
|
376
|
-
Value: true
|
|
377
|
-
}
|
|
378
|
-
];
|
|
379
|
-
|
|
380
|
-
return [...baseParams, ...specificParams];
|
|
278
|
+
/**
|
|
279
|
+
* Merge additional statistics from the stats endpoint
|
|
280
|
+
*/
|
|
281
|
+
private mergeStatistics(userDetails: LearnWorldsUserDetailsFull, stats: LWStatsResponse): void {
|
|
282
|
+
if (stats.total_time_spent) {
|
|
283
|
+
userDetails.totalTimeSpent = stats.total_time_spent;
|
|
284
|
+
}
|
|
285
|
+
if (stats.certificates_earned !== undefined) {
|
|
286
|
+
userDetails.totalCertificates = stats.certificates_earned;
|
|
287
|
+
}
|
|
288
|
+
if (stats.badges_earned !== undefined) {
|
|
289
|
+
userDetails.totalBadges = stats.badges_earned;
|
|
381
290
|
}
|
|
382
|
-
|
|
291
|
+
if (stats.points !== undefined) {
|
|
292
|
+
userDetails.points = stats.points;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Create a summary of user information
|
|
298
|
+
*/
|
|
299
|
+
private createUserSummary(userDetails: LearnWorldsUserDetailsFull): Record<string, unknown> {
|
|
300
|
+
const recentActivity = userDetails.enrollments
|
|
301
|
+
? userDetails.enrollments
|
|
302
|
+
.filter((e) => e.lastAccessedAt)
|
|
303
|
+
.sort((a, b) => (b.lastAccessedAt?.getTime() || 0) - (a.lastAccessedAt?.getTime() || 0))
|
|
304
|
+
.slice(0, 5)
|
|
305
|
+
.map((e) => ({
|
|
306
|
+
courseTitle: e.courseTitle,
|
|
307
|
+
progress: e.progress,
|
|
308
|
+
lastAccessed: e.lastAccessedAt,
|
|
309
|
+
}))
|
|
310
|
+
: [];
|
|
311
|
+
|
|
312
|
+
return {
|
|
313
|
+
userId: userDetails.id,
|
|
314
|
+
displayName: userDetails.fullName || userDetails.email,
|
|
315
|
+
status: userDetails.status,
|
|
316
|
+
role: userDetails.role,
|
|
317
|
+
learningProgress: {
|
|
318
|
+
totalCourses: userDetails.totalCourses,
|
|
319
|
+
completedCourses: userDetails.completedCourses,
|
|
320
|
+
inProgressCourses: userDetails.inProgressCourses,
|
|
321
|
+
notStartedCourses: userDetails.notStartedCourses,
|
|
322
|
+
averageCompletionRate: userDetails.averageCompletionRate,
|
|
323
|
+
totalTimeSpent: this.formatDuration(userDetails.totalTimeSpent),
|
|
324
|
+
},
|
|
325
|
+
achievements: {
|
|
326
|
+
certificates: userDetails.totalCertificates,
|
|
327
|
+
badges: userDetails.totalBadges,
|
|
328
|
+
points: userDetails.points,
|
|
329
|
+
level: userDetails.level,
|
|
330
|
+
},
|
|
331
|
+
engagement: {
|
|
332
|
+
accountAge: Math.floor((new Date().getTime() - userDetails.createdAt.getTime()) / (1000 * 60 * 60 * 24)),
|
|
333
|
+
lastLoginDaysAgo: userDetails.lastLoginAt ? Math.floor((new Date().getTime() - userDetails.lastLoginAt.getTime()) / (1000 * 60 * 60 * 24)) : null,
|
|
334
|
+
lastActivityDaysAgo: userDetails.lastActivityDate
|
|
335
|
+
? Math.floor((new Date().getTime() - userDetails.lastActivityDate.getTime()) / (1000 * 60 * 60 * 24))
|
|
336
|
+
: null,
|
|
337
|
+
},
|
|
338
|
+
recentActivity,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Define the parameters for this action
|
|
344
|
+
*/
|
|
345
|
+
public get Params(): ActionParam[] {
|
|
346
|
+
const baseParams = this.getCommonLMSParams();
|
|
347
|
+
|
|
348
|
+
const specificParams: ActionParam[] = [
|
|
349
|
+
{
|
|
350
|
+
Name: 'UserID',
|
|
351
|
+
Type: 'Input',
|
|
352
|
+
Value: null,
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
Name: 'IncludeEnrollments',
|
|
356
|
+
Type: 'Input',
|
|
357
|
+
Value: true,
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
Name: 'IncludeStats',
|
|
361
|
+
Type: 'Input',
|
|
362
|
+
Value: true,
|
|
363
|
+
},
|
|
364
|
+
];
|
|
365
|
+
|
|
366
|
+
return [...baseParams, ...specificParams];
|
|
367
|
+
}
|
|
368
|
+
}
|