diff options
author | Frederick Yin <fkfd@fkfd.me> | 2023-07-21 14:57:15 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2023-07-21 14:57:15 +0800 |
commit | 07926e1d43dda6e6acb64c691ceefb818da87ba7 (patch) | |
tree | a06bccacb01519ea2b35e12a1ea326645354d51e | |
parent | 17c41a0c998b7e73cb96bc71f26e2b68aae7eff4 (diff) |
Fix false submitted bug
-rw-r--r-- | contents/ui/main.qml | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/contents/ui/main.qml b/contents/ui/main.qml index 41af62a..da80c38 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -51,6 +51,13 @@ Item { const showSubmittedAssignments = plasmoid.configuration.showSubmittedAssignments + // we need user id to check submission status + callApi("/users/self", 1, user => { + syncCourses(courses, showSubmittedAssignments, user.id) + }) + } + + function syncCourses(courses, showSubmittedAssignments, userId) { announcementsModel.clear() assignmentsModel.clear() @@ -79,25 +86,27 @@ Item { callApi(`/courses/${course.id}/assignments`, 10, assignments => { assignments.forEach(assignment => { - const info = { - type: "assignment", - activityId: assignment.id, - course: course.code, - title: assignment.name, - dueAt: assignment.due_at, - submitted: assignment.has_submitted_submissions, - url: assignment.html_url, - important: plasmoid.configuration.importantAssignments.includes(assignment.id.toString()), - finished: plasmoid.configuration.finishedAssignments.includes(assignment.id.toString()), - } + callApi(`/courses/${course.id}/assignments/${assignment.id}/submissions/${userId}`, 1, submission => { + const info = { + type: "assignment", + activityId: assignment.id, + course: course.code, + title: assignment.name, + dueAt: assignment.due_at, + submitted: submission.workflow_state != "unsubmitted", + url: assignment.html_url, + important: plasmoid.configuration.importantAssignments.includes(assignment.id.toString()), + finished: plasmoid.configuration.finishedAssignments.includes(assignment.id.toString()), + } - if (!info.submitted || showSubmittedAssignments) { - if (info.important) { - assignmentsModel.insert(importantCount.assignments++, info) - } else { - assignmentsModel.append(info) + if (!info.submitted || showSubmittedAssignments) { + if (info.important) { + assignmentsModel.insert(importantCount.assignments++, info) + } else { + assignmentsModel.append(info) + } } - } + }) }) }) } |