Skip to content

Commit

Permalink
fix(programming-annotations): fix student being able to see unpublish…
Browse files Browse the repository at this point in the history
…ed annotations

- added filtering for only published posts is a user cannot grade
- previously unpublished postIds were sent to students
- they should not have been able to see this postId, this resulted in frontend crashes as the erroneously sent postId is not present in json.posts
  • Loading branch information
syoopie authored and cysjonathan committed Sep 12, 2024
1 parent b9eb898 commit 2f82633
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# frozen_string_literal: true

json.annotations programming_files do |file|
json.fileId file.id
json.topics(file.annotations.reject { |a| a.discussion_topic.post_ids.empty? }) do |annotation|
topic = annotation.discussion_topic
next unless can_grade || !topic.posts.only_published_posts.empty?

json.id topic.id
json.postIds topic.post_ids
if can_grade
json.postIds topic.post_ids
else
json.postIds topic.posts.only_published_posts.ids
end
json.line annotation.line
end
end

0 comments on commit 2f82633

Please sign in to comment.