Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/api/unit_roles_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class UnitRolesApi < Grape::API
end

action = params[:action].downcase
unless %w[show_more show_less dismiss_ok upheld overturn].include?(action)
unless %w[show_more show_less dismiss_ok upheld overturn snooze].include?(action)
error!({ error: 'Invalid moderation action' }, 400)
end

Expand All @@ -149,7 +149,7 @@ class UnitRolesApi < Grape::API
error!({ error: 'This task is under Feedback Review. Only review actions (upheld or overturn) are allowed. Please refresh the moderation queue.' }, 400)
end
else
unless %w[show_more show_less dismiss_ok].include?(action)
unless %w[show_more show_less dismiss_ok snooze].include?(action)
error!({ error: 'Invalid action for this moderated task. Please refresh moderation queue.' }, 400)
end
end
Expand All @@ -176,6 +176,9 @@ class UnitRolesApi < Grape::API
when 'show_more'
delta = -1
state = :waiting_for_new_feedback
when 'snooze'
delta = 0
state = :waiting_for_new_feedback
when 'show_less'
delta = 1
state = :resolved
Expand Down
57 changes: 31 additions & 26 deletions app/models/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2203,32 +2203,36 @@ def tasks_for_moderation(user)
my_unit_role = unit_role_for(user)
mentees = my_unit_role ? staff.where(mentor_id: my_unit_role.id) : staff.none

tasks = student_tasks
.includes(:comments)
.left_joins(:moderated_task)
.where(moderated_tasks: { state: %i[open waiting_for_new_feedback] })
.where(projects: { unit_id: id })
.joins(:task_definition)
.joins(project: { tutorial_enrolments: :tutorial })
.where('tutorials.tutorial_stream_id = task_definitions.tutorial_stream_id')
.select(
'tasks.id AS task_id',
'tasks.project_id',
'tasks.task_definition_id',
'tutorials.id AS tutorial_id',
'tasks.task_status_id AS status_id',
'tasks.completion_date',
'tasks.submission_date',
'tasks.times_assessed',
'tasks.grade',
'tasks.quality_pts',
'0 AS number_unread',
'0 AS similar_to_count',
'false AS pinned',
'false AS has_extensions',
'tasks.*',
moderated_tasks = ModeratedTask
.where(state: %i[open waiting_for_new_feedback])
.joins(task: [:task_definition, { project: { tutorial_enrolments: :tutorial } }])
.where(tasks: { project_id: projects.select(:id) })
.where('tutorials.tutorial_stream_id = task_definitions.tutorial_stream_id')
.includes(task: :comments)
.distinct

tasks = Task
.joins(:moderated_task)
.merge(moderated_tasks)
.includes(:comments)
.select(
'tasks.id AS task_id',
'tasks.project_id',
'tasks.task_definition_id',
'tutorials.id AS tutorial_id',
'tasks.task_status_id AS status_id',
'tasks.completion_date',
'tasks.submission_date',
'tasks.times_assessed',
'tasks.grade',
'tasks.quality_pts',
'0 AS number_unread',
'0 AS similar_to_count',
'false AS pinned',
'false AS has_extensions',
'tasks.*',
)
.distinct
.distinct

if my_unit_role.nil? || my_unit_role.role != Role.convenor
tasks = tasks.where(tutorials: { unit_role_id: mentees.select(:id) })
Expand Down Expand Up @@ -2256,7 +2260,8 @@ def tasks_for_moderation(user)
c.content_type == "status" &&
nxt&.content_type == "text" &&
(nxt.comment&.downcase&.include?("**automated comment**: some tests did not pass") ||
nxt.comment&.downcase&.include?("**automated comment**: something went wrong with your submission"))
nxt.comment&.downcase&.include?("**automated comment**: something went wrong with your submission") ||
nxt.comment&.downcase&.include?("**automated comment**: a prerequisite task was updated to fix and resubmit"))

c.user == task.tutor &&
%w[status discussed_in_class text].include?(c.content_type) &&
Expand Down