import {calculateHomeworkTime} from "../study.js";
export function makeEffortTable(lecturesInformation) {
let table = `
Vorlesung | Aufwand pro Woche in Stunden |
\n`;
for(let l of lecturesInformation) {
table += `${l.name} | ${l.homework} |
\n`
}
table += "
";
return table;
}
export function calculateSemesterEffort(lectures) {
let lecturesInformation = []
for(let lecture of lectures ) {
let homework = calculateHomeworkTime(lecture.ects, lecture.sws/2);
let newLecture = Object.assign({},lecture);
newLecture.homework = homework;
// handle omitted sws or ects
let sws = newLecture["sws"] || 0;
newLecture["sws"] = sws;
let ects = newLecture["ects"] || 0;
newLecture["ects"] = ects;
lecturesInformation.push(newLecture);
}
return lecturesInformation;
}
/**
* columns of csv: order is matter!
* name; code; sws; ects
* */
export function parseCSV(csvFormat) {
let csv = csvFormat.trim();
let data = [];
for(let line of csv.split("\n") ) {
let values = line.split(";");
let name = values[0].trim();
let code = values[1] ;
code = code ? code.trim() : code; // if code is not an undefined, then trim it
let sws = Number.parseInt(values[2], 10);
let ects = Number.parseInt(values[3], 10);
data.push({name, code, sws, ects});
}
return data;
}