77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
|
|
import datetime
|
|
from typing import Dict, List
|
|
|
|
|
|
class Submission:
|
|
def __init__(
|
|
self,
|
|
uco: str,
|
|
login: str,
|
|
path: str,
|
|
points: float,
|
|
homework: str,
|
|
correction: bool,
|
|
) -> None:
|
|
self.uco = uco
|
|
self.login = login
|
|
self.path = path
|
|
self.points = points
|
|
self.homework = homework
|
|
self.correction = correction
|
|
|
|
self.submitted_at = None
|
|
self.submitted_before_deadline = None
|
|
self.flag = None
|
|
self.branch = f"{homework}{'-opravne' if correction else ''}-{login}"
|
|
self.__set_submission_date()
|
|
|
|
def __set_submission_date(self) -> None:
|
|
self.submitted_at = datetime.datetime.strptime(
|
|
self.path.split("/")[-1][-16:], "%Y_%m%d_%H%M%S"
|
|
)
|
|
|
|
def set_late_tag(self, deadline: datetime.datetime) -> None:
|
|
self.submitted_before_deadline = self.submitted_at < deadline
|
|
if not self.submitted_before_deadline:
|
|
self.flag = "LATE"
|
|
|
|
|
|
def print_submissions(all_submissions: Dict[str, List[Submission]]) -> None:
|
|
header = (
|
|
"| "
|
|
+ " | ".join(
|
|
[
|
|
"###",
|
|
"UCO".center(6),
|
|
"LOGIN".center(8),
|
|
"SUBMITTED".center(19),
|
|
"POINTS",
|
|
"FLAG".center(6),
|
|
]
|
|
)
|
|
+ " |"
|
|
)
|
|
SEPARATOR = "-" * len(header)
|
|
print(SEPARATOR)
|
|
print(header)
|
|
print(SEPARATOR)
|
|
|
|
FORMAT = "| {:>3} | {:>6s} | {:>8s} | {} | {:>6.2f} | {:^6s} |"
|
|
|
|
for _, submissions in all_submissions.items():
|
|
for i, submission in enumerate(submissions):
|
|
date = submission.submitted_at.strftime("%Y-%m-%d %H:%M:%S")
|
|
print(
|
|
FORMAT.format(
|
|
i,
|
|
submission.uco if i == 0 else "",
|
|
submission.login if i == 0 else "",
|
|
date,
|
|
submission.points,
|
|
submission.flag if submission.flag else "",
|
|
)
|
|
)
|
|
print(SEPARATOR)
|