musora-content-services 2.72.1 → 2.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/services/content-org/learning-paths.ts +26 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.74.0](https://github.com/railroadmedia/musora-content-services/compare/v2.73.0...v2.74.0) (2025-11-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* update fetch learning path lessons ([#551](https://github.com/railroadmedia/musora-content-services/issues/551)) ([a434076](https://github.com/railroadmedia/musora-content-services/commit/a434076a8281af61043c1ec3e09798e7981ff8f3))
|
|
11
|
+
|
|
12
|
+
## [2.73.0](https://github.com/railroadmedia/musora-content-services/compare/v2.72.1...v2.73.0) (2025-11-06)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* returning data updates in fetchLearningPathLessons ([#550](https://github.com/railroadmedia/musora-content-services/issues/550)) ([1753d75](https://github.com/railroadmedia/musora-content-services/commit/1753d754d620fafc387e700f114d67ec7fc9043f))
|
|
18
|
+
|
|
5
19
|
### [2.72.1](https://github.com/railroadmedia/musora-content-services/compare/v2.72.0...v2.72.1) (2025-11-06)
|
|
6
20
|
|
|
7
21
|
|
package/package.json
CHANGED
|
@@ -66,11 +66,12 @@ export async function updateActivePath(brand: string) {
|
|
|
66
66
|
* @returns {string} result.thumbnail - Optional thumbnail URL for the learning path.
|
|
67
67
|
* @returns {string} result.title - The title of the learning path.
|
|
68
68
|
* @returns {boolean} result.is_active_learning_path - Whether the learning path is currently active.
|
|
69
|
-
* @returns {Array} result.
|
|
69
|
+
* @returns {Array} result.children - Array of all lessons.
|
|
70
70
|
* @returns {Array} result.upcoming_lessons - Array of upcoming/additional lessons.
|
|
71
71
|
* @returns {Array} result.todays_lessons - Array of today's lessons (max 3).
|
|
72
72
|
* @returns {Array} result.next_learning_path_lessons - Array of next lessons to be taken.
|
|
73
73
|
* @returns {Array} result.completed_lessons - Array of completed lessons.
|
|
74
|
+
* @returns {Array} result.previous_learning_path_todays - Array of completed lessons.
|
|
74
75
|
*/
|
|
75
76
|
export async function fetchLearningPathLessons(
|
|
76
77
|
learningPathId: number,
|
|
@@ -86,21 +87,30 @@ export async function fetchLearningPathLessons(
|
|
|
86
87
|
addProgressStatus: true,
|
|
87
88
|
addProgressPercentage: true,
|
|
88
89
|
}
|
|
90
|
+
|
|
89
91
|
const lessons = await addContextToContent(() => learningPath.children, addContextParameters)
|
|
90
92
|
const isActiveLearningPath = (dailySession?.active_learning_path_id || 0) == learningPathId
|
|
93
|
+
const manipulatedLessons = lessons.map((lesson: any) => {
|
|
94
|
+
return { ...lesson, type: 'learning-path-lesson-v2', parent_id: learningPathId }
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
if (!isActiveLearningPath) {
|
|
98
|
+
return {
|
|
99
|
+
...learningPath,
|
|
100
|
+
is_active_learning_path: isActiveLearningPath,
|
|
101
|
+
children: manipulatedLessons,
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
const todayContentIds = dailySession.daily_session[0]?.content_ids || []
|
|
92
106
|
const nextContentIds = dailySession.daily_session[1]?.content_ids || []
|
|
93
107
|
const completedLessons = []
|
|
94
108
|
let todaysLessons = []
|
|
95
|
-
let nextLPLessons = []
|
|
96
109
|
const upcomingLessons = []
|
|
97
|
-
const lessonIds = lessons.map((lesson: any) => lesson.id).filter(Boolean)
|
|
98
110
|
|
|
99
|
-
|
|
111
|
+
manipulatedLessons.forEach((lesson: any) => {
|
|
100
112
|
if (todayContentIds.includes(lesson.id)) {
|
|
101
113
|
todaysLessons.push(lesson)
|
|
102
|
-
} else if (nextContentIds.includes(lesson.id)) {
|
|
103
|
-
nextLPLessons.push(lesson)
|
|
104
114
|
} else if (lesson.progressStatus === 'completed') {
|
|
105
115
|
completedLessons.push(lesson)
|
|
106
116
|
} else {
|
|
@@ -108,15 +118,20 @@ export async function fetchLearningPathLessons(
|
|
|
108
118
|
}
|
|
109
119
|
})
|
|
110
120
|
|
|
121
|
+
let previousLearnigPathTodays = []
|
|
111
122
|
if (todaysLessons.length == 0 && nextLPLessons.length > 0) {
|
|
112
123
|
// Daily sessions first lessons are not part of the active learning path, but next lessons are
|
|
113
124
|
// load todays lessons from previous learning path
|
|
114
|
-
|
|
125
|
+
previousLearnigPathTodays = await addContextToContent(
|
|
115
126
|
fetchByRailContentIds,
|
|
116
127
|
todayContentIds,
|
|
117
128
|
addContextParameters
|
|
118
129
|
)
|
|
119
|
-
} else if (
|
|
130
|
+
} else if (
|
|
131
|
+
nextContentIds.length > 0 &&
|
|
132
|
+
todaysLessons.length < 3 &&
|
|
133
|
+
upcomingLessons.length === 0
|
|
134
|
+
) {
|
|
120
135
|
// Daily sessions first lessons are the active learning path and the next lessons are not
|
|
121
136
|
// load next lessons from next learning path
|
|
122
137
|
nextLPLessons = await addContextToContent(
|
|
@@ -127,14 +142,13 @@ export async function fetchLearningPathLessons(
|
|
|
127
142
|
}
|
|
128
143
|
|
|
129
144
|
return {
|
|
130
|
-
|
|
131
|
-
thumbnail: learningPath.thumbnail,
|
|
132
|
-
title: learningPath.title || '',
|
|
145
|
+
...learningPath,
|
|
133
146
|
is_active_learning_path: isActiveLearningPath,
|
|
134
|
-
|
|
147
|
+
children: manipulatedLessons,
|
|
135
148
|
upcoming_lessons: upcomingLessons,
|
|
136
149
|
todays_lessons: todaysLessons,
|
|
137
150
|
next_learning_path_lessons: nextLPLessons,
|
|
138
151
|
completed_lessons: completedLessons,
|
|
152
|
+
previous_learning_path_todays: previousLearnigPathTodays,
|
|
139
153
|
}
|
|
140
154
|
}
|