style: fix linting issues met Prettier
This commit is contained in:
parent
a4f992035e
commit
bec69863b4
1 changed files with 20 additions and 23 deletions
|
@ -41,11 +41,9 @@ async function getLearningObjectsForNodes(nodes: LearningPathNode[]): Promise<Ma
|
||||||
async function convertLearningPath(learningPath: LearningPathEntity, order: number, personalizedFor?: PersonalizationTarget): Promise<LearningPath> {
|
async function convertLearningPath(learningPath: LearningPathEntity, order: number, personalizedFor?: PersonalizationTarget): Promise<LearningPath> {
|
||||||
const nodesToLearningObjects: Map<LearningPathNode, FilteredLearningObject> = await getLearningObjectsForNodes(learningPath.nodes);
|
const nodesToLearningObjects: Map<LearningPathNode, FilteredLearningObject> = await getLearningObjectsForNodes(learningPath.nodes);
|
||||||
|
|
||||||
const targetAges = Array.from(nodesToLearningObjects.values())
|
const targetAges = Array.from(nodesToLearningObjects.values()).flatMap((it) => it.targetAges || []);
|
||||||
.flatMap((it) => it.targetAges || []);
|
|
||||||
|
|
||||||
const keywords = Array.from(nodesToLearningObjects.values())
|
const keywords = Array.from(nodesToLearningObjects.values()).flatMap((it) => it.keywords || []);
|
||||||
.flatMap((it) => it.keywords || []);
|
|
||||||
|
|
||||||
const image = learningPath.image ? learningPath.image.toString('base64') : undefined;
|
const image = learningPath.image ? learningPath.image.toString('base64') : undefined;
|
||||||
|
|
||||||
|
@ -79,25 +77,24 @@ async function convertNodes(
|
||||||
nodesToLearningObjects: Map<LearningPathNode, FilteredLearningObject>,
|
nodesToLearningObjects: Map<LearningPathNode, FilteredLearningObject>,
|
||||||
personalizedFor?: PersonalizationTarget
|
personalizedFor?: PersonalizationTarget
|
||||||
): Promise<LearningObjectNode[]> {
|
): Promise<LearningObjectNode[]> {
|
||||||
const nodesPromise = Array.from(nodesToLearningObjects.entries())
|
const nodesPromise = Array.from(nodesToLearningObjects.entries()).map(async (entry) => {
|
||||||
.map(async (entry) => {
|
const [node, learningObject] = entry;
|
||||||
const [node, learningObject] = entry;
|
const lastSubmission = personalizedFor ? await getLastSubmissionForCustomizationTarget(node, personalizedFor) : null;
|
||||||
const lastSubmission = personalizedFor ? await getLastSubmissionForCustomizationTarget(node, personalizedFor) : null;
|
return {
|
||||||
return {
|
_id: learningObject.uuid,
|
||||||
_id: learningObject.uuid,
|
language: learningObject.language,
|
||||||
language: learningObject.language,
|
start_node: node.startNode,
|
||||||
start_node: node.startNode,
|
created_at: node.createdAt.toISOString(),
|
||||||
created_at: node.createdAt.toISOString(),
|
updatedAt: node.updatedAt.toISOString(),
|
||||||
updatedAt: node.updatedAt.toISOString(),
|
learningobject_hruid: node.learningObjectHruid,
|
||||||
learningobject_hruid: node.learningObjectHruid,
|
version: learningObject.version,
|
||||||
version: learningObject.version,
|
transitions: node.transitions
|
||||||
transitions: node.transitions
|
.filter(
|
||||||
.filter(
|
(trans) => !personalizedFor || isTransitionPossible(trans, optionalJsonStringToObject(lastSubmission?.content)) // If we want a personalized learning path, remove all transitions that aren't possible.
|
||||||
(trans) => !personalizedFor || isTransitionPossible(trans, optionalJsonStringToObject(lastSubmission?.content)) // If we want a personalized learning path, remove all transitions that aren't possible.
|
)
|
||||||
)
|
.map((trans, i) => convertTransition(trans, i, nodesToLearningObjects)), // Then convert all the transition
|
||||||
.map((trans, i) => convertTransition(trans, i, nodesToLearningObjects)), // Then convert all the transition
|
};
|
||||||
};
|
});
|
||||||
});
|
|
||||||
return await Promise.all(nodesPromise);
|
return await Promise.all(nodesPromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue