Merge branch 'dev' into refactor/common
This commit is contained in:
commit
a4408b5bc0
145 changed files with 3437 additions and 2822 deletions
|
@ -24,14 +24,14 @@ async function getLearningObjectsForNodes(nodes: LearningPathNode[]): Promise<Ma
|
|||
// Its corresponding learning object.
|
||||
const nullableNodesToLearningObjects = new Map<LearningPathNode, FilteredLearningObject | null>(
|
||||
await Promise.all(
|
||||
nodes.map((node) =>
|
||||
nodes.map(async (node) =>
|
||||
learningObjectService
|
||||
.getLearningObjectById({
|
||||
hruid: node.learningObjectHruid,
|
||||
version: node.version,
|
||||
language: node.language,
|
||||
})
|
||||
.then((learningObject) => <[LearningPathNode, FilteredLearningObject | null]>[node, learningObject])
|
||||
.then((learningObject) => [node, learningObject] as [LearningPathNode, FilteredLearningObject | null])
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -123,7 +123,7 @@ async function convertNodes(
|
|||
nodesToLearningObjects: Map<LearningPathNode, FilteredLearningObject>,
|
||||
personalizedFor?: PersonalizationTarget
|
||||
): Promise<LearningObjectNode[]> {
|
||||
const nodesPromise = Array.from(nodesToLearningObjects.entries()).map((entry) =>
|
||||
const nodesPromise = Array.from(nodesToLearningObjects.entries()).map(async (entry) =>
|
||||
convertNode(entry[0], entry[1], personalizedFor, nodesToLearningObjects)
|
||||
);
|
||||
return await Promise.all(nodesPromise);
|
||||
|
@ -158,7 +158,7 @@ function convertTransition(
|
|||
throw new Error(`Learning object ${transition.next.learningObjectHruid}/${transition.next.language}/${transition.next.version} not found!`);
|
||||
} else {
|
||||
return {
|
||||
_id: '' + index, // Retained for backwards compatibility. The index uniquely identifies the transition within the learning path.
|
||||
_id: String(index), // Retained for backwards compatibility. The index uniquely identifies the transition within the learning path.
|
||||
default: false, // We don't work with default transitions but retain this for backwards compatibility.
|
||||
next: {
|
||||
_id: nextNode._id + index, // Construct a unique ID for the transition for backwards compatibility.
|
||||
|
@ -185,11 +185,11 @@ const databaseLearningPathProvider: LearningPathProvider = {
|
|||
): Promise<LearningPathResponse> {
|
||||
const learningPathRepo = getLearningPathRepository();
|
||||
|
||||
const learningPaths = (await Promise.all(hruids.map((hruid) => learningPathRepo.findByHruidAndLanguage(hruid, language)))).filter(
|
||||
const learningPaths = (await Promise.all(hruids.map(async (hruid) => learningPathRepo.findByHruidAndLanguage(hruid, language)))).filter(
|
||||
(learningPath) => learningPath !== null
|
||||
);
|
||||
const filteredLearningPaths = await Promise.all(
|
||||
learningPaths.map((learningPath, index) => convertLearningPath(learningPath, index, personalizedFor))
|
||||
learningPaths.map(async (learningPath, index) => convertLearningPath(learningPath, index, personalizedFor))
|
||||
);
|
||||
|
||||
return {
|
||||
|
@ -206,7 +206,7 @@ const databaseLearningPathProvider: LearningPathProvider = {
|
|||
const learningPathRepo = getLearningPathRepository();
|
||||
|
||||
const searchResults = await learningPathRepo.findByQueryStringAndLanguage(query, language);
|
||||
return await Promise.all(searchResults.map((result, index) => convertLearningPath(result, index, personalizedFor)));
|
||||
return await Promise.all(searchResults.map(async (result, index) => convertLearningPath(result, index, personalizedFor)));
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import dwengoApiLearningPathProvider from './dwengo-api-learning-path-provider.js';
|
||||
import databaseLearningPathProvider from './database-learning-path-provider.js';
|
||||
import { EnvVars, getEnvVar } from '../../util/envvars.js';
|
||||
import { envVars, getEnvVar } from '../../util/envVars.js';
|
||||
import { PersonalizationTarget } from './learning-path-personalization-util.js';
|
||||
import { LearningPath, LearningPathResponse } from 'dwengo-1-common/src/interfaces/learning-content';
|
||||
import { Language } from 'dwengo-1-common/src/util/language.js';
|
||||
|
||||
const userContentPrefix = getEnvVar(EnvVars.UserContentPrefix);
|
||||
const userContentPrefix = getEnvVar(envVars.UserContentPrefix);
|
||||
const allProviders = [dwengoApiLearningPathProvider, databaseLearningPathProvider];
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,9 @@ const learningPathService = {
|
|||
* Search learning paths in the data source using the given search string.
|
||||
*/
|
||||
async searchLearningPaths(query: string, language: Language, personalizedFor?: PersonalizationTarget): Promise<LearningPath[]> {
|
||||
const providerResponses = await Promise.all(allProviders.map((provider) => provider.searchLearningPaths(query, language, personalizedFor)));
|
||||
const providerResponses = await Promise.all(
|
||||
allProviders.map(async (provider) => provider.searchLearningPaths(query, language, personalizedFor))
|
||||
);
|
||||
return providerResponses.flat();
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue