diff --git a/exercise/api/full_serializers.py b/exercise/api/full_serializers.py index 550e93e89..f02492fe7 100644 --- a/exercise/api/full_serializers.py +++ b/exercise/api/full_serializers.py @@ -172,6 +172,7 @@ class SubmissionGraderSerializer(AplusModelSerializerBase): ) submission = SubmissionInGraderSerializer(source='*') exercise = ExerciseBriefSerializer() + feedback_response_seen = serializers.SerializerMethodField() class Meta(AplusSerializerMeta): model = Submission @@ -181,8 +182,18 @@ 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): """ diff --git a/notification/views.py b/notification/views.py index 87e34f571..a27069d7c 100644 --- a/notification/views.py +++ b/notification/views.py @@ -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')