Skip to content

Commit d4f8638

Browse files
committed
refactor: further attempt to filter out moderation tasks with no tutor feedback
1 parent b3636f8 commit d4f8638

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

app/models/unit.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,13 +2245,24 @@ def tasks_for_moderation(user)
22452245
if mt.escalation?
22462246
[task, Time.zone.at(0)]
22472247
else
2248-
# Skip automated comments that the tutor did not manually send
2249-
tutor_comments = task.comments.select do |c|
2248+
sorted = task.comments.sort_by(&:created_at)
2249+
2250+
tutor_comments = sorted.select.with_index do |c, i|
2251+
nxt = sorted[i + 1]
2252+
2253+
# Automated comments after a status comment should be filtered out (Overseer test result, corrupt submission)
2254+
# Except for when its been updated due to a prerequisite fix
2255+
is_automated_status =
2256+
c.content_type == "status" &&
2257+
nxt&.content_type == "text" &&
2258+
(nxt.comment&.downcase&.include?("**automated comment**: some tests did not pass") ||
2259+
nxt.comment&.downcase&.include?("**automated comment**: something went wrong with your submission"))
2260+
22502261
c.user == task.tutor &&
22512262
%w[status discussed_in_class text].include?(c.content_type) &&
22522263
(c.content_type != "status" || c.task_status != "time_exceeded") &&
2253-
!c.comment&.include?("**Automated comment**: Some tests did not pass for this submission.") &&
2254-
!c.comment&.include?("**Automated Comment**: Something went wrong with your submission")
2264+
!is_automated_status &&
2265+
!c.comment&.downcase&.include?("**automated comment**:")
22552266
end
22562267

22572268
next nil if tutor_comments.empty?

0 commit comments

Comments
 (0)