hbui
2024-07-15 fbfe69b85cb9471e9699c9d9c68e2af640a73892
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from typing import Final
 
from mystudy.DataFormatError import DataFormatError
from mystudy.LecruresConverter import LecturesConvert
 
lecture_time: Final[int] = 15
ects_effort: Final[int] = 30
 
 
class Lecture():
    def __init__(self, name, ects, frequency):
        """
 
        :param name:
        :param ects:
        :param frequency:
        """
        self._name = name
        self._ects = ects
        self._frequency = frequency
 
    def cal_effort(self, time_per_ects = ects_effort, duration = lecture_time) -> float:
        """
        Berechnet den Zeitaufwand pro woche für diese Vorlesung
        :param time_per_ects:
        :param duration:
        :return:
        """
        effort_in_time = self._ects * time_per_ects
        effort_per_week = effort_in_time / duration
        return effort_per_week - (self._frequency * 1.5)
 
    def name(self):
        return self._name
 
    def ects(self):
        return self._ects
 
    def frequency(self):
        return self._frequency
 
    def __repr__(self):
        return f"Vorlesungsname {self._name} ECTS: {self._ects} Zeit/Woche {self.cal_effort()}"
 
    # def __str__(self):
    #    return self.__repr__()
 
 
def parse_lecture_line(line: str) -> Lecture:
    words = line.split(";")
    words = [w.strip() for w in words]
    name = words[0]
    count = float(words[1])
    ects = int(words[2])
    return Lecture(name, ects, count)
 
    pass
 
 
class Lecture2HTMLConverter(LecturesConvert):
    def __init__(self):
        self.__head = """<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vorlesung</title>
</head>
<body>"""
        self.__foot = """
        </body>
</html>
        """
 
    def convert(self, lectures: list[Lecture]) -> str:
        html = ""
        for l in lectures:
            html += f"""<tr>
            <td>{l.name()}<td>
            <td>{l.ects()}</td>
            <td>{l.frequency()}</td>
            <td>{l.cal_effort()}</td>
            </tr>"""
        return f"{self.__head}<table>{html}</table>{self.__foot}"