move courses controller todo items to slave
test plan - hit a course home page as teacher and student - should not get an error refs KNO-376 Change-Id: Ieb336e360d2f69ce4653596898a94a89be8797ab Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/232846 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Mysti Lilla <mysti@instructure.com> Reviewed-by: Davis Hyer <dhyer@instructure.com> QA-Review: Davis Hyer <dhyer@instructure.com> Product-Review: Davis Hyer <dhyer@instructure.com>
This commit is contained in:
parent
cb4896bad7
commit
d15fba71e0
|
@ -1205,54 +1205,56 @@ class CoursesController < ApplicationController
|
|||
#
|
||||
# For full documentation, see the API documentation for the user todo items, in the user api.
|
||||
def todo_items
|
||||
get_context
|
||||
if authorized_action(@context, @current_user, :read)
|
||||
bookmark = Plannable::Bookmarker.new(Assignment, false, [:due_at, :created_at], :id)
|
||||
Shackles.activate(:slave) do
|
||||
get_context
|
||||
if authorized_action(@context, @current_user, :read)
|
||||
bookmark = Plannable::Bookmarker.new(Assignment, false, [:due_at, :created_at], :id)
|
||||
|
||||
grading_scope = @current_user.assignments_needing_grading(:contexts => [@context], scope_only: true).
|
||||
reorder(:due_at, :id).preload(:external_tool_tag, :rubric_association, :rubric, :discussion_topic, :quiz, :duplicate_of)
|
||||
submitting_scope = @current_user.
|
||||
assignments_needing_submitting(
|
||||
:contexts => [@context],
|
||||
include_ungraded: true,
|
||||
scope_only: true).
|
||||
reorder(:due_at, :id).preload(:external_tool_tag, :rubric_association, :rubric, :discussion_topic, :quiz).eager_load(:duplicate_of)
|
||||
|
||||
grading_collection = BookmarkedCollection.wrap(bookmark, grading_scope)
|
||||
grading_collection = BookmarkedCollection.transform(grading_collection) do |a|
|
||||
todo_item_json(a, @current_user, session, 'grading')
|
||||
end
|
||||
submitting_collection = BookmarkedCollection.wrap(bookmark, submitting_scope)
|
||||
submitting_collection = BookmarkedCollection.transform(submitting_collection) do |a|
|
||||
todo_item_json(a, @current_user, session, 'submitting')
|
||||
end
|
||||
|
||||
collections = [
|
||||
['grading', grading_collection],
|
||||
['submitting', submitting_collection]
|
||||
]
|
||||
|
||||
if Array(params[:include]).include? 'ungraded_quizzes'
|
||||
quizzes_bookmark = Plannable::Bookmarker.new(Quizzes::Quiz, false, [:due_at, :created_at], :id)
|
||||
quizzes_scope = @current_user.
|
||||
ungraded_quizzes(
|
||||
grading_scope = @current_user.assignments_needing_grading(:contexts => [@context], scope_only: true).
|
||||
reorder(:due_at, :id).preload(:external_tool_tag, :rubric_association, :rubric, :discussion_topic, :quiz, :duplicate_of)
|
||||
submitting_scope = @current_user.
|
||||
assignments_needing_submitting(
|
||||
:contexts => [@context],
|
||||
:needing_submitting => true,
|
||||
:scope_only => true
|
||||
).
|
||||
reorder(:due_at, :id)
|
||||
quizzes_collection = BookmarkedCollection.wrap(quizzes_bookmark, quizzes_scope)
|
||||
quizzes_collection = BookmarkedCollection.transform(quizzes_collection) do |a|
|
||||
include_ungraded: true,
|
||||
scope_only: true).
|
||||
reorder(:due_at, :id).preload(:external_tool_tag, :rubric_association, :rubric, :discussion_topic, :quiz).eager_load(:duplicate_of)
|
||||
|
||||
grading_collection = BookmarkedCollection.wrap(bookmark, grading_scope)
|
||||
grading_collection = BookmarkedCollection.transform(grading_collection) do |a|
|
||||
todo_item_json(a, @current_user, session, 'grading')
|
||||
end
|
||||
submitting_collection = BookmarkedCollection.wrap(bookmark, submitting_scope)
|
||||
submitting_collection = BookmarkedCollection.transform(submitting_collection) do |a|
|
||||
todo_item_json(a, @current_user, session, 'submitting')
|
||||
end
|
||||
|
||||
collections << ['quizzes', quizzes_collection]
|
||||
collections = [
|
||||
['grading', grading_collection],
|
||||
['submitting', submitting_collection]
|
||||
]
|
||||
|
||||
if Array(params[:include]).include? 'ungraded_quizzes'
|
||||
quizzes_bookmark = Plannable::Bookmarker.new(Quizzes::Quiz, false, [:due_at, :created_at], :id)
|
||||
quizzes_scope = @current_user.
|
||||
ungraded_quizzes(
|
||||
:contexts => [@context],
|
||||
:needing_submitting => true,
|
||||
:scope_only => true
|
||||
).
|
||||
reorder(:due_at, :id)
|
||||
quizzes_collection = BookmarkedCollection.wrap(quizzes_bookmark, quizzes_scope)
|
||||
quizzes_collection = BookmarkedCollection.transform(quizzes_collection) do |a|
|
||||
todo_item_json(a, @current_user, session, 'submitting')
|
||||
end
|
||||
|
||||
collections << ['quizzes', quizzes_collection]
|
||||
end
|
||||
|
||||
paginated_collection = BookmarkedCollection.merge(*collections)
|
||||
todos = Api.paginate(paginated_collection, self, api_v1_course_todo_list_items_url)
|
||||
|
||||
render :json => todos
|
||||
end
|
||||
|
||||
paginated_collection = BookmarkedCollection.merge(*collections)
|
||||
todos = Api.paginate(paginated_collection, self, api_v1_course_todo_list_items_url)
|
||||
|
||||
render :json => todos
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue