Merge remote-tracking branch 'origin/dev' into feature/own-learning-objects

# Conflicts:
#	backend/package.json
#	backend/src/config.ts
#	backend/src/controllers/learningObjects.ts
#	backend/src/controllers/learningPaths.ts
#	backend/src/data/content/attachment-repository.ts
#	backend/src/data/content/learning-object-repository.ts
#	backend/src/data/content/learning-path-repository.ts
#	backend/src/data/repositories.ts
#	backend/src/entities/content/learning-path.entity.ts
#	backend/src/exceptions.ts
#	backend/src/routes/learning-objects.ts
#	backend/src/services/learningObjects.ts
#	backend/src/services/learningPaths.ts
#	backend/src/util/apiHelper.ts
#	backend/src/util/envvars.ts
#	package-lock.json
This commit is contained in:
Gerald Schmittinger 2025-03-11 03:01:18 +01:00
commit cd0a3a8a7b
119 changed files with 8837 additions and 1697 deletions

View file

@ -0,0 +1,33 @@
import { EnvVars, getEnvVar } from '../util/envvars.js';
type FrontendIdpConfig = {
authority: string;
clientId: string;
scope: string;
responseType: string;
};
type FrontendAuthConfig = {
student: FrontendIdpConfig;
teacher: FrontendIdpConfig;
};
const SCOPE = 'openid profile email';
const RESPONSE_TYPE = 'code';
export function getFrontendAuthConfig(): FrontendAuthConfig {
return {
student: {
authority: getEnvVar(EnvVars.IdpStudentUrl),
clientId: getEnvVar(EnvVars.IdpStudentClientId),
scope: SCOPE,
responseType: RESPONSE_TYPE,
},
teacher: {
authority: getEnvVar(EnvVars.IdpTeacherUrl),
clientId: getEnvVar(EnvVars.IdpTeacherClientId),
scope: SCOPE,
responseType: RESPONSE_TYPE,
},
};
}

View file

@ -0,0 +1,45 @@
import { Request, Response } from 'express';
import { themes } from '../data/themes.js';
import { FALLBACK_LANG } from '../config.js';
import { fetchLearningPaths, searchLearningPaths } from '../services/learningPaths.js';
import { getLogger } from '../logging/initalize.js';
/**
* Fetch learning paths based on query parameters.
*/
export async function getLearningPaths(req: Request, res: Response): Promise<void> {
try {
const hruids = req.query.hruid;
const themeKey = req.query.theme as string;
const searchQuery = req.query.search as string;
const language = (req.query.language as string) || FALLBACK_LANG;
let hruidList;
if (hruids) {
hruidList = Array.isArray(hruids) ? hruids.map(String) : [String(hruids)];
} else if (themeKey) {
const theme = themes.find((t) => t.title === themeKey);
if (theme) {
hruidList = theme.hruids;
} else {
res.status(404).json({
error: `Theme "${themeKey}" not found.`,
});
return;
}
} else if (searchQuery) {
const searchResults = await searchLearningPaths(searchQuery, language);
res.json(searchResults);
return;
} else {
hruidList = themes.flatMap((theme) => theme.hruids);
}
const learningPaths = await fetchLearningPaths(hruidList, language, `HRUIDs: ${hruidList.join(', ')}`);
res.json(learningPaths.data);
} catch (error) {
getLogger().error('❌ Unexpected error fetching learning paths:', error);
res.status(500).json({ error: 'Internal server error' });
}
}

View file

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