Make todo api work for past due todos
Refs MBL-10173 Test Plan: - Regression test the test plans from the following two commits https://gerrit.instructure.com/#/c/134699/ https://gerrit.instructure.com/#/c/140671/ - Create an assignment that is due in the future (less than 1 week) and requires submission - Create an assignment that is past due (less than 4 weeks) and requires submission - Create an assignment in the future (less than 1 week) that does not requires submission - Create an assignment that is past due (less than 4 weeks) and does not require submission - As a student in that course hit /api/v1/users/self/todo - The student should have 3 todos - the assignment due in the future that requires submission - the assignment due in the past that requires submission - the assignment due in the future that does not require submission - The student should not see a todo for the past due assignment not requiring submission Change-Id: If097f4da041583e0a5a8b1ada8c4fadabed2bfa5 Reviewed-on: https://gerrit.instructure.com/147768 Reviewed-by: Mysti Sadler <mysti@instructure.com> Tested-by: Jenkins QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Matthew Sessions <msessions@instructure.com>
This commit is contained in:
parent
c2255eb0fd
commit
2b201e7bb4
|
@ -1085,7 +1085,6 @@ class CoursesController < ApplicationController
|
|||
include_ungraded: true,
|
||||
limit: ToDoListPresenter::ASSIGNMENT_LIMIT,
|
||||
scope_only: true).
|
||||
where('assignments.due_at IS NULL OR assignments.due_at > ?', Time.zone.now).
|
||||
reorder(:due_at, :id)
|
||||
|
||||
grading_collection = BookmarkedCollection.wrap(bookmark, grading_scope)
|
||||
|
@ -1110,7 +1109,6 @@ class CoursesController < ApplicationController
|
|||
:needing_submitting => true,
|
||||
:scope_only => true
|
||||
).
|
||||
where('quizzes.due_at IS NULL OR quizzes.due_at > ?', Time.zone.now).
|
||||
reorder(:due_at, :id)
|
||||
quizzes_collection = BookmarkedCollection.wrap(quizzes_bookmark, quizzes_scope)
|
||||
quizzes_collection = BookmarkedCollection.transform(quizzes_collection) do |a|
|
||||
|
|
|
@ -839,9 +839,7 @@ class UsersController < ApplicationController
|
|||
assignments_needing_submitting(
|
||||
include_ungraded: true,
|
||||
limit: ToDoListPresenter::ASSIGNMENT_LIMIT,
|
||||
scope_only: true
|
||||
).
|
||||
where('assignments.due_at IS NULL OR assignments.due_at > ?', Time.zone.now).
|
||||
scope_only: true).
|
||||
reorder(:due_at, :id)
|
||||
|
||||
grading_collection = BookmarkedCollection.wrap(bookmark, grading_scope)
|
||||
|
@ -864,7 +862,6 @@ class UsersController < ApplicationController
|
|||
:needing_submitting => true,
|
||||
:scope_only => true
|
||||
).
|
||||
where('quizzes.due_at IS NULL OR quizzes.due_at >= ?', Time.zone.now).
|
||||
reorder(:due_at, :id)
|
||||
quizzes_collection = BookmarkedCollection.wrap(quizzes_bookmark, quizzes_scope)
|
||||
quizzes_collection = BookmarkedCollection.transform(quizzes_collection) do |a|
|
||||
|
|
|
@ -112,6 +112,7 @@ module UserLearningObjectScopes
|
|||
objects_needing('Assignment', purpose, :student, cache_timeout, opts) do |assignment_scope, options|
|
||||
assignments = assignment_scope.due_between_for_user(options[:due_after], options[:due_before], self)
|
||||
assignments = assignments.need_submitting_info(id, options[:limit]) if purpose == 'submitting'
|
||||
assignments = assignments.submittable.or(assignments.where('due_at > ?', Time.zone.now)) if purpose == 'submitting'
|
||||
assignments = assignments.having_submissions_for_user(id) if purpose == 'submitted'
|
||||
assignments = assignments.not_locked unless options[:include_locked]
|
||||
assignments
|
||||
|
@ -124,9 +125,7 @@ module UserLearningObjectScopes
|
|||
opts[:cache_timeout] = 15.minutes
|
||||
assignments = assignments_for_student('submitting', opts)
|
||||
return assignments if opts[:scope_only]
|
||||
select_available_assignments(assignments, opts).reject do |a|
|
||||
a.due_at && a.due_at < Time.zone.now && !a.expects_submission?
|
||||
end
|
||||
select_available_assignments(assignments, opts)
|
||||
end
|
||||
|
||||
def submitted_assignments(opts={})
|
||||
|
|
|
@ -248,6 +248,21 @@ describe UsersController, type: :request do
|
|||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "doesnt include anything over 4 weeks old" do
|
||||
@student_course.assignments.create! due_at: 5.weeks.ago, workflow_state: 'published', submission_types: 'not_graded'
|
||||
past_survey = @student_course.quizzes.create!(quiz_type: 'survey', due_at: 5.weeks.ago)
|
||||
past_survey.publish!
|
||||
|
||||
json = api_call :get, "/api/v1/users/self/todo?include[]=ungraded_quizzes", :controller => "users",
|
||||
:action => "todo_items", :format => "json", :include => %w(ungraded_quizzes)
|
||||
expect(json.map { |el| el['quiz'] && el['quiz']['id'] }.compact).to eql([])
|
||||
|
||||
json = api_call :get, "/api/v1/courses/#{@student_course.id}/todo?include[]=ungraded_quizzes",
|
||||
:controller => "courses", :action => "todo_items",
|
||||
:format => "json", :course_id => @student_course.to_param, :include => %w(ungraded_quizzes)
|
||||
expect(json.map { |el| el['quiz'] && el['quiz']['id'] }.compact).to eql([])
|
||||
end
|
||||
|
||||
context 'when the assignment is differentiated/ has overrides' do
|
||||
before :each do
|
||||
@course = course_factory(active_all: true)
|
||||
|
@ -256,7 +271,7 @@ describe UsersController, type: :request do
|
|||
@user = user_factory(active_all: true)
|
||||
@course.enroll_student(@user, { :section => @section }).accept!
|
||||
|
||||
ao = differentiated_assignment(:context => @course, :course_section => @section, :due_at => nil)
|
||||
ao = differentiated_assignment(:context => @course, :course_section => @section, :due_at => nil, :submission_types => 'online_text_entry')
|
||||
ao.due_at = 1.day.from_now
|
||||
ao.due_at_overridden = true
|
||||
ao.save!
|
||||
|
|
Loading…
Reference in New Issue