diff --git a/app/api/unit_roles_api.rb b/app/api/unit_roles_api.rb index 65ab5aca4..ff0d9f900 100644 --- a/app/api/unit_roles_api.rb +++ b/app/api/unit_roles_api.rb @@ -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 @@ -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 @@ -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 diff --git a/app/models/unit.rb b/app/models/unit.rb index c7fa82766..e0b082817 100644 --- a/app/models/unit.rb +++ b/app/models/unit.rb @@ -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) }) @@ -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) &&