Hong-Phuc Bui
2024-07-01 82915d6ee31fd763e7cd2391a25c225060cf1120
study-effort/src/mystudy/lecture.py
@@ -1,5 +1,7 @@
from typing import Final
from mystudy.DataFormatError import DataFormatError
lecture_time: Final[int] = 15
ects_effort: Final[int] = 30
@@ -27,8 +29,17 @@
        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}"
        return f"Vorlesungsname {self._name} ECTS: {self._ects} Zeit/Woche {self.cal_effort()}"
    # def __str__(self):
    #    return self.__repr__()
@@ -41,11 +52,31 @@
    count = float(words[1])
    ects = int(words[2])
    return Lecture(name, ects, count)
    pass
class Lecture2HTMLConverter:
    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 to_html(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}"