Carolyn/GoogleService/models/assignment.py
Serafim 892fa7b87b
Сервис переименован: SpreadsheetsService→GoogleService (#18)
* Переименовал SpreadsheetsService→GoogleService

* кэш тестов
2021-11-05 15:20:41 +03:00

49 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from logging import addLevelName
import uuid
class Assignment(dict):
"""Задание."""
def __init__(
self,
name: str,
points: list,
weight: float = 1,
subject: str = None,
allow_to_display: bool = False,
how_to_display: str = "z,10,1",
notes: str = "Замечаний по работе нет.",
deadline: str = "-",
):
self.name = name
self.subject = subject
self.weight = weight
self.points = points
self.allow_to_display = allow_to_display
self.how_to_display = how_to_display
self.notes = notes
self.deadline = deadline
self.uuid = uuid.uuid3(uuid.NAMESPACE_DNS, f"{name}{subject}")
dict.__init__(
self,
name=self.name,
subject=self.subject,
weight=self.weight,
points=self.points,
total=self.total,
allow_to_display=self.allow_to_display,
how_to_display=self.how_to_display,
notes=self.notes,
deadline=self.deadline,
uuid=self.uuid,
)
@property
def total(self) -> float:
"""Получить общую оценку по заданию.
`вес*СУММ(рез-ты)`
"""
return sum(self.points) * self.weight