style: fix linting issues met ESLint

This commit is contained in:
Lint Action 2025-03-11 03:09:08 +00:00
parent a30c4d0d32
commit aa1a85e64e
24 changed files with 76 additions and 90 deletions

View file

@ -22,7 +22,7 @@ import {LearningPathTransition} from "../../entities/content/learning-path-trans
*/
async function getLearningObjectsForNodes(nodes: LearningPathNode[]): Promise<Map<LearningPathNode, FilteredLearningObject>> {
// Fetching the corresponding learning object for each of the nodes and creating a map that maps each node to
// its corresponding learning object.
// Its corresponding learning object.
const nullableNodesToLearningObjects = new Map<LearningPathNode, FilteredLearningObject | null>(
await Promise.all(
nodes.map(node =>
@ -58,7 +58,7 @@ async function convertLearningPath(learningPath: LearningPathEntity, order: numb
const image = learningPath.image ? learningPath.image.toString("base64") : undefined;
return {
_id: `${learningPath.hruid}/${learningPath.language}`, // for backwards compatibility with the original Dwengo API.
_id: `${learningPath.hruid}/${learningPath.language}`, // For backwards compatibility with the original Dwengo API.
__order: order,
hruid: learningPath.hruid,
language: learningPath.language,

View file

@ -43,7 +43,7 @@ function transitionPossible(transition: LearningPathTransition, submitted: objec
*/
const learningPathPersonalizingService = {
async calculatePersonalizedTrajectory(nodes: LearningPathNode[], pathFor: {student?: Student, group?: Group}): Promise<LearningPathNode[]> {
let trajectory: LearningPathNode[] = [];
const trajectory: LearningPathNode[] = [];
// Always start with the start node.
let currentNode = nodes.filter(it => it.startNode)[0];
@ -51,17 +51,17 @@ const learningPathPersonalizingService = {
while (true) {
// At every node, calculate all the possible next transitions.
let lastSubmission = await getLastRelevantSubmission(currentNode, pathFor);
let submitted = lastSubmission === null ? null : JSON.parse(lastSubmission.content);
let possibleTransitions = currentNode.transitions
const lastSubmission = await getLastRelevantSubmission(currentNode, pathFor);
const submitted = lastSubmission === null ? null : JSON.parse(lastSubmission.content);
const possibleTransitions = currentNode.transitions
.filter(it => transitionPossible(it, submitted));
if (possibleTransitions.length === 0) { // If there are none, the trajectory has ended.
return trajectory;
} else { // Otherwise, take the first possible transition.
} // Otherwise, take the first possible transition.
currentNode = possibleTransitions[0].node;
trajectory.push(currentNode);
}
}
}
};