style: fix linting issues met ESLint

This commit is contained in:
Lint Action 2025-03-06 13:37:39 +00:00
parent 710adcaa34
commit b8aae0ab1b
17 changed files with 46 additions and 136 deletions

View file

@ -26,9 +26,7 @@ export async function getLearningPaths(
? hruids.map(String) ? hruids.map(String)
: [String(hruids)]; : [String(hruids)];
} else if (themeKey) { } else if (themeKey) {
const theme = themes.find((t) => { const theme = themes.find((t) => t.title === themeKey);
return t.title === themeKey;
});
if (theme) { if (theme) {
hruidList = theme.hruids; hruidList = theme.hruids;
} else { } else {
@ -45,9 +43,7 @@ export async function getLearningPaths(
res.json(searchResults); res.json(searchResults);
return; return;
} else { } else {
hruidList = themes.flatMap((theme) => { hruidList = themes.flatMap((theme) => theme.hruids);
return theme.hruids;
});
} }
const learningPaths = await fetchLearningPaths( const learningPaths = await fetchLearningPaths(

View file

@ -11,24 +11,20 @@ interface Translations {
export function getThemes(req: Request, res: Response) { export function getThemes(req: Request, res: Response) {
const language = (req.query.language as string)?.toLowerCase() || 'nl'; const language = (req.query.language as string)?.toLowerCase() || 'nl';
const translations = loadTranslations<Translations>(language); const translations = loadTranslations<Translations>(language);
const themeList = themes.map((theme) => { const themeList = themes.map((theme) => ({
return {
key: theme.title, key: theme.title,
title: title:
translations.curricula_page[theme.title]?.title || theme.title, translations.curricula_page[theme.title]?.title || theme.title,
description: translations.curricula_page[theme.title]?.description, description: translations.curricula_page[theme.title]?.description,
image: `https://dwengo.org/images/curricula/logo_${theme.title}.png`, image: `https://dwengo.org/images/curricula/logo_${theme.title}.png`,
}; }));
});
res.json(themeList); res.json(themeList);
} }
export function getThemeByTitle(req: Request, res: Response) { export function getThemeByTitle(req: Request, res: Response) {
const themeKey = req.params.theme; const themeKey = req.params.theme;
const theme = themes.find((t) => { const theme = themes.find((t) => t.title === themeKey);
return t.title === themeKey;
});
if (theme) { if (theme) {
res.json(theme.hruids); res.json(theme.hruids);

View file

@ -5,9 +5,7 @@ import { Student } from '../users/student.entity.js';
@Entity() @Entity()
export class Group { export class Group {
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Assignment,
return Assignment;
},
primary: true, primary: true,
}) })
assignment!: Assignment; assignment!: Assignment;
@ -16,9 +14,7 @@ export class Group {
groupNumber!: number; groupNumber!: number;
@ManyToMany({ @ManyToMany({
entity: () => { entity: () => Student,
return Student;
},
}) })
members!: Student[]; members!: Student[];
} }

View file

@ -9,9 +9,7 @@ export class Submission {
learningObjectHruid!: string; learningObjectHruid!: string;
@Enum({ @Enum({
items: () => { items: () => Language,
return Language;
},
primary: true, primary: true,
}) })
learningObjectLanguage!: Language; learningObjectLanguage!: Language;
@ -23,9 +21,7 @@ export class Submission {
submissionNumber!: number; submissionNumber!: number;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Student,
return Student;
},
}) })
submitter!: Student; submitter!: Student;
@ -33,9 +29,7 @@ export class Submission {
submissionTime!: Date; submissionTime!: Date;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Group,
return Group;
},
nullable: true, nullable: true,
}) })
onBehalfOf?: Group; onBehalfOf?: Group;

View file

@ -5,24 +5,18 @@ import { Class } from './class.entity.js';
@Entity() @Entity()
export class ClassJoinRequest { export class ClassJoinRequest {
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Student,
return Student;
},
primary: true, primary: true,
}) })
requester!: Student; requester!: Student;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Class,
return Class;
},
primary: true, primary: true,
}) })
class!: Class; class!: Class;
@Enum(() => { @Enum(() => ClassJoinRequestStatus)
return ClassJoinRequestStatus;
})
status!: ClassJoinRequestStatus; status!: ClassJoinRequestStatus;
} }

View file

@ -17,13 +17,9 @@ export class Class {
@Property({ type: 'string' }) @Property({ type: 'string' })
displayName!: string; displayName!: string;
@ManyToMany(() => { @ManyToMany(() => Teacher)
return Teacher;
})
teachers!: Collection<Teacher>; teachers!: Collection<Teacher>;
@ManyToMany(() => { @ManyToMany(() => Student)
return Student;
})
students!: Collection<Student>; students!: Collection<Student>;
} }

View file

@ -8,25 +8,19 @@ import { Class } from './class.entity.js';
@Entity() @Entity()
export class TeacherInvitation { export class TeacherInvitation {
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Teacher,
return Teacher;
},
primary: true, primary: true,
}) })
sender!: Teacher; sender!: Teacher;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Teacher,
return Teacher;
},
primary: true, primary: true,
}) })
receiver!: Teacher; receiver!: Teacher;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Class,
return Class;
},
primary: true, primary: true,
}) })
class!: Class; class!: Class;

View file

@ -4,9 +4,7 @@ import { LearningObject } from './learning-object.entity.js';
@Entity() @Entity()
export class Attachment { export class Attachment {
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => LearningObject,
return LearningObject;
},
primary: true, primary: true,
}) })
learningObject!: LearningObject; learningObject!: LearningObject;

View file

@ -18,9 +18,7 @@ export class LearningObject {
hruid!: string; hruid!: string;
@Enum({ @Enum({
items: () => { items: () => Language,
return Language;
},
primary: true, primary: true,
}) })
language!: Language; language!: Language;
@ -29,9 +27,7 @@ export class LearningObject {
version: string = '1'; version: string = '1';
@ManyToMany({ @ManyToMany({
entity: () => { entity: () => Teacher,
return Teacher;
},
}) })
admins!: Teacher[]; admins!: Teacher[];
@ -57,9 +53,7 @@ export class LearningObject {
skosConcepts!: string[]; skosConcepts!: string[];
@Embedded({ @Embedded({
entity: () => { entity: () => EducationalGoal,
return EducationalGoal;
},
array: true, array: true,
}) })
educationalGoals: EducationalGoal[] = []; educationalGoals: EducationalGoal[] = [];
@ -77,9 +71,7 @@ export class LearningObject {
estimatedTime!: number; estimatedTime!: number;
@Embedded({ @Embedded({
entity: () => { entity: () => ReturnValue,
return ReturnValue;
},
}) })
returnValue!: ReturnValue; returnValue!: ReturnValue;
@ -90,9 +82,7 @@ export class LearningObject {
contentLocation?: string; contentLocation?: string;
@OneToMany({ @OneToMany({
entity: () => { entity: () => Attachment,
return Attachment;
},
mappedBy: 'learningObject', mappedBy: 'learningObject',
}) })
attachments: Attachment[] = []; attachments: Attachment[] = [];

View file

@ -17,17 +17,13 @@ export class LearningPath {
hruid!: string; hruid!: string;
@Enum({ @Enum({
items: () => { items: () => Language,
return Language;
},
primary: true, primary: true,
}) })
language!: Language; language!: Language;
@ManyToMany({ @ManyToMany({
entity: () => { entity: () => Teacher,
return Teacher;
},
}) })
admins!: Teacher[]; admins!: Teacher[];
@ -41,9 +37,7 @@ export class LearningPath {
image!: string; image!: string;
@Embedded({ @Embedded({
entity: () => { entity: () => LearningPathNode,
return LearningPathNode;
},
array: true, array: true,
}) })
nodes: LearningPathNode[] = []; nodes: LearningPathNode[] = [];
@ -55,9 +49,7 @@ export class LearningPathNode {
learningObjectHruid!: string; learningObjectHruid!: string;
@Enum({ @Enum({
items: () => { items: () => Language,
return Language;
},
}) })
language!: Language; language!: Language;
@ -71,9 +63,7 @@ export class LearningPathNode {
startNode!: boolean; startNode!: boolean;
@Embedded({ @Embedded({
entity: () => { entity: () => LearningPathTransition,
return LearningPathTransition;
},
array: true, array: true,
}) })
transitions!: LearningPathTransition[]; transitions!: LearningPathTransition[];
@ -85,9 +75,7 @@ export class LearningPathTransition {
condition!: string; condition!: string;
@OneToOne({ @OneToOne({
entity: () => { entity: () => LearningPathNode,
return LearningPathNode;
},
}) })
next!: LearningPathNode; next!: LearningPathNode;
} }

View file

@ -5,17 +5,13 @@ import { Teacher } from '../users/teacher.entity.js';
@Entity() @Entity()
export class Answer { export class Answer {
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Teacher,
return Teacher;
},
primary: true, primary: true,
}) })
author!: Teacher; author!: Teacher;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Question,
return Question;
},
primary: true, primary: true,
}) })
toQuestion!: Question; toQuestion!: Question;

View file

@ -8,9 +8,7 @@ export class Question {
learningObjectHruid!: string; learningObjectHruid!: string;
@Enum({ @Enum({
items: () => { items: () => Language,
return Language;
},
primary: true, primary: true,
}) })
learningObjectLanguage!: Language; learningObjectLanguage!: Language;
@ -22,9 +20,7 @@ export class Question {
sequenceNumber!: number; sequenceNumber!: number;
@ManyToOne({ @ManyToOne({
entity: () => { entity: () => Student,
return Student;
},
}) })
author!: Student; author!: Student;

View file

@ -5,19 +5,13 @@ import { Group } from '../assignments/group.entity.js';
import { StudentRepository } from '../../data/users/student-repository.js'; import { StudentRepository } from '../../data/users/student-repository.js';
@Entity({ @Entity({
repository: () => { repository: () => StudentRepository,
return StudentRepository;
},
}) })
export class Student extends User { export class Student extends User {
@ManyToMany(() => { @ManyToMany(() => Class)
return Class;
})
classes!: Collection<Class>; classes!: Collection<Class>;
@ManyToMany(() => { @ManyToMany(() => Group)
return Group;
})
groups!: Collection<Group>; groups!: Collection<Group>;
constructor( constructor(

View file

@ -4,8 +4,6 @@ import { Class } from '../classes/class.entity.js';
@Entity() @Entity()
export class Teacher extends User { export class Teacher extends User {
@ManyToMany(() => { @ManyToMany(() => Class)
return Class;
})
classes!: Collection<Class>; classes!: Collection<Class>;
} }

View file

@ -52,9 +52,7 @@ function config(testingMode: boolean = false): Options {
// Workaround: vitest: `TypeError: Unknown file extension ".ts"` (ERR_UNKNOWN_FILE_EXTENSION) // Workaround: vitest: `TypeError: Unknown file extension ".ts"` (ERR_UNKNOWN_FILE_EXTENSION)
// (see https://mikro-orm.io/docs/guide/project-setup#testing-the-endpoint) // (see https://mikro-orm.io/docs/guide/project-setup#testing-the-endpoint)
dynamicImportProvider: (id) => { dynamicImportProvider: (id) => import(id),
return import(id);
},
}; };
} }
@ -70,9 +68,7 @@ function config(testingMode: boolean = false): Options {
// Logging // Logging
debug: LOG_LEVEL === 'debug', debug: LOG_LEVEL === 'debug',
loggerFactory: (options: LoggerOptions) => { loggerFactory: (options: LoggerOptions) => new MikroOrmLogger(options),
return new MikroOrmLogger(options);
},
}; };
} }

View file

@ -89,23 +89,15 @@ async function fetchLearningObjects(
const nodes: LearningObjectNode[] = learningPathResponse.data[0].nodes; const nodes: LearningObjectNode[] = learningPathResponse.data[0].nodes;
if (!full) { if (!full) {
return nodes.map((node) => { return nodes.map((node) => node.learningobject_hruid);
return node.learningobject_hruid;
});
} }
return await Promise.all( return await Promise.all(
nodes.map(async (node) => { nodes.map(async (node) => getLearningObjectById(
return getLearningObjectById(
node.learningobject_hruid, node.learningobject_hruid,
language language
); ))
}) ).then((objects) => objects.filter((obj): obj is FilteredLearningObject => obj !== null));
).then((objects) => {
return objects.filter((obj): obj is FilteredLearningObject => {
return obj !== null;
});
});
} catch (error) { } catch (error) {
logger.error('❌ Error fetching learning objects:', error); logger.error('❌ Error fetching learning objects:', error);
return []; return [];

View file

@ -22,16 +22,12 @@ const router = createRouter({
{ {
path: "/", path: "/",
name: "home", name: "home",
component: () => { component: () => import("../views/HomePage.vue"),
return import("../views/HomePage.vue");
},
}, },
{ {
path: "/login", path: "/login",
name: "LoginPage", name: "LoginPage",
component: () => { component: () => import("../views/LoginPage.vue"),
return import("../views/LoginPage.vue");
},
}, },
{ {
path: "/student/:id", path: "/student/:id",