Skip to content

Commit

Permalink
Update to Jutut that a feedback response has been read
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael-Lenander authored and ihalaij1 committed Jun 4, 2024
1 parent a3a69f6 commit b3c9a82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions exercise/api/full_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class SubmissionGraderSerializer(AplusModelSerializerBase):
)
submission = SubmissionInGraderSerializer(source='*')
exercise = ExerciseBriefSerializer()
feedback_response_seen = serializers.SerializerMethodField()

class Meta(AplusSerializerMeta):
model = Submission
Expand All @@ -181,8 +182,19 @@ class Meta(AplusSerializerMeta):
'exercise',
'grading_data',
'is_graded',
'feedback_response_seen',
)

def get_feedback_response_seen(self, obj: Submission) -> bool:
"""Returns whether all feedback responses (notifications) have
been seen by the submitter. Used to inform the author of the
feedback about the status of the feedback responses.
If there are no notifications, the feedback response is not
considered seen so that a new submission is not immediately
marked as 'feedback response seen'.
"""
return not obj.notifications.filter(seen=False).exists() and obj.notifications.count() > 0


class TreeExerciseSerializer(serializers.Serializer):
"""
Expand Down
3 changes: 3 additions & 0 deletions notification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def get_resource_objects(self):
def get(self, request, *args, **kwargs):
self.notification.seen = True
self.notification.save()
submission = self.notification.submission
# Sends an update to Jutut that the feedback response has been seen.
submission.exercise.grade(submission)
if self.notification.submission:
return self.redirect(
self.notification.submission.get_url('submission-plain')
Expand Down

0 comments on commit b3c9a82

Please sign in to comment.