API-32: Adding ability to remove unwanted elective and profile modules
Jenkins Production Deployment Details

This commit is contained in:
Patrick Müller 2021-10-07 13:48:44 +02:00
parent f850b84152
commit 03250ef182
1 changed files with 76 additions and 0 deletions

View File

@ -20,6 +20,14 @@ export const getiCalFile = async (user: string, file: string, showBlockers: bool
iCalFile = removeBlockers(iCalFile);
}
if (electiveModule !== '') {
iCalFile = removeElective(iCalFile, electiveModule);
}
if (profileModule !== '') {
iCalFile = removeProfile(iCalFile, profileModule);
}
// Turn into one file again
let resultingFile = serializeIcal(iCalFile);
@ -80,7 +88,75 @@ export const removeBlockers = function (ical: iCalFile): iCalFile {
return ical;
};
export const removeElective = function (ical: iCalFile, chosenElective: string): iCalFile {
let remainingEvents: string[] = [];
let electiveToRemove = electiveModules;
electiveToRemove.splice(parseInt(chosenElective), 1);
ical.body.forEach((event) => {
let addEvent = true;
electiveToRemove.forEach((module) => {
if (event.includes(module.name)) {
addEvent = false;
}
});
if (addEvent) {
remainingEvents.push(event);
}
});
ical.body = remainingEvents;
return ical;
};
export const removeProfile = function (ical: iCalFile, chosenProfile: string): iCalFile {
let remainingEvents: string[] = [];
let profileToRemove = profileModules;
profileToRemove.splice(parseInt(chosenProfile), 1);
ical.body.forEach((event) => {
let addEvent = true;
profileToRemove.forEach((module) => {
module.names.forEach((name) => {
if (event.includes(name)) {
addEvent = false;
}
});
});
if (addEvent) {
remainingEvents.push(event);
}
});
ical.body = remainingEvents;
return ical;
};
export interface iCalFile {
head: string;
body: string[];
}
let electiveModules = [
{name: 'ERP-Systeme'},
{name: 'Ethik für Informatiker'},
{name: 'Evolutionäre Algorithmen'},
{name: 'Forensik'},
{name: 'Kryptographische Verfahren'},
{name: 'Anwendung der Robotik'},
{name: 'Web-Services'}
];
let profileModules = [
{names: ['.Grundlagen der KI (KI und BV)', 'Bildverarbeitung (KI und BV)']},
{names: ['Bildverarbeitung', 'Computergraphik']},
{names: ['Interaktive Systeme', 'Grundlagen der KI']},
{names: ['e Business', 'angewandtes Projektmanagement']},
{names: ['Kommunikations und Netztechnik II']}
];