@memberjunction/actions-bizapps-lms 2.55.0 → 2.56.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.
Files changed (49) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +15 -0
  3. package/README.md +321 -0
  4. package/dist/providers/learnworlds/actions/create-user.action.d.ts +20 -0
  5. package/dist/providers/learnworlds/actions/create-user.action.d.ts.map +1 -0
  6. package/dist/providers/learnworlds/actions/create-user.action.js +243 -0
  7. package/dist/providers/learnworlds/actions/create-user.action.js.map +1 -0
  8. package/dist/providers/learnworlds/actions/enroll-user.action.d.ts +20 -0
  9. package/dist/providers/learnworlds/actions/enroll-user.action.d.ts.map +1 -0
  10. package/dist/providers/learnworlds/actions/enroll-user.action.js +208 -0
  11. package/dist/providers/learnworlds/actions/enroll-user.action.js.map +1 -0
  12. package/dist/providers/learnworlds/actions/get-certificates.action.d.ts +20 -0
  13. package/dist/providers/learnworlds/actions/get-certificates.action.d.ts.map +1 -0
  14. package/dist/providers/learnworlds/actions/get-certificates.action.js +301 -0
  15. package/dist/providers/learnworlds/actions/get-certificates.action.js.map +1 -0
  16. package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts +36 -0
  17. package/dist/providers/learnworlds/actions/get-course-analytics.action.d.ts.map +1 -0
  18. package/dist/providers/learnworlds/actions/get-course-analytics.action.js +333 -0
  19. package/dist/providers/learnworlds/actions/get-course-analytics.action.js.map +1 -0
  20. package/dist/providers/learnworlds/actions/get-course-details.action.d.ts +28 -0
  21. package/dist/providers/learnworlds/actions/get-course-details.action.d.ts.map +1 -0
  22. package/dist/providers/learnworlds/actions/get-course-details.action.js +237 -0
  23. package/dist/providers/learnworlds/actions/get-course-details.action.js.map +1 -0
  24. package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts +28 -0
  25. package/dist/providers/learnworlds/actions/get-quiz-results.action.d.ts.map +1 -0
  26. package/dist/providers/learnworlds/actions/get-quiz-results.action.js +368 -0
  27. package/dist/providers/learnworlds/actions/get-quiz-results.action.js.map +1 -0
  28. package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts +20 -0
  29. package/dist/providers/learnworlds/actions/get-user-enrollments.action.d.ts.map +1 -0
  30. package/dist/providers/learnworlds/actions/get-user-enrollments.action.js +228 -0
  31. package/dist/providers/learnworlds/actions/get-user-enrollments.action.js.map +1 -0
  32. package/dist/providers/learnworlds/actions/index.d.ts +8 -0
  33. package/dist/providers/learnworlds/actions/index.d.ts.map +1 -1
  34. package/dist/providers/learnworlds/actions/index.js +8 -0
  35. package/dist/providers/learnworlds/actions/index.js.map +1 -1
  36. package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts +20 -0
  37. package/dist/providers/learnworlds/actions/update-user-progress.action.d.ts.map +1 -0
  38. package/dist/providers/learnworlds/actions/update-user-progress.action.js +254 -0
  39. package/dist/providers/learnworlds/actions/update-user-progress.action.js.map +1 -0
  40. package/package.json +6 -6
  41. package/src/providers/learnworlds/actions/create-user.action.ts +249 -0
  42. package/src/providers/learnworlds/actions/enroll-user.action.ts +233 -0
  43. package/src/providers/learnworlds/actions/get-certificates.action.ts +332 -0
  44. package/src/providers/learnworlds/actions/get-course-analytics.action.ts +359 -0
  45. package/src/providers/learnworlds/actions/get-course-details.action.ts +267 -0
  46. package/src/providers/learnworlds/actions/get-quiz-results.action.ts +399 -0
  47. package/src/providers/learnworlds/actions/get-user-enrollments.action.ts +242 -0
  48. package/src/providers/learnworlds/actions/index.ts +9 -1
  49. package/src/providers/learnworlds/actions/update-user-progress.action.ts +277 -0
@@ -2,4 +2,12 @@ export * from './get-users.action';
2
2
  export * from './get-user-details.action';
3
3
  export * from './get-user-progress.action';
4
4
  export * from './get-courses.action';
5
+ export * from './get-course-details.action';
6
+ export * from './enroll-user.action';
7
+ export * from './get-user-enrollments.action';
8
+ export * from './get-course-analytics.action';
9
+ export * from './create-user.action';
10
+ export * from './update-user-progress.action';
11
+ export * from './get-certificates.action';
12
+ export * from './get-quiz-results.action';
5
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/index.ts"],"names":[],"mappings":"AACA,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC"}
@@ -19,4 +19,12 @@ __exportStar(require("./get-users.action"), exports);
19
19
  __exportStar(require("./get-user-details.action"), exports);
20
20
  __exportStar(require("./get-user-progress.action"), exports);
21
21
  __exportStar(require("./get-courses.action"), exports);
22
+ __exportStar(require("./get-course-details.action"), exports);
23
+ __exportStar(require("./enroll-user.action"), exports);
24
+ __exportStar(require("./get-user-enrollments.action"), exports);
25
+ __exportStar(require("./get-course-analytics.action"), exports);
26
+ __exportStar(require("./create-user.action"), exports);
27
+ __exportStar(require("./update-user-progress.action"), exports);
28
+ __exportStar(require("./get-certificates.action"), exports);
29
+ __exportStar(require("./get-quiz-results.action"), exports);
22
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,qDAAmC;AACnC,4DAA0C;AAC1C,6DAA2C;AAC3C,uDAAqC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,qDAAmC;AACnC,4DAA0C;AAC1C,6DAA2C;AAC3C,uDAAqC;AACrC,8DAA4C;AAC5C,uDAAqC;AACrC,gEAA8C;AAC9C,gEAA8C;AAC9C,uDAAqC;AACrC,gEAA8C;AAC9C,4DAA0C;AAC1C,4DAA0C"}
@@ -0,0 +1,20 @@
1
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action';
2
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
3
+ /**
4
+ * Action to update a user's course progress in LearnWorlds
5
+ */
6
+ export declare class UpdateUserProgressAction extends LearnWorldsBaseAction {
7
+ /**
8
+ * Update user progress for a course or lesson
9
+ */
10
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
11
+ /**
12
+ * Define the parameters this action expects
13
+ */
14
+ get Params(): ActionParam[];
15
+ /**
16
+ * Metadata about this action
17
+ */
18
+ get Description(): string;
19
+ }
20
+ //# sourceMappingURL=update-user-progress.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-user-progress.action.d.ts","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/update-user-progress.action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEhG;;GAEG;AACH,qBACa,wBAAyB,SAAQ,qBAAqB;IAC/D;;OAEG;cACa,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsMvF;;OAEG;IACH,IAAW,MAAM,IAAI,WAAW,EAAE,CAuDjC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;CACJ"}
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.UpdateUserProgressAction = void 0;
10
+ const global_1 = require("@memberjunction/global");
11
+ const learnworlds_base_action_1 = require("../learnworlds-base.action");
12
+ /**
13
+ * Action to update a user's course progress in LearnWorlds
14
+ */
15
+ let UpdateUserProgressAction = class UpdateUserProgressAction extends learnworlds_base_action_1.LearnWorldsBaseAction {
16
+ /**
17
+ * Update user progress for a course or lesson
18
+ */
19
+ async InternalRunAction(params) {
20
+ const { Params, ContextUser } = params;
21
+ this.params = Params; // Set params for base class to use
22
+ try {
23
+ // Extract and validate parameters
24
+ const userId = this.getParamValue(Params, 'UserID');
25
+ const courseId = this.getParamValue(Params, 'CourseID');
26
+ const lessonId = this.getParamValue(Params, 'LessonID');
27
+ const progressPercentage = this.getParamValue(Params, 'ProgressPercentage');
28
+ const completed = this.getParamValue(Params, 'Completed');
29
+ const timeSpent = this.getParamValue(Params, 'TimeSpent');
30
+ const score = this.getParamValue(Params, 'Score');
31
+ const notes = this.getParamValue(Params, 'Notes');
32
+ if (!userId) {
33
+ return {
34
+ Success: false,
35
+ ResultCode: 'VALIDATION_ERROR',
36
+ Message: 'UserID is required',
37
+ Params
38
+ };
39
+ }
40
+ if (!courseId) {
41
+ return {
42
+ Success: false,
43
+ ResultCode: 'VALIDATION_ERROR',
44
+ Message: 'CourseID is required',
45
+ Params
46
+ };
47
+ }
48
+ // Get current enrollment first
49
+ let currentEnrollment;
50
+ try {
51
+ currentEnrollment = await this.makeLearnWorldsRequest(`users/${userId}/enrollments/${courseId}`, 'GET', undefined, ContextUser);
52
+ }
53
+ catch (error) {
54
+ return {
55
+ Success: false,
56
+ ResultCode: 'NOT_ENROLLED',
57
+ Message: 'User is not enrolled in this course',
58
+ Params
59
+ };
60
+ }
61
+ let updateResult = {};
62
+ // Update lesson progress if lessonId is provided
63
+ if (lessonId) {
64
+ const lessonProgressData = {
65
+ completed: completed !== undefined ? completed : false,
66
+ progress_percentage: progressPercentage
67
+ };
68
+ if (timeSpent !== undefined) {
69
+ lessonProgressData.time_spent = timeSpent;
70
+ }
71
+ if (score !== undefined) {
72
+ lessonProgressData.score = score;
73
+ }
74
+ if (notes) {
75
+ lessonProgressData.notes = notes;
76
+ }
77
+ try {
78
+ const lessonUpdateData = await this.makeLearnWorldsRequest(`users/${userId}/courses/${courseId}/lessons/${lessonId}/progress`, 'PUT', lessonProgressData, ContextUser);
79
+ updateResult.lessonProgress = lessonUpdateData;
80
+ }
81
+ catch (error) {
82
+ return {
83
+ Success: false,
84
+ ResultCode: 'UPDATE_FAILED',
85
+ Message: error instanceof Error ? error.message : 'Failed to update lesson progress',
86
+ Params
87
+ };
88
+ }
89
+ }
90
+ // Update overall course progress if progressPercentage is provided at course level
91
+ if (progressPercentage !== undefined && !lessonId) {
92
+ const courseProgressData = {
93
+ progress_percentage: progressPercentage
94
+ };
95
+ if (completed !== undefined) {
96
+ courseProgressData.completed = completed;
97
+ }
98
+ if (timeSpent !== undefined) {
99
+ courseProgressData.total_time_spent = (currentEnrollment.total_time_spent || 0) + timeSpent;
100
+ }
101
+ try {
102
+ const courseUpdateData = await this.makeLearnWorldsRequest(`users/${userId}/enrollments/${courseId}/progress`, 'PUT', courseProgressData, ContextUser);
103
+ updateResult.courseProgress = courseUpdateData;
104
+ }
105
+ catch (error) {
106
+ return {
107
+ Success: false,
108
+ ResultCode: 'UPDATE_FAILED',
109
+ Message: error instanceof Error ? error.message : 'Failed to update course progress',
110
+ Params
111
+ };
112
+ }
113
+ }
114
+ // Get updated enrollment details
115
+ let updatedProgress = currentEnrollment;
116
+ try {
117
+ updatedProgress = await this.makeLearnWorldsRequest(`users/${userId}/enrollments/${courseId}`, 'GET', undefined, ContextUser);
118
+ }
119
+ catch (error) {
120
+ // If we can't get updated details, use current enrollment
121
+ console.warn('Failed to get updated enrollment details:', error);
122
+ }
123
+ // Format progress details
124
+ const progressDetails = {
125
+ userId: userId,
126
+ courseId: courseId,
127
+ lessonId: lessonId,
128
+ previousProgress: {
129
+ percentage: currentEnrollment.progress_percentage || 0,
130
+ completedUnits: currentEnrollment.completed_units || 0,
131
+ totalTimeSpent: currentEnrollment.total_time_spent || 0
132
+ },
133
+ updatedProgress: {
134
+ percentage: updatedProgress.progress_percentage || 0,
135
+ completedUnits: updatedProgress.completed_units || 0,
136
+ totalUnits: updatedProgress.total_units || 0,
137
+ totalTimeSpent: updatedProgress.total_time_spent || 0,
138
+ totalTimeSpentText: this.formatDuration(updatedProgress.total_time_spent || 0),
139
+ lastAccessedAt: updatedProgress.last_accessed_at || new Date().toISOString(),
140
+ completed: updatedProgress.completed || false,
141
+ completedAt: updatedProgress.completed_at
142
+ },
143
+ updateType: lessonId ? 'lesson' : 'course',
144
+ updateResult: updateResult
145
+ };
146
+ // Create summary
147
+ const summary = {
148
+ userId: userId,
149
+ courseId: courseId,
150
+ lessonId: lessonId,
151
+ progressIncreased: (updatedProgress.progress_percentage || 0) > (currentEnrollment.progress_percentage || 0),
152
+ previousPercentage: currentEnrollment.progress_percentage || 0,
153
+ newPercentage: updatedProgress.progress_percentage || 0,
154
+ timeAdded: timeSpent || 0,
155
+ totalTimeSpent: updatedProgress.total_time_spent || 0,
156
+ isCompleted: updatedProgress.completed || false,
157
+ updateType: progressDetails.updateType
158
+ };
159
+ // Update output parameters
160
+ const outputParams = [...Params];
161
+ const progressDetailsParam = outputParams.find(p => p.Name === 'ProgressDetails');
162
+ if (progressDetailsParam)
163
+ progressDetailsParam.Value = progressDetails;
164
+ const summaryParam = outputParams.find(p => p.Name === 'Summary');
165
+ if (summaryParam)
166
+ summaryParam.Value = summary;
167
+ return {
168
+ Success: true,
169
+ ResultCode: 'SUCCESS',
170
+ Message: `Successfully updated ${progressDetails.updateType} progress`,
171
+ Params: outputParams
172
+ };
173
+ }
174
+ catch (error) {
175
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
176
+ return {
177
+ Success: false,
178
+ ResultCode: 'ERROR',
179
+ Message: `Error updating progress: ${errorMessage}`,
180
+ Params
181
+ };
182
+ }
183
+ }
184
+ /**
185
+ * Define the parameters this action expects
186
+ */
187
+ get Params() {
188
+ const baseParams = this.getCommonLMSParams();
189
+ const specificParams = [
190
+ {
191
+ Name: 'UserID',
192
+ Type: 'Input',
193
+ Value: null
194
+ },
195
+ {
196
+ Name: 'CourseID',
197
+ Type: 'Input',
198
+ Value: null
199
+ },
200
+ {
201
+ Name: 'LessonID',
202
+ Type: 'Input',
203
+ Value: null
204
+ },
205
+ {
206
+ Name: 'ProgressPercentage',
207
+ Type: 'Input',
208
+ Value: null
209
+ },
210
+ {
211
+ Name: 'Completed',
212
+ Type: 'Input',
213
+ Value: null
214
+ },
215
+ {
216
+ Name: 'TimeSpent',
217
+ Type: 'Input',
218
+ Value: null
219
+ },
220
+ {
221
+ Name: 'Score',
222
+ Type: 'Input',
223
+ Value: null
224
+ },
225
+ {
226
+ Name: 'Notes',
227
+ Type: 'Input',
228
+ Value: null
229
+ },
230
+ {
231
+ Name: 'ProgressDetails',
232
+ Type: 'Output',
233
+ Value: null
234
+ },
235
+ {
236
+ Name: 'Summary',
237
+ Type: 'Output',
238
+ Value: null
239
+ }
240
+ ];
241
+ return [...baseParams, ...specificParams];
242
+ }
243
+ /**
244
+ * Metadata about this action
245
+ */
246
+ get Description() {
247
+ return 'Updates a user\'s progress for a course or specific lesson in LearnWorlds';
248
+ }
249
+ };
250
+ exports.UpdateUserProgressAction = UpdateUserProgressAction;
251
+ exports.UpdateUserProgressAction = UpdateUserProgressAction = __decorate([
252
+ (0, global_1.RegisterClass)(learnworlds_base_action_1.LearnWorldsBaseAction, 'UpdateUserProgressAction')
253
+ ], UpdateUserProgressAction);
254
+ //# sourceMappingURL=update-user-progress.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-user-progress.action.js","sourceRoot":"","sources":["../../../../src/providers/learnworlds/actions/update-user-progress.action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mDAAuD;AACvD,wEAAmE;AAGnE;;GAEG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,+CAAqB;IAC/D;;OAEG;IACO,KAAK,CAAC,iBAAiB,CAAC,MAAuB;QACrD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,mCAAmC;QAEzD,IAAI,CAAC;YACD,kCAAkC;YAClC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACxD,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;YAC5E,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAClD,MAAM,KAAK,GAAG,IAAI,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BACf,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,IAAI;aACd;SACJ,CAAC;QACF,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,cAAc,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,2EAA2E,CAAC;IACvF,CAAC;CACJ,CAAA;AA5QY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAa,EAAC,+CAAqB,EAAE,0BAA0B,CAAC;GACpD,wBAAwB,CA4QpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/actions-bizapps-lms",
3
- "version": "2.55.0",
3
+ "version": "2.56.0",
4
4
  "description": "LMS system integration actions for MemberJunction",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,11 +23,11 @@
23
23
  "author": "MemberJunction",
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
- "@memberjunction/core": "2.55.0",
27
- "@memberjunction/global": "2.55.0",
28
- "@memberjunction/actions-base": "2.55.0",
29
- "@memberjunction/actions": "2.55.0",
30
- "@memberjunction/core-entities": "2.55.0"
26
+ "@memberjunction/core": "2.56.0",
27
+ "@memberjunction/global": "2.56.0",
28
+ "@memberjunction/actions-base": "2.56.0",
29
+ "@memberjunction/actions": "2.56.0",
30
+ "@memberjunction/core-entities": "2.56.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "20.8.7",
@@ -0,0 +1,249 @@
1
+ import { RegisterClass } from '@memberjunction/global';
2
+ import { LearnWorldsBaseAction } from '../learnworlds-base.action';
3
+ import { ActionParam, ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
4
+
5
+ /**
6
+ * Action to create a new user in LearnWorlds
7
+ */
8
+ @RegisterClass(LearnWorldsBaseAction, 'CreateUserAction')
9
+ export class CreateUserAction extends LearnWorldsBaseAction {
10
+ /**
11
+ * Create a new user
12
+ */
13
+ protected async InternalRunAction(params: RunActionParams): Promise<ActionResultSimple> {
14
+ const { Params, ContextUser } = params;
15
+ this.params = Params; // Set params for base class to use
16
+
17
+ try {
18
+ // Extract and validate parameters
19
+ const email = this.getParamValue(Params, 'Email');
20
+ const username = this.getParamValue(Params, 'Username');
21
+ const password = this.getParamValue(Params, 'Password');
22
+ const firstName = this.getParamValue(Params, 'FirstName');
23
+ const lastName = this.getParamValue(Params, 'LastName');
24
+ const role = this.getParamValue(Params, 'Role') || 'student';
25
+ const isActive = this.getParamValue(Params, 'IsActive') !== false;
26
+ const sendWelcomeEmail = this.getParamValue(Params, 'SendWelcomeEmail') !== false;
27
+ const tags = this.getParamValue(Params, 'Tags');
28
+ const customFields = this.getParamValue(Params, 'CustomFields');
29
+ const enrollInCourses = this.getParamValue(Params, 'EnrollInCourses');
30
+
31
+ if (!email) {
32
+ return {
33
+ Success: false,
34
+ ResultCode: 'VALIDATION_ERROR',
35
+ Message: 'Email is required',
36
+ Params
37
+ };
38
+ }
39
+
40
+ // Prepare user data
41
+ const userData: any = {
42
+ email: email,
43
+ role: role,
44
+ is_active: isActive
45
+ };
46
+
47
+ // Add optional fields
48
+ if (username) userData.username = username;
49
+ if (password) userData.password = password;
50
+ if (firstName) userData.first_name = firstName;
51
+ if (lastName) userData.last_name = lastName;
52
+ if (sendWelcomeEmail !== undefined) userData.send_welcome_email = sendWelcomeEmail;
53
+
54
+ // Add tags if provided (expecting comma-separated string or array)
55
+ if (tags) {
56
+ userData.tags = Array.isArray(tags) ? tags : tags.split(',').map((t: string) => t.trim());
57
+ }
58
+
59
+ // Add custom fields if provided
60
+ if (customFields) {
61
+ userData.custom_fields = customFields;
62
+ }
63
+
64
+ // Create user
65
+ const newUser = await this.makeLearnWorldsRequest<any>(
66
+ 'users',
67
+ 'POST',
68
+ userData,
69
+ ContextUser
70
+ );
71
+
72
+ // Format user details
73
+ const userDetails = {
74
+ id: newUser.id,
75
+ email: newUser.email,
76
+ username: newUser.username,
77
+ firstName: newUser.first_name,
78
+ lastName: newUser.last_name,
79
+ fullName: `${newUser.first_name || ''} ${newUser.last_name || ''}`.trim(),
80
+ role: newUser.role,
81
+ status: newUser.is_active ? 'active' : 'inactive',
82
+ tags: newUser.tags || [],
83
+ customFields: newUser.custom_fields || {},
84
+ createdAt: newUser.created_at,
85
+ loginUrl: newUser.login_url,
86
+ resetPasswordUrl: newUser.reset_password_url
87
+ };
88
+
89
+ // Enroll in courses if requested
90
+ const enrollmentResults: any[] = [];
91
+ if (enrollInCourses && enrollInCourses.length > 0) {
92
+ const courseIds = Array.isArray(enrollInCourses) ? enrollInCourses : [enrollInCourses];
93
+
94
+ for (const courseId of courseIds) {
95
+ try {
96
+ const enrollData = await this.makeLearnWorldsRequest<any>(
97
+ `courses/${courseId}/enrollments`,
98
+ 'POST',
99
+ {
100
+ user_id: newUser.id,
101
+ justification: 'Enrolled during user creation',
102
+ notify_user: false
103
+ },
104
+ ContextUser
105
+ );
106
+
107
+ enrollmentResults.push({
108
+ courseId: courseId,
109
+ success: true,
110
+ enrollmentId: enrollData.id
111
+ });
112
+ } catch (enrollError) {
113
+ enrollmentResults.push({
114
+ courseId: courseId,
115
+ success: false,
116
+ error: enrollError instanceof Error ? enrollError.message : 'Enrollment failed'
117
+ });
118
+ }
119
+ }
120
+ }
121
+
122
+ // Create summary
123
+ const summary = {
124
+ userId: userDetails.id,
125
+ email: userDetails.email,
126
+ username: userDetails.username,
127
+ fullName: userDetails.fullName,
128
+ role: userDetails.role,
129
+ status: userDetails.status,
130
+ welcomeEmailSent: sendWelcomeEmail,
131
+ coursesEnrolled: enrollmentResults.filter(r => r.success).length,
132
+ totalCoursesRequested: enrollmentResults.length,
133
+ loginUrl: userDetails.loginUrl
134
+ };
135
+
136
+ // Update output parameters
137
+ const outputParams = [...Params];
138
+ const userDetailsParam = outputParams.find(p => p.Name === 'UserDetails');
139
+ if (userDetailsParam) userDetailsParam.Value = userDetails;
140
+ const enrollmentResultsParam = outputParams.find(p => p.Name === 'EnrollmentResults');
141
+ if (enrollmentResultsParam) enrollmentResultsParam.Value = enrollmentResults;
142
+ const summaryParam = outputParams.find(p => p.Name === 'Summary');
143
+ if (summaryParam) summaryParam.Value = summary;
144
+
145
+ return {
146
+ Success: true,
147
+ ResultCode: 'SUCCESS',
148
+ Message: `Successfully created user ${userDetails.email}`,
149
+ Params: outputParams
150
+ };
151
+
152
+ } catch (error) {
153
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
154
+ return {
155
+ Success: false,
156
+ ResultCode: 'ERROR',
157
+ Message: `Error creating user: ${errorMessage}`,
158
+ Params
159
+ };
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Define the parameters this action expects
165
+ */
166
+ public get Params(): ActionParam[] {
167
+ const baseParams = this.getCommonLMSParams();
168
+ const specificParams: ActionParam[] = [
169
+ {
170
+ Name: 'Email',
171
+ Type: 'Input',
172
+ Value: null
173
+ },
174
+ {
175
+ Name: 'Username',
176
+ Type: 'Input',
177
+ Value: null
178
+ },
179
+ {
180
+ Name: 'Password',
181
+ Type: 'Input',
182
+ Value: null
183
+ },
184
+ {
185
+ Name: 'FirstName',
186
+ Type: 'Input',
187
+ Value: null
188
+ },
189
+ {
190
+ Name: 'LastName',
191
+ Type: 'Input',
192
+ Value: null
193
+ },
194
+ {
195
+ Name: 'Role',
196
+ Type: 'Input',
197
+ Value: 'student'
198
+ },
199
+ {
200
+ Name: 'IsActive',
201
+ Type: 'Input',
202
+ Value: true
203
+ },
204
+ {
205
+ Name: 'SendWelcomeEmail',
206
+ Type: 'Input',
207
+ Value: true
208
+ },
209
+ {
210
+ Name: 'Tags',
211
+ Type: 'Input',
212
+ Value: null
213
+ },
214
+ {
215
+ Name: 'CustomFields',
216
+ Type: 'Input',
217
+ Value: null
218
+ },
219
+ {
220
+ Name: 'EnrollInCourses',
221
+ Type: 'Input',
222
+ Value: null
223
+ },
224
+ {
225
+ Name: 'UserDetails',
226
+ Type: 'Output',
227
+ Value: null
228
+ },
229
+ {
230
+ Name: 'EnrollmentResults',
231
+ Type: 'Output',
232
+ Value: null
233
+ },
234
+ {
235
+ Name: 'Summary',
236
+ Type: 'Output',
237
+ Value: null
238
+ }
239
+ ];
240
+ return [...baseParams, ...specificParams];
241
+ }
242
+
243
+ /**
244
+ * Metadata about this action
245
+ */
246
+ public get Description(): string {
247
+ return 'Creates a new user in LearnWorlds with optional course enrollments and welcome email';
248
+ }
249
+ }