@memberjunction/actions-bizapps-lms 4.0.0 → 4.1.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.
@@ -1,6 +1,4 @@
1
-
2
- 
3
- > @memberjunction/actions-bizapps-lms@4.0.0 build
4
- > tsc && tsc-alias -f
5
-
6
- ⠙
1
+
2
+ > @memberjunction/actions-bizapps-lms@4.1.0 build
3
+ > tsc && tsc-alias -f
4
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @memberjunction/actions-bizapps-lms
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [77839a9]
8
+ - Updated dependencies [2ea241f]
9
+ - Updated dependencies [5af036f]
10
+ - @memberjunction/core@4.1.0
11
+ - @memberjunction/core-entities@4.1.0
12
+ - @memberjunction/actions-base@4.1.0
13
+ - @memberjunction/actions@4.1.0
14
+ - @memberjunction/global@4.1.0
15
+
3
16
  ## 4.0.0
4
17
 
5
18
  ### Major Changes
package/README.md CHANGED
@@ -1,118 +1,80 @@
1
1
  # @memberjunction/actions-bizapps-lms
2
2
 
3
- Learning Management System (LMS) integration actions for MemberJunction. This package provides a standardized way to interact with various LMS platforms through MemberJunction's action framework.
3
+ Learning Management System (LMS) integration actions for MemberJunction. This package provides a standardized, multi-provider interface for interacting with LMS platforms through the MemberJunction Actions framework, currently supporting LearnWorlds with an extensible architecture for additional providers.
4
4
 
5
- ## Overview
6
-
7
- This package implements actions for common LMS operations across multiple learning platforms:
8
- - LearnWorlds ✅
9
- - Moodle (coming soon)
10
- - Canvas (coming soon)
11
- - Blackboard (coming soon)
12
- - LearnDash (coming soon)
5
+ For general Actions framework concepts, patterns, and the "Actions as boundaries" philosophy, see the [Actions README](../../README.md) and [Actions CLAUDE.md](../../CLAUDE.md). For shared BizApps patterns (credential management, provider base classes, multi-tenant support), see the [BizApps README](../README.md).
13
6
 
14
7
  ## Architecture
15
8
 
16
- ### Base Classes
17
-
18
- - **BaseLMSAction**: Abstract base class providing common functionality for all LMS actions
19
- - Company-based credential management via CompanyIntegration entity
20
- - Common parameter definitions
21
- - Learning-specific utilities (progress calculation, duration formatting)
22
- - Error handling patterns
23
-
24
- - **Provider-Specific Base Classes** (e.g., LearnWorldsBaseAction):
25
- - Handle provider-specific authentication
26
- - API request/response handling
27
- - Pagination support
28
- - Data mapping between provider formats and standard formats
9
+ The package follows a three-tier class hierarchy: a domain-level base class providing common LMS utilities, provider-specific base classes handling API authentication and communication, and individual action classes implementing specific operations.
10
+
11
+ ```mermaid
12
+ graph TD
13
+ subgraph Framework["MemberJunction Actions Framework"]
14
+ BA[BaseAction<br/>@memberjunction/actions]
15
+ end
16
+
17
+ subgraph Domain["Domain Layer"]
18
+ BLMS[BaseLMSAction<br/>Credential management<br/>Progress calculation<br/>Duration formatting<br/>Enrollment status mapping]
19
+ end
20
+
21
+ subgraph Provider["Provider Layer"]
22
+ LWBase[LearnWorldsBaseAction<br/>API v2 authentication<br/>Paginated requests<br/>Date format conversion<br/>Status mapping]
23
+ end
24
+
25
+ subgraph Actions["LearnWorlds Actions"]
26
+ direction LR
27
+ UM["User Management<br/>GetUsers | GetUserDetails<br/>CreateUser | GetUserProgress"]
28
+ CM["Course Management<br/>GetCourses | GetCourseDetails<br/>GetCourseAnalytics"]
29
+ EM["Enrollment Management<br/>EnrollUser | GetUserEnrollments<br/>UpdateUserProgress"]
30
+ AM["Assessment & Certs<br/>GetQuizResults<br/>GetCertificates"]
31
+ end
32
+
33
+ BA --> BLMS
34
+ BLMS --> LWBase
35
+ LWBase --> UM
36
+ LWBase --> CM
37
+ LWBase --> EM
38
+ LWBase --> AM
39
+
40
+ style Framework fill:#64748b,stroke:#475569,color:#fff
41
+ style Domain fill:#2d6a9f,stroke:#1a4971,color:#fff
42
+ style Provider fill:#7c5295,stroke:#563a6b,color:#fff
43
+ style Actions fill:#2d8659,stroke:#1a5c3a,color:#fff
44
+ ```
29
45
 
30
- ### Authentication
46
+ ### Credential Resolution Flow
47
+
48
+ All actions resolve API credentials through a consistent two-step process, checking environment variables first with a database fallback.
49
+
50
+ ```mermaid
51
+ flowchart LR
52
+ A[Action invoked<br/>with CompanyID] --> B{Check env var<br/>BIZAPPS_LEARNWORLDS<br/>_CompanyID_API_KEY}
53
+ B -- Found --> D[Use env credentials]
54
+ B -- Not found --> C[Query CompanyIntegration<br/>entity from database]
55
+ C --> E{APIKey or<br/>AccessToken<br/>present?}
56
+ E -- Yes --> F[Use DB credentials]
57
+ E -- No --> G[Throw error:<br/>No credentials found]
58
+ D --> H[Build API request<br/>with Bearer token]
59
+ F --> H
60
+
61
+ style A fill:#2d6a9f,stroke:#1a4971,color:#fff
62
+ style B fill:#b8762f,stroke:#8a5722,color:#fff
63
+ style C fill:#7c5295,stroke:#563a6b,color:#fff
64
+ style D fill:#2d8659,stroke:#1a5c3a,color:#fff
65
+ style F fill:#2d8659,stroke:#1a5c3a,color:#fff
66
+ style G fill:#64748b,stroke:#475569,color:#fff
67
+ style H fill:#2d8659,stroke:#1a5c3a,color:#fff
68
+ style E fill:#b8762f,stroke:#8a5722,color:#fff
69
+ ```
31
70
 
32
- The package uses MemberJunction's CompanyIntegration entity to store credentials:
33
- - Each Company can have multiple LMS integrations
34
- - API keys, OAuth tokens stored securely
35
- - Environment variable support with database fallback
71
+ ## Installation
36
72
 
37
- ## Available Actions
73
+ ```bash
74
+ npm install @memberjunction/actions-bizapps-lms
75
+ ```
38
76
 
39
- ### LearnWorlds
40
-
41
- #### User Management
42
-
43
- ##### GetLearnWorldsUsersAction
44
- Retrieves users (students, instructors, admins) from LearnWorlds with comprehensive filtering.
45
-
46
- **Parameters:**
47
- - `CompanyID` (required): MemberJunction Company ID
48
- - `SearchText`: Search by name, email, or username
49
- - `Role`: Filter by user role (student, instructor, admin)
50
- - `Status`: Filter by status (active, inactive, suspended)
51
- - `Tags`: Filter by user tags (comma-separated)
52
- - `CreatedAfter/CreatedBefore`: Date range filters
53
- - `SortBy`: Sort field (created, name, email, last_login)
54
- - `SortOrder`: asc or desc
55
- - `IncludeCourseStats`: Include enrollment statistics
56
- - `MaxResults`: Limit results (default: 100)
57
-
58
- **Output:**
59
- - `Users`: Array of user objects with profile and statistics
60
- - `TotalCount`: Total number of users found
61
- - `Summary`: Statistical summary including role distribution
62
-
63
- ##### GetLearnWorldsUserDetailsAction
64
- Retrieves comprehensive details about a specific user including enrollments and achievements.
65
-
66
- **Parameters:**
67
- - `CompanyID` (required): MemberJunction Company ID
68
- - `UserID` (required): LearnWorlds user ID
69
- - `IncludeEnrollments`: Include course enrollments (default: true)
70
- - `IncludeStats`: Include additional statistics (default: true)
71
-
72
- **Output:**
73
- - `UserDetails`: Complete user profile with learning data
74
- - `Summary`: User engagement and achievement summary
75
-
76
- ##### GetLearnWorldsUserProgressAction
77
- Retrieves detailed learning progress for a user across all courses or specific course.
78
-
79
- **Parameters:**
80
- - `CompanyID` (required): MemberJunction Company ID
81
- - `UserID` (required): LearnWorlds user ID
82
- - `CourseID`: Optional specific course ID
83
- - `IncludeUnitDetails`: Include module/unit breakdown
84
- - `IncludeLessonDetails`: Include individual lesson progress
85
-
86
- **Output:**
87
- - `UserProgress`: Comprehensive progress data
88
- - `Summary`: Progress overview with key metrics
89
-
90
- #### Course Management
91
-
92
- ##### GetLearnWorldsCoursesAction
93
- Retrieves the course catalog with advanced filtering and search capabilities.
94
-
95
- **Parameters:**
96
- - `CompanyID` (required): MemberJunction Company ID
97
- - `SearchText`: Search in title and description
98
- - `Status`: Filter by status (published, draft, coming_soon)
99
- - `CategoryID`: Filter by category
100
- - `Level`: Filter by difficulty (beginner, intermediate, advanced)
101
- - `Language`: Filter by course language
102
- - `OnlyFree`: Show only free courses
103
- - `MinPrice/MaxPrice`: Price range filter
104
- - `Tags`: Filter by course tags
105
- - `InstructorID`: Filter by instructor
106
- - `CreatedAfter/CreatedBefore`: Date range filters
107
- - `SortBy`: Sort field (created, title, price, enrollments)
108
- - `SortOrder`: asc or desc
109
- - `IncludeEnrollmentStats`: Include enrollment data
110
- - `MaxResults`: Limit results (default: 100)
111
-
112
- **Output:**
113
- - `Courses`: Array of course objects with details
114
- - `TotalCount`: Total number of courses found
115
- - `Summary`: Catalog statistics including pricing and enrollment data
77
+ This package is part of the MemberJunction monorepo. When working within the monorepo, add the dependency to your package's `package.json` and run `npm install` at the repository root.
116
78
 
117
79
  ## Setup
118
80
 
@@ -120,7 +82,7 @@ Retrieves the course catalog with advanced filtering and search capabilities.
120
82
 
121
83
  ```sql
122
84
  INSERT INTO Integration (Name, Description, NavigationBaseURL, ClassName)
123
- VALUES ('LearnWorlds', 'LearnWorlds LMS Integration',
85
+ VALUES ('LearnWorlds', 'LearnWorlds LMS Integration',
124
86
  'https://api.learnworlds.com', 'LearnWorldsIntegration');
125
87
  ```
126
88
 
@@ -135,23 +97,353 @@ VALUES (@CompanyID, @LearnWorldsIntegrationID, @SchoolDomain, 1);
135
97
  ### 3. Set Environment Variables
136
98
 
137
99
  ```bash
138
- # LearnWorlds API credentials
139
- BIZAPPS_LEARNWORLDS_[COMPANY_ID]_API_KEY=your_api_key
140
- BIZAPPS_LEARNWORLDS_[COMPANY_ID]_SCHOOL_DOMAIN=myschool.learnworlds.com
141
-
142
- # Example for company ID "12345"
100
+ # Format: BIZAPPS_LEARNWORLDS_{COMPANY_ID}_{CREDENTIAL_TYPE}
143
101
  BIZAPPS_LEARNWORLDS_12345_API_KEY=lw_api_xxxxxxxxxxxxx
144
102
  BIZAPPS_LEARNWORLDS_12345_SCHOOL_DOMAIN=myschool.learnworlds.com
145
103
  ```
146
104
 
105
+ ## Available Actions
106
+
107
+ ### User Management
108
+
109
+ | Action | Class | Description |
110
+ |--------|-------|-------------|
111
+ | Get Users | `GetLearnWorldsUsersAction` | List and search users with role, status, tag, and date filters |
112
+ | Get User Details | `GetLearnWorldsUserDetailsAction` | Comprehensive user profile with enrollments, achievements, and engagement metrics |
113
+ | Get User Progress | `GetLearnWorldsUserProgressAction` | Detailed learning progress across all courses or a specific course, with optional unit/lesson breakdown |
114
+ | Create User | `CreateUserAction` | Create a new user with optional course enrollments and welcome email |
115
+
116
+ ### Course Management
117
+
118
+ | Action | Class | Description |
119
+ |--------|-------|-------------|
120
+ | Get Courses | `GetLearnWorldsCoursesAction` | Search and filter the course catalog by status, category, level, language, price range, and tags |
121
+ | Get Course Details | `GetLearnWorldsCourseDetailsAction` | Full course information including curriculum modules, instructors, and enrollment statistics |
122
+ | Get Course Analytics | `GetCourseAnalyticsAction` | Performance analytics with enrollment trends, engagement metrics, completion rates, and revenue data |
123
+
124
+ ### Enrollment Management
125
+
126
+ | Action | Class | Description |
127
+ |--------|-------|-------------|
128
+ | Enroll User | `EnrollUserAction` | Enroll a user in a course with optional pricing, start/expiry dates, and notifications |
129
+ | Get User Enrollments | `GetUserEnrollmentsAction` | List all enrollments for a user with progress, course details, and summary statistics |
130
+ | Update User Progress | `UpdateUserProgressAction` | Update progress at the course or individual lesson level with score and time tracking |
131
+
132
+ ### Assessment and Certificates
133
+
134
+ | Action | Class | Description |
135
+ |--------|-------|-------------|
136
+ | Get Quiz Results | `GetQuizResultsAction` | Retrieve quiz/assessment results with question-level details, answers, and accuracy metrics |
137
+ | Get Certificates | `GetCertificatesAction` | Fetch earned certificates with download links, verification codes, and expiration status |
138
+
139
+ ## API Reference
140
+
141
+ ### Base Classes
142
+
143
+ #### `BaseLMSAction`
144
+
145
+ Abstract base class for all LMS actions. Provides:
146
+
147
+ - **`getCompanyIntegration(companyId, contextUser)`** - Resolves the `CompanyIntegrationEntity` for the given company, with internal caching
148
+ - **`getCredentialFromEnv(companyId, credentialType)`** - Reads credentials from environment variables using the `BIZAPPS_{PROVIDER}_{COMPANY_ID}_{TYPE}` pattern
149
+ - **`getAPICredentials(integration)`** - Two-step credential resolution (environment variables first, then database)
150
+ - **`calculateProgressPercentage(completed, total)`** - Computes progress as a rounded percentage
151
+ - **`formatDuration(seconds)`** - Converts seconds to human-readable format (e.g., `2h 15m 30s`)
152
+ - **`mapEnrollmentStatus(status)`** - Normalizes provider-specific statuses to standard values: `active`, `completed`, `expired`, `suspended`, `unknown`
153
+
154
+ #### `LearnWorldsBaseAction`
155
+
156
+ LearnWorlds-specific base class extending `BaseLMSAction`. Provides:
157
+
158
+ - **`makeLearnWorldsRequest<T>(endpoint, method, body, contextUser)`** - Authenticated HTTP request to the LearnWorlds v2 API with Bearer token, error parsing, and JSON handling
159
+ - **`makeLearnWorldsPaginatedRequest<T>(endpoint, params, contextUser)`** - Auto-paginating wrapper that collects all pages of results, respecting `MaxResults` limits
160
+ - **`parseLearnWorldsDate(dateString)`** - Handles both ISO strings and Unix epoch timestamps (seconds)
161
+ - **`mapUserStatus(status)`** - Maps LearnWorlds statuses to `active | inactive | suspended`
162
+ - **`mapLearnWorldsEnrollmentStatus(enrollment)`** - Determines enrollment status from boolean flags (`completed`, `expired`, `suspended`, `active`)
163
+ - **`calculateProgress(progressData)`** - Extracts percentage, completed/total units, and time spent from LearnWorlds progress objects
164
+
165
+ ### Action Parameters
166
+
167
+ Every action requires the `CompanyID` input parameter (inherited from `BaseLMSAction`). Additional parameters are action-specific, documented in the sections below.
168
+
169
+ #### GetLearnWorldsUsersAction
170
+
171
+ **Input Parameters:**
172
+
173
+ | Parameter | Type | Default | Description |
174
+ |-----------|------|---------|-------------|
175
+ | `CompanyID` | string | required | MemberJunction Company ID |
176
+ | `SearchText` | string | null | Search by name, email, or username |
177
+ | `Role` | string | null | Filter by role (student, instructor, admin) |
178
+ | `Status` | string | null | Filter by status (active, inactive, suspended) |
179
+ | `Tags` | string | null | Comma-separated tag filter |
180
+ | `CreatedAfter` | string | null | ISO date lower bound |
181
+ | `CreatedBefore` | string | null | ISO date upper bound |
182
+ | `SortBy` | string | `created` | Sort field (created, name, email, last_login) |
183
+ | `SortOrder` | string | `desc` | Sort direction (asc, desc) |
184
+ | `IncludeCourseStats` | boolean | `true` | Include enrollment statistics per user |
185
+ | `MaxResults` | number | `100` | Maximum number of users to return |
186
+
187
+ **Output Parameters:**
188
+
189
+ | Parameter | Type | Description |
190
+ |-----------|------|-------------|
191
+ | `Users` | `LearnWorldsUser[]` | Array of user objects with profile and course statistics |
192
+ | `TotalCount` | number | Total number of users returned |
193
+ | `Summary` | object | Aggregate statistics including role distribution, most active users, and recent signups |
194
+
195
+ #### GetLearnWorldsUserDetailsAction
196
+
197
+ **Input Parameters:**
198
+
199
+ | Parameter | Type | Default | Description |
200
+ |-----------|------|---------|-------------|
201
+ | `CompanyID` | string | required | MemberJunction Company ID |
202
+ | `UserID` | string | required | LearnWorlds user ID |
203
+ | `IncludeEnrollments` | boolean | `true` | Include course enrollment details |
204
+ | `IncludeStats` | boolean | `true` | Include additional learning statistics |
205
+
206
+ **Output Parameters:**
207
+
208
+ | Parameter | Type | Description |
209
+ |-----------|------|-------------|
210
+ | `UserDetails` | `LearnWorldsUserDetails` | Complete user profile with learning data, achievements, and account settings |
211
+ | `Summary` | object | Engagement overview with learning progress, achievement counts, and recent activity |
212
+
213
+ #### GetLearnWorldsUserProgressAction
214
+
215
+ **Input Parameters:**
216
+
217
+ | Parameter | Type | Default | Description |
218
+ |-----------|------|---------|-------------|
219
+ | `CompanyID` | string | required | MemberJunction Company ID |
220
+ | `UserID` | string | required | LearnWorlds user ID |
221
+ | `CourseID` | string | null | Optional specific course ID (omit for all courses) |
222
+ | `IncludeUnitDetails` | boolean | `false` | Include module/unit level breakdown |
223
+ | `IncludeLessonDetails` | boolean | `false` | Include individual lesson progress |
224
+
225
+ **Output Parameters:**
226
+
227
+ | Parameter | Type | Description |
228
+ |-----------|------|-------------|
229
+ | `UserProgress` | `UserLearningProgress` | Comprehensive progress data across all courses or a specific course |
230
+ | `Summary` | object | Overview with completion rate, current focus courses, and achievement data |
231
+
232
+ #### GetLearnWorldsCoursesAction
233
+
234
+ **Input Parameters:**
235
+
236
+ | Parameter | Type | Default | Description |
237
+ |-----------|------|---------|-------------|
238
+ | `CompanyID` | string | required | MemberJunction Company ID |
239
+ | `SearchText` | string | null | Search in title and description |
240
+ | `Status` | string | null | Filter by status (published, draft, coming_soon) |
241
+ | `CategoryID` | string | null | Filter by category ID |
242
+ | `Level` | string | null | Filter by difficulty (beginner, intermediate, advanced) |
243
+ | `Language` | string | null | Filter by course language |
244
+ | `OnlyFree` | boolean | `false` | Show only free courses |
245
+ | `MinPrice` | number | null | Minimum price filter |
246
+ | `MaxPrice` | number | null | Maximum price filter |
247
+ | `Tags` | string | null | Comma-separated tag filter |
248
+ | `InstructorID` | string | null | Filter by instructor |
249
+ | `CreatedAfter` | string | null | ISO date lower bound |
250
+ | `CreatedBefore` | string | null | ISO date upper bound |
251
+ | `SortBy` | string | `created` | Sort field (created, title, price, enrollments) |
252
+ | `SortOrder` | string | `desc` | Sort direction |
253
+ | `IncludeEnrollmentStats` | boolean | `true` | Include enrollment data |
254
+ | `MaxResults` | number | `100` | Maximum results to return |
255
+
256
+ **Output Parameters:**
257
+
258
+ | Parameter | Type | Description |
259
+ |-----------|------|-------------|
260
+ | `Courses` | `LearnWorldsCourse[]` | Array of course objects with full details |
261
+ | `TotalCount` | number | Total courses returned |
262
+ | `Summary` | `CourseCatalogSummary` | Catalog statistics with category/level/language counts, enrollment stats, and pricing |
263
+
264
+ #### GetLearnWorldsCourseDetailsAction
265
+
266
+ **Input Parameters:**
267
+
268
+ | Parameter | Type | Default | Description |
269
+ |-----------|------|---------|-------------|
270
+ | `CompanyID` | string | required | MemberJunction Company ID |
271
+ | `CourseID` | string | required | LearnWorlds course ID |
272
+ | `IncludeModules` | boolean | `true` | Include curriculum structure |
273
+ | `IncludeInstructors` | boolean | `true` | Include instructor profiles |
274
+ | `IncludeStats` | boolean | `true` | Include enrollment and completion statistics |
275
+
276
+ **Output Parameters:**
277
+
278
+ | Parameter | Type | Description |
279
+ |-----------|------|-------------|
280
+ | `CourseDetails` | object | Full course information including curriculum modules, instructor profiles, and stats |
281
+ | `Summary` | object | Key metrics overview |
282
+
283
+ #### EnrollUserAction
284
+
285
+ **Input Parameters:**
286
+
287
+ | Parameter | Type | Default | Description |
288
+ |-----------|------|---------|-------------|
289
+ | `CompanyID` | string | required | MemberJunction Company ID |
290
+ | `UserID` | string | required | LearnWorlds user ID |
291
+ | `CourseID` | string | required | Course to enroll in |
292
+ | `Price` | number | `0` | Enrollment price |
293
+ | `Justification` | string | `API Enrollment` | Reason for enrollment |
294
+ | `NotifyUser` | boolean | `true` | Send enrollment notification email |
295
+ | `StartDate` | string | null | Optional enrollment start date (ISO format) |
296
+ | `ExpiryDate` | string | null | Optional enrollment expiry date (ISO format) |
297
+
298
+ **Output Parameters:**
299
+
300
+ | Parameter | Type | Description |
301
+ |-----------|------|-------------|
302
+ | `EnrollmentDetails` | object | Enrollment record with progress tracking and certificate eligibility |
303
+ | `Summary` | object | Enrollment summary with user and course names |
304
+
305
+ #### GetUserEnrollmentsAction
306
+
307
+ **Input Parameters:**
308
+
309
+ | Parameter | Type | Default | Description |
310
+ |-----------|------|---------|-------------|
311
+ | `CompanyID` | string | required | MemberJunction Company ID |
312
+ | `UserID` | string | required | LearnWorlds user ID |
313
+ | `Status` | string | null | Filter by enrollment status |
314
+ | `IncludeExpired` | boolean | `false` | Include expired enrollments |
315
+ | `IncludeCourseDetails` | boolean | `true` | Include course metadata for each enrollment |
316
+ | `SortBy` | string | `enrolled_at` | Sort field |
317
+ | `SortOrder` | string | `desc` | Sort direction |
318
+ | `MaxResults` | number | `100` | Maximum results |
319
+
320
+ **Output Parameters:**
321
+
322
+ | Parameter | Type | Description |
323
+ |-----------|------|-------------|
324
+ | `Enrollments` | array | Enrollment records with progress, grade, and certificate data |
325
+ | `TotalCount` | number | Total enrollments found |
326
+ | `Summary` | object | Aggregate statistics by status, average progress, and total time spent |
327
+
328
+ #### UpdateUserProgressAction
329
+
330
+ **Input Parameters:**
331
+
332
+ | Parameter | Type | Default | Description |
333
+ |-----------|------|---------|-------------|
334
+ | `CompanyID` | string | required | MemberJunction Company ID |
335
+ | `UserID` | string | required | LearnWorlds user ID |
336
+ | `CourseID` | string | required | Course ID |
337
+ | `LessonID` | string | null | Optional lesson ID for lesson-level updates |
338
+ | `ProgressPercentage` | number | null | New progress percentage |
339
+ | `Completed` | boolean | null | Mark as completed |
340
+ | `TimeSpent` | number | null | Additional time spent (seconds) |
341
+ | `Score` | number | null | Score for quiz/assignment |
342
+ | `Notes` | string | null | Progress notes |
343
+
344
+ **Output Parameters:**
345
+
346
+ | Parameter | Type | Description |
347
+ |-----------|------|-------------|
348
+ | `ProgressDetails` | object | Previous and updated progress state with diff |
349
+ | `Summary` | object | Change summary including whether progress increased |
350
+
351
+ #### GetCourseAnalyticsAction
352
+
353
+ **Input Parameters:**
354
+
355
+ | Parameter | Type | Default | Description |
356
+ |-----------|------|---------|-------------|
357
+ | `CompanyID` | string | required | MemberJunction Company ID |
358
+ | `CourseID` | string | required | Course ID |
359
+ | `DateFrom` | string | null | Analytics period start date |
360
+ | `DateTo` | string | null | Analytics period end date |
361
+ | `IncludeUserBreakdown` | boolean | `false` | Include per-user progress distribution |
362
+ | `IncludeModuleStats` | boolean | `true` | Include module/lesson-level statistics |
363
+ | `IncludeRevenue` | boolean | `true` | Include revenue analytics |
364
+
365
+ **Output Parameters:**
366
+
367
+ | Parameter | Type | Description |
368
+ |-----------|------|-------------|
369
+ | `CourseAnalytics` | object | Comprehensive analytics: enrollment trends, progress distribution, engagement metrics, quiz performance, and revenue |
370
+ | `Summary` | object | Key metrics and growth/engagement trends |
371
+
372
+ #### GetCertificatesAction
373
+
374
+ **Input Parameters:**
375
+
376
+ | Parameter | Type | Default | Description |
377
+ |-----------|------|---------|-------------|
378
+ | `CompanyID` | string | required | MemberJunction Company ID |
379
+ | `UserID` | string | null | Filter by user (either UserID or CourseID required) |
380
+ | `CourseID` | string | null | Filter by course (either UserID or CourseID required) |
381
+ | `DateFrom` | string | null | Issued after date |
382
+ | `DateTo` | string | null | Issued before date |
383
+ | `IncludeDownloadLinks` | boolean | `true` | Include PDF and image download URLs |
384
+ | `SortBy` | string | `issued_at` | Sort field |
385
+ | `SortOrder` | string | `desc` | Sort direction |
386
+ | `MaxResults` | number | `100` | Maximum results |
387
+
388
+ **Output Parameters:**
389
+
390
+ | Parameter | Type | Description |
391
+ |-----------|------|-------------|
392
+ | `Certificates` | array | Certificate records with user/course info, download links, and verification data |
393
+ | `TotalCount` | number | Total certificates found |
394
+ | `Summary` | object | Active/expired counts with optional grouping by course or user |
395
+
396
+ #### GetQuizResultsAction
397
+
398
+ **Input Parameters:**
399
+
400
+ | Parameter | Type | Default | Description |
401
+ |-----------|------|---------|-------------|
402
+ | `CompanyID` | string | required | MemberJunction Company ID |
403
+ | `UserID` | string | null | Filter by user (at least one of UserID/CourseID/QuizID required) |
404
+ | `CourseID` | string | null | Filter by course |
405
+ | `QuizID` | string | null | Filter by specific quiz |
406
+ | `IncludeQuestions` | boolean | `true` | Include question text and metadata |
407
+ | `IncludeAnswers` | boolean | `true` | Include user answers with correct/incorrect analysis |
408
+ | `PassingOnly` | boolean | `false` | Return only passing attempts |
409
+ | `DateFrom` | string | null | Completed after date |
410
+ | `DateTo` | string | null | Completed before date |
411
+ | `SortBy` | string | `completed_at` | Sort field |
412
+ | `SortOrder` | string | `desc` | Sort direction |
413
+ | `MaxResults` | number | `100` | Maximum results |
414
+
415
+ **Output Parameters:**
416
+
417
+ | Parameter | Type | Description |
418
+ |-----------|------|-------------|
419
+ | `QuizResults` | array | Quiz attempts with scores, answers, accuracy metrics, and per-question breakdown |
420
+ | `TotalCount` | number | Total results found |
421
+ | `Summary` | object | Pass rate, average score, average duration, and per-quiz breakdown |
422
+
423
+ ## Exported Interfaces
424
+
425
+ The package exports several TypeScript interfaces for strong typing:
426
+
427
+ - **`LearnWorldsUser`** - User profile with status, role, tags, custom fields, and course statistics
428
+ - **`LearnWorldsUserDetails`** - Extended user profile with enrollment details, achievements, and account settings
429
+ - **`UserEnrollment`** - Individual course enrollment with progress, grade, and certificate data
430
+ - **`CourseProgress`** - Detailed progress for a single course including unit-level breakdown
431
+ - **`UnitProgress`** - Progress within a course module/section
432
+ - **`LessonProgress`** - Individual lesson progress with type-specific fields (video watch time, quiz scores, assignment grades)
433
+ - **`UserLearningProgress`** - Aggregated learning progress across all courses with analytics
434
+ - **`LearnWorldsCourse`** - Full course metadata including pricing, structure, enrollment data, and learning outcomes
435
+ - **`CourseCatalogSummary`** - Catalog-level statistics with category, level, language, enrollment, and price breakdowns
436
+
147
437
  ## Usage Examples
148
438
 
149
- ### Get All Active Students
439
+ ### Get Active Students with Course Statistics
440
+
150
441
  ```typescript
151
- import { GetLearnWorldsUsersAction } from '@memberjunction/actions-bizapps-lms';
442
+ import { ActionEngineServer } from '@memberjunction/actions';
152
443
 
153
- const action = new GetLearnWorldsUsersAction();
154
- const result = await action.RunAction({
444
+ const engine = ActionEngineServer.Instance;
445
+ const result = await engine.RunAction({
446
+ ActionName: 'GetLearnWorldsUsersAction',
155
447
  Params: [
156
448
  { Name: 'CompanyID', Value: 'company-123' },
157
449
  { Name: 'Role', Value: 'student' },
@@ -171,33 +463,38 @@ if (result.Success) {
171
463
  }
172
464
  ```
173
465
 
174
- ### Get User Learning Progress
175
- ```typescript
176
- import { GetLearnWorldsUserProgressAction } from '@memberjunction/actions-bizapps-lms';
466
+ ### Track User Learning Progress
177
467
 
178
- const action = new GetLearnWorldsUserProgressAction();
179
- const result = await action.RunAction({
468
+ ```typescript
469
+ const result = await engine.RunAction({
470
+ ActionName: 'GetLearnWorldsUserProgressAction',
180
471
  Params: [
181
472
  { Name: 'CompanyID', Value: 'company-123' },
182
473
  { Name: 'UserID', Value: 'user-456' },
183
- { Name: 'IncludeUnitDetails', Value: true }
474
+ { Name: 'IncludeUnitDetails', Value: true },
475
+ { Name: 'IncludeLessonDetails', Value: true }
184
476
  ],
185
477
  ContextUser: currentUser
186
478
  });
187
479
 
188
480
  if (result.Success) {
189
481
  const progress = result.Params.find(p => p.Name === 'UserProgress')?.Value;
190
- console.log(`User has completed ${progress.coursesCompleted} of ${progress.totalCourses} courses`);
482
+ console.log(`Completed ${progress.coursesCompleted} of ${progress.totalCourses} courses`);
191
483
  console.log(`Overall progress: ${progress.overallProgressPercentage}%`);
484
+
485
+ for (const course of progress.courses) {
486
+ if (course.status === 'in_progress') {
487
+ console.log(` ${course.courseTitle}: ${course.progressPercentage}%`);
488
+ }
489
+ }
192
490
  }
193
491
  ```
194
492
 
195
493
  ### Search Course Catalog
196
- ```typescript
197
- import { GetLearnWorldsCoursesAction } from '@memberjunction/actions-bizapps-lms';
198
494
 
199
- const action = new GetLearnWorldsCoursesAction();
200
- const result = await action.RunAction({
495
+ ```typescript
496
+ const result = await engine.RunAction({
497
+ ActionName: 'GetLearnWorldsCoursesAction',
201
498
  Params: [
202
499
  { Name: 'CompanyID', Value: 'company-123' },
203
500
  { Name: 'SearchText', Value: 'JavaScript' },
@@ -210,112 +507,89 @@ const result = await action.RunAction({
210
507
 
211
508
  if (result.Success) {
212
509
  const courses = result.Params.find(p => p.Name === 'Courses')?.Value;
213
- courses.forEach(course => {
510
+ for (const course of courses) {
214
511
  console.log(`${course.title} - $${course.price} (${course.totalEnrollments} students)`);
215
- });
512
+ }
216
513
  }
217
514
  ```
218
515
 
219
- ## Common Data Models
516
+ ### Create User and Enroll in Courses
220
517
 
221
- ### LMS User
222
518
  ```typescript
223
- interface LMSUser {
224
- id: string;
225
- email: string;
226
- username: string;
227
- firstName?: string;
228
- lastName?: string;
229
- status: 'active' | 'inactive' | 'suspended';
230
- role: string;
231
- createdAt: Date;
232
- lastLoginAt?: Date;
233
- totalCourses?: number;
234
- completedCourses?: number;
235
- totalTimeSpent?: number;
236
- }
237
- ```
519
+ const result = await engine.RunAction({
520
+ ActionName: 'CreateUserAction',
521
+ Params: [
522
+ { Name: 'CompanyID', Value: 'company-123' },
523
+ { Name: 'Email', Value: 'new.student@example.com' },
524
+ { Name: 'FirstName', Value: 'Jane' },
525
+ { Name: 'LastName', Value: 'Smith' },
526
+ { Name: 'Role', Value: 'student' },
527
+ { Name: 'SendWelcomeEmail', Value: true },
528
+ { Name: 'EnrollInCourses', Value: ['course-101', 'course-202'] }
529
+ ],
530
+ ContextUser: currentUser
531
+ });
238
532
 
239
- ### Course Progress
240
- ```typescript
241
- interface CourseProgress {
242
- courseId: string;
243
- courseTitle: string;
244
- enrolledAt: Date;
245
- progressPercentage: number;
246
- completedUnits: number;
247
- totalUnits: number;
248
- totalTimeSpent: number;
249
- status: 'not_started' | 'in_progress' | 'completed' | 'expired';
250
- certificateEarned: boolean;
533
+ if (result.Success) {
534
+ const summary = result.Params.find(p => p.Name === 'Summary')?.Value;
535
+ console.log(`Created user: ${summary.email}`);
536
+ console.log(`Enrolled in ${summary.coursesEnrolled} of ${summary.totalCoursesRequested} courses`);
251
537
  }
252
538
  ```
253
539
 
254
- ### Course
255
- ```typescript
256
- interface LMSCourse {
257
- id: string;
258
- title: string;
259
- description?: string;
260
- status: 'published' | 'draft' | 'coming_soon';
261
- price?: number;
262
- currency?: string;
263
- level?: 'beginner' | 'intermediate' | 'advanced' | 'all';
264
- duration?: number;
265
- totalEnrollments: number;
266
- averageRating?: number;
267
- instructorName?: string;
268
- }
269
- ```
540
+ ## Adding New Providers
541
+
542
+ The package is designed for extensibility. To add support for a new LMS provider:
543
+
544
+ 1. Create a provider directory: `src/providers/{provider-name}/`
545
+ 2. Create a provider base class extending `BaseLMSAction` with provider-specific authentication and API communication
546
+ 3. Implement individual action classes extending the provider base class
547
+ 4. Map provider-specific data formats to the shared interfaces (`LearnWorldsUser`, `CourseProgress`, etc.)
548
+ 5. Export everything from provider and actions index files
549
+ 6. Re-export the new provider from `src/index.ts`
270
550
 
271
- ## Planned Actions
551
+ ```
552
+ src/
553
+ base/
554
+ base-lms.action.ts # Domain base class (shared)
555
+ providers/
556
+ learnworlds/ # Existing provider
557
+ learnworlds-base.action.ts
558
+ actions/
559
+ get-users.action.ts
560
+ ...
561
+ moodle/ # New provider
562
+ moodle-base.action.ts
563
+ actions/
564
+ get-users.action.ts
565
+ ...
566
+ index.ts
567
+ ```
272
568
 
273
- ### Coming Soon
274
- - **GetCourseDetailsAction** - Detailed course information with curriculum
275
- - **EnrollUserAction** - Enroll users in courses
276
- - **GetUserEnrollmentsAction** - Get all enrollments for a user
277
- - **GetCourseAnalyticsAction** - Course performance analytics
278
- - **CreateUserAction** - Create new LMS users
279
- - **UpdateUserProgressAction** - Update user progress manually
280
- - **GetCertificatesAction** - Retrieve earned certificates
281
- - **GetQuizResultsAction** - Get quiz/assessment results
569
+ ## Dependencies
282
570
 
283
- ## Development
571
+ | Package | Purpose |
572
+ |---------|---------|
573
+ | `@memberjunction/core` | `UserInfo`, `Metadata`, `RunView` for entity access |
574
+ | `@memberjunction/global` | `@RegisterClass` decorator for action discovery |
575
+ | `@memberjunction/actions-base` | `ActionParam`, `ActionResultSimple`, `RunActionParams` types |
576
+ | `@memberjunction/actions` | `BaseAction` class that all actions extend |
577
+ | `@memberjunction/core-entities` | `CompanyIntegrationEntity` for credential/integration management |
284
578
 
285
- ### Adding New Providers
579
+ ## Related Packages
286
580
 
287
- 1. Create provider directory: `src/providers/[provider-name]/`
288
- 2. Extend `BaseLMSAction` with provider-specific base class
289
- 3. Implement authentication mechanism
290
- 4. Add pagination support for list endpoints
291
- 5. Map provider data to common LMS models
292
- 6. Implement core actions (users, courses, progress)
293
- 7. Add comprehensive error handling
294
- 8. Write unit tests
295
- 9. Update documentation
581
+ - [@memberjunction/actions](../../Engine) - Actions execution engine
582
+ - [@memberjunction/actions-base](../../Base) - Base classes and type definitions
583
+ - [@memberjunction/actions-bizapps-accounting](../Accounting) - Accounting system integrations (QuickBooks, etc.)
584
+ - [@memberjunction/actions-bizapps-crm](../CRM) - CRM system integrations
296
585
 
297
- ### Testing
586
+ ## Building
298
587
 
299
588
  ```bash
300
- # Run tests
301
- npm test
302
-
303
- # Build package
589
+ # Build this package
590
+ cd packages/Actions/BizApps/LMS
304
591
  npm run build
305
592
 
306
- # Watch mode
593
+ # Watch mode for development
307
594
  npm run watch
308
595
  ```
309
-
310
- ## Best Practices
311
-
312
- 1. **Pagination**: Always implement pagination for list endpoints
313
- 2. **Rate Limiting**: Respect provider API limits
314
- 3. **Data Mapping**: Consistently map to common models
315
- 4. **Error Messages**: Provide clear, actionable error messages
316
- 5. **Progress Tracking**: Calculate progress percentages consistently
317
- 6. **Time Formatting**: Use consistent duration formatting
318
-
319
- ## License
320
-
321
- ISC
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/actions-bizapps-lms",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.1.0",
5
5
  "description": "LMS system integration actions for MemberJunction",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -24,11 +24,11 @@
24
24
  "author": "MemberJunction",
25
25
  "license": "ISC",
26
26
  "dependencies": {
27
- "@memberjunction/core": "4.0.0",
28
- "@memberjunction/global": "4.0.0",
29
- "@memberjunction/actions-base": "4.0.0",
30
- "@memberjunction/actions": "4.0.0",
31
- "@memberjunction/core-entities": "4.0.0"
27
+ "@memberjunction/core": "4.1.0",
28
+ "@memberjunction/global": "4.1.0",
29
+ "@memberjunction/actions-base": "4.1.0",
30
+ "@memberjunction/actions": "4.1.0",
31
+ "@memberjunction/core-entities": "4.1.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "24.10.11",