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}"
|