Hong-Phuc Bui
2025-01-16 2889de7f0c2d587a17fbd322af57c29e84238620
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {DomOutput} from "./lib/DomIO.js";
import {calculateHomeworkTime} from "./study.js";
 
const OUTPUT_ELEMENT_ID = "text-output";
let terminal = new DomOutput(OUTPUT_ELEMENT_ID);
 
document.addEventListener("DOMContentLoaded",() =>{
    document.getElementById("run").addEventListener("click", main);
});
 
function main() {
    const lectures = [
        // ergänzen Sie die Vorlesungen hier. Die Struktur des Elementes finden Sie im Skript
    ];
    const lecturesInformation = []
    for(const lecture of lectures ) {
        const homework = calculateHomeworkTime(lecture.ects, lecture.sws/2);
        const newLecture = Object.assign({},lecture);
        newLecture.homework = homework;
        lecturesInformation.push(newLecture);
    }
    printLectureInformation(lecturesInformation);
}
 
/**
 * pint a HTML table which represents the erffort of each lecture, one per row,
 * on browser via `terminal`.
 *
 * @param lecturesInformation an array, its elements have structure:
 * ```[
 *     {"name":"Deutsch 3",     "code":"DFBI-311", "sws":4, "ects": 4, "homework": 1},
 *     {"name":"Französisch 3", "code":"DFBI-312", "sws":3, "ects": 4, "homework": 1}
 * ]```
 *
 * */
function printLectureInformation(lecturesInformation) {
    terminal.clear();
    let table = `<table><tr>
    <th class="name">Vorlesung</th><th class="effort">Aufwand pro Woche in Stunden</th>
</tr>\n`;
    for(const l of lecturesInformation) {
        table += `<tr><td class="name">${l.name}</td> <td class="effort">${l.homework}</td></tr>\n`
    }
    table += "</table>";
    terminal.printh(table);
}