style: fix linting issues met Prettier
This commit is contained in:
parent
78267a2416
commit
86dadeae81
2 changed files with 29 additions and 30 deletions
|
@ -2,12 +2,9 @@ import { Request, Response } from 'express';
|
||||||
import { themes } from '../data/themes.js';
|
import { themes } from '../data/themes.js';
|
||||||
import { FALLBACK_LANG } from '../config.js';
|
import { FALLBACK_LANG } from '../config.js';
|
||||||
import learningPathService from '../services/learning-paths/learning-path-service';
|
import learningPathService from '../services/learning-paths/learning-path-service';
|
||||||
import {BadRequestException, NotFoundException} from '../exceptions';
|
import { BadRequestException, NotFoundException } from '../exceptions';
|
||||||
import {Language} from "../entities/content/language";
|
import { Language } from '../entities/content/language';
|
||||||
import {
|
import { PersonalizationTarget, personalizedForGroup, personalizedForStudent } from '../services/learning-paths/learning-path-personalization-util';
|
||||||
PersonalizationTarget, personalizedForGroup,
|
|
||||||
personalizedForStudent
|
|
||||||
} from "../services/learning-paths/learning-path-personalization-util";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch learning paths based on query parameters.
|
* Fetch learning paths based on query parameters.
|
||||||
|
@ -26,10 +23,10 @@ export async function getLearningPaths(req: Request, res: Response): Promise<voi
|
||||||
let personalizationTarget: PersonalizationTarget | undefined;
|
let personalizationTarget: PersonalizationTarget | undefined;
|
||||||
|
|
||||||
if (forStudent) {
|
if (forStudent) {
|
||||||
personalizationTarget = await personalizedForStudent(forStudent)
|
personalizationTarget = await personalizedForStudent(forStudent);
|
||||||
} else if (forGroupNo) {
|
} else if (forGroupNo) {
|
||||||
if (!assignmentNo || !classId) {
|
if (!assignmentNo || !classId) {
|
||||||
throw new BadRequestException("If forGroupNo is specified, assignmentNo and classId must also be specified.");
|
throw new BadRequestException('If forGroupNo is specified, assignmentNo and classId must also be specified.');
|
||||||
}
|
}
|
||||||
personalizationTarget = await personalizedForGroup(classId, parseInt(assignmentNo), parseInt(forGroupNo));
|
personalizationTarget = await personalizedForGroup(classId, parseInt(assignmentNo), parseInt(forGroupNo));
|
||||||
}
|
}
|
||||||
|
@ -53,6 +50,11 @@ export async function getLearningPaths(req: Request, res: Response): Promise<voi
|
||||||
hruidList = themes.flatMap((theme) => theme.hruids);
|
hruidList = themes.flatMap((theme) => 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);
|
res.json(learningPaths.data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,7 @@ import { LearningPathNode } from '../../entities/content/learning-path-node.enti
|
||||||
import { Student } from '../../entities/users/student.entity';
|
import { Student } from '../../entities/users/student.entity';
|
||||||
import { Group } from '../../entities/assignments/group.entity';
|
import { Group } from '../../entities/assignments/group.entity';
|
||||||
import { Submission } from '../../entities/assignments/submission.entity';
|
import { Submission } from '../../entities/assignments/submission.entity';
|
||||||
import {
|
import { getClassRepository, getGroupRepository, getStudentRepository, getSubmissionRepository } from '../../data/repositories';
|
||||||
getClassRepository,
|
|
||||||
getGroupRepository,
|
|
||||||
getStudentRepository,
|
|
||||||
getSubmissionRepository
|
|
||||||
} from '../../data/repositories';
|
|
||||||
import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier';
|
import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier';
|
||||||
import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity';
|
import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity';
|
||||||
import { JSONPath } from 'jsonpath-plus';
|
import { JSONPath } from 'jsonpath-plus';
|
||||||
|
@ -23,12 +18,11 @@ export async function personalizedForStudent(username: string): Promise<Personal
|
||||||
const student = await getStudentRepository().findByUsername(username);
|
const student = await getStudentRepository().findByUsername(username);
|
||||||
if (student) {
|
if (student) {
|
||||||
return {
|
return {
|
||||||
type: "student",
|
type: 'student',
|
||||||
student: student
|
student: student,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +32,11 @@ export async function personalizedForStudent(username: string): Promise<Personal
|
||||||
* @param assignmentNumber Number of the assignment for which this group was created
|
* @param assignmentNumber Number of the assignment for which this group was created
|
||||||
* @param groupNumber Number of the group for which we want to personalize the learning path.
|
* @param groupNumber Number of the group for which we want to personalize the learning path.
|
||||||
*/
|
*/
|
||||||
export async function personalizedForGroup(classId: string, assignmentNumber: number, groupNumber: number): Promise<PersonalizationTarget | undefined> {
|
export async function personalizedForGroup(
|
||||||
|
classId: string,
|
||||||
|
assignmentNumber: number,
|
||||||
|
groupNumber: number
|
||||||
|
): Promise<PersonalizationTarget | undefined> {
|
||||||
const clazz = await getClassRepository().findById(classId);
|
const clazz = await getClassRepository().findById(classId);
|
||||||
if (!clazz) {
|
if (!clazz) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -48,16 +46,15 @@ export async function personalizedForGroup(classId: string, assignmentNumber: nu
|
||||||
within: clazz,
|
within: clazz,
|
||||||
id: assignmentNumber,
|
id: assignmentNumber,
|
||||||
},
|
},
|
||||||
groupNumber: groupNumber
|
groupNumber: groupNumber,
|
||||||
})
|
});
|
||||||
if (group) {
|
if (group) {
|
||||||
return {
|
return {
|
||||||
type: "group",
|
type: 'group',
|
||||||
group: group
|
group: group,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue