diff --git a/webapp/dto.py b/webapp/dto.py index 80fae584..b55a12b8 100644 --- a/webapp/dto.py +++ b/webapp/dto.py @@ -170,6 +170,16 @@ def show_achievements(self) -> bool: Status.CheckedFailed: True, }) + @property + def is_submitted(self) -> bool: + if self.status in [Status.Submitted, Status.CheckedSubmitted]: + return True + if self.status in [Status.Checked, Status.Failed, Status.NotSubmitted, Status.CheckedFailed]: + return False + else: + assert False, "unhandled status" + return False + def map_achievements(self, status: TaskStatus | None, achievements: list[int]): dtos = [] for order, count in enumerate(achievements): diff --git a/webapp/static/js/autoreload.js b/webapp/static/js/autoreload.js new file mode 100644 index 00000000..70d4ca1d --- /dev/null +++ b/webapp/static/js/autoreload.js @@ -0,0 +1,13 @@ +let statusPath = window.location.href + "/status"; +let f = () => fetch(statusPath).then(res => { + if(res.status == 418) { + return new Promise(r => setTimeout(r, 2000)).then(f) + } + if(!res.ok) { + return + } + return res.text().then(b => { + document.getElementById("task-status").innerHTML = b; + }) +}); +f() diff --git a/webapp/templates/student/task.jinja b/webapp/templates/student/task.jinja index faef0645..a575eb6e 100644 --- a/webapp/templates/student/task.jinja +++ b/webapp/templates/student/task.jinja @@ -28,48 +28,14 @@ status.external.group_title }} -