diff options
Diffstat (limited to 'contents/ui')
-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) + } } - } + }) }) }) } |