diff --git a/backend/src/controllers/learning-paths.ts b/backend/src/controllers/learning-paths.ts index fca86bfb..7a98ab2e 100644 --- a/backend/src/controllers/learning-paths.ts +++ b/backend/src/controllers/learning-paths.ts @@ -2,12 +2,9 @@ import { Request, Response } from 'express'; import { themes } from '../data/themes.js'; import { FALLBACK_LANG } from '../config.js'; import learningPathService from '../services/learning-paths/learning-path-service'; -import {BadRequestException, NotFoundException} from '../exceptions'; -import {Language} from "../entities/content/language"; -import { - PersonalizationTarget, personalizedForGroup, - personalizedForStudent -} from "../services/learning-paths/learning-path-personalization-util"; +import { BadRequestException, NotFoundException } from '../exceptions'; +import { Language } from '../entities/content/language'; +import { PersonalizationTarget, personalizedForGroup, personalizedForStudent } from '../services/learning-paths/learning-path-personalization-util'; /** * Fetch learning paths based on query parameters. @@ -26,10 +23,10 @@ export async function getLearningPaths(req: Request, res: Response): Promise theme.hruids); } - const learningPaths = await learningPathService.fetchLearningPaths(hruidList, language as Language, `HRUIDs: ${hruidList.join(', ')}`, personalizationTarget); + const learningPaths = await learningPathService.fetchLearningPaths( + hruidList, + language as Language, + `HRUIDs: ${hruidList.join(', ')}`, + personalizationTarget + ); res.json(learningPaths.data); } diff --git a/backend/src/services/learning-paths/learning-path-personalization-util.ts b/backend/src/services/learning-paths/learning-path-personalization-util.ts index b7145bf3..df344917 100644 --- a/backend/src/services/learning-paths/learning-path-personalization-util.ts +++ b/backend/src/services/learning-paths/learning-path-personalization-util.ts @@ -2,12 +2,7 @@ import { LearningPathNode } from '../../entities/content/learning-path-node.enti import { Student } from '../../entities/users/student.entity'; import { Group } from '../../entities/assignments/group.entity'; import { Submission } from '../../entities/assignments/submission.entity'; -import { - getClassRepository, - getGroupRepository, - getStudentRepository, - getSubmissionRepository -} from '../../data/repositories'; +import { getClassRepository, getGroupRepository, getStudentRepository, getSubmissionRepository } from '../../data/repositories'; import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier'; import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity'; import { JSONPath } from 'jsonpath-plus'; @@ -23,12 +18,11 @@ export async function personalizedForStudent(username: string): Promise { +export async function personalizedForGroup( + classId: string, + assignmentNumber: number, + groupNumber: number +): Promise { const clazz = await getClassRepository().findById(classId); if (!clazz) { return undefined; @@ -48,16 +46,15 @@ export async function personalizedForGroup(classId: string, assignmentNumber: nu within: clazz, id: assignmentNumber, }, - groupNumber: groupNumber - }) + groupNumber: groupNumber, + }); if (group) { return { - type: "group", - group: group - } - } - return undefined; - + type: 'group', + group: group, + }; + } + return undefined; } /**