make "Upcoming Assignments" lists vdd aware
fixes CNVS-1220 test plan when checking for an assignment listed as upcoming, check: - the "Coming Up" sidebar on the right of the user's or course's "Recent Activity" page - the "Upcoming Assignments" sidebar on the right of the user's or course's Assignments page - the "Upcoming Assignments" section on the main listing on the user's or course's Assignments page ensure assignments can be overridden to be upcoming - create an assignment that is due more than one week from now - as a student, ensure the assignment is not listed as upcoming - create an override that applies to the student that makes the assignment's due date less than one week from now - As a student, ensure that the assignment is listed as upcoming ensure assignments can be overridden to not be upcoming - create an assignment that is due less than one week from now - as a student, ensure the assignment is listed as upcoming - create an override that applies to the student that makes the assignment's due date more than one week from now - As a student, ensure that the assignment is not listed as upcoming Change-Id: Ia517d87f0a8ed48f6ce3ca466258e7ad8ebe650c Reviewed-on: https://gerrit.instructure.com/17168 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Stanley Stuart <stanley@instructure.com> QA-Review: Marc LeGendre <marc@instructure.com>
This commit is contained in:
parent
358ad26203
commit
5dfe5bc96f
|
@ -511,7 +511,8 @@ class ApplicationController < ActionController::Base
|
|||
@submissions = @current_user.try(:submissions).to_a
|
||||
@submissions.each{ |s| s.mute if s.muted_assignment? }
|
||||
|
||||
sorted_by_vdd = SortsAssignments.by_varied_due_date({
|
||||
@assignments.map! {|a| a.overridden_for(@current_user)}
|
||||
sorted = SortsAssignments.by_due_date({
|
||||
:assignments => @assignments,
|
||||
:user => @current_user,
|
||||
:session => session,
|
||||
|
@ -519,12 +520,12 @@ class ApplicationController < ActionController::Base
|
|||
:submissions => @submissions
|
||||
})
|
||||
|
||||
@past_assignments = sorted_by_vdd.past
|
||||
@undated_assignments = sorted_by_vdd.undated
|
||||
@ungraded_assignments = sorted_by_vdd.ungraded
|
||||
@upcoming_assignments = sorted_by_vdd.upcoming
|
||||
@future_assignments = sorted_by_vdd.future
|
||||
@overdue_assignments = sorted_by_vdd.overdue
|
||||
@past_assignments = sorted.past
|
||||
@undated_assignments = sorted.undated
|
||||
@ungraded_assignments = sorted.ungraded
|
||||
@upcoming_assignments = sorted.upcoming
|
||||
@future_assignments = sorted.future
|
||||
@overdue_assignments = sorted.overdue
|
||||
|
||||
condense_assignments if requesting_main_assignments_page?
|
||||
|
||||
|
|
|
@ -1811,7 +1811,14 @@ class User < ActiveRecord::Base
|
|||
opts[:limit] ||= 20
|
||||
|
||||
events = CalendarEvent.active.for_user_and_context_codes(self, context_codes).between(Time.now.utc, opts[:end_at]).scoped(:limit => opts[:limit]).reject(&:hidden?)
|
||||
events += Assignment.active.for_context_codes(context_codes).due_between(Time.now.utc, opts[:end_at]).scoped(:limit => opts[:limit]).include_submitted_count
|
||||
events += Assignment.
|
||||
active.
|
||||
for_context_codes(context_codes).
|
||||
due_between_with_overrides(Time.now.utc, opts[:end_at]).
|
||||
include_submitted_count.
|
||||
map {|a| a.overridden_for(self)}.
|
||||
select {|a| a.due_at >= Time.now.utc && a.due_at <= opts[:end_at]}.
|
||||
first(opts[:limit])
|
||||
appointment_groups = AppointmentGroup.manageable_by(self, context_codes).intersecting(Time.now.utc, opts[:end_at]).scoped(:limit => opts[:limit])
|
||||
appointment_groups.each { |ag| ag.context = ag.contexts_for_user(self).first }
|
||||
events += appointment_groups
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class SortsAssignments
|
||||
|
||||
AssignmentsSortedByVariedDueDate = Struct.new(
|
||||
AssignmentsSortedByDueDate = Struct.new(
|
||||
:past,
|
||||
:overdue,
|
||||
:undated,
|
||||
|
@ -9,38 +9,23 @@ class SortsAssignments
|
|||
:future
|
||||
)
|
||||
|
||||
def self.by_varied_due_date(opts)
|
||||
def self.by_due_date(opts)
|
||||
assignments = opts.fetch( :assignments )
|
||||
user = opts.fetch( :user )
|
||||
session = opts.fetch( :session )
|
||||
submissions = opts.fetch( :submissions )
|
||||
upcoming_limit = opts[:upcoming_limit] || 1.week.from_now
|
||||
|
||||
vdd_assignments = vdd_map(assignments, user)
|
||||
past_assignments = past(vdd_assignments)
|
||||
undated_assignments = undated(vdd_assignments)
|
||||
ungraded_assignments = ungraded_for_user_and_session(assignments, user, session)
|
||||
upcoming_assignments = upcoming(vdd_assignments, upcoming_limit)
|
||||
future_assignments = future(vdd_assignments)
|
||||
overdue_assignments = overdue(assignments, user, session, submissions)
|
||||
|
||||
AssignmentsSortedByVariedDueDate.new(
|
||||
select_originals(assignments, past_assignments),
|
||||
select_originals(assignments, overdue_assignments),
|
||||
select_originals(assignments, undated_assignments),
|
||||
ungraded_assignments,
|
||||
select_originals(assignments, upcoming_assignments),
|
||||
select_originals(assignments, future_assignments)
|
||||
AssignmentsSortedByDueDate.new(
|
||||
past(assignments),
|
||||
overdue(assignments, user, session, submissions),
|
||||
undated(assignments),
|
||||
ungraded_for_user_and_session(assignments, user, session),
|
||||
upcoming(assignments, upcoming_limit),
|
||||
future(assignments)
|
||||
)
|
||||
end
|
||||
|
||||
def self.vdd_map(assignments, user)
|
||||
assignments ||= []
|
||||
assignments.map do |assignment|
|
||||
assignment.overridden_for(user)
|
||||
end
|
||||
end
|
||||
|
||||
def self.past(assignments)
|
||||
assignments ||= []
|
||||
dated(assignments).select{ |assignment| assignment.due_at < Time.now }
|
||||
|
@ -65,11 +50,6 @@ class SortsAssignments
|
|||
assignments - past(assignments)
|
||||
end
|
||||
|
||||
def self.select_originals(original, vdd_map)
|
||||
vdd_map_keys = vdd_map.map{ |assignment| assignment.id }
|
||||
original.select { |assignment| vdd_map_keys.include?(assignment.id) }
|
||||
end
|
||||
|
||||
def self.up_to(assignments, time)
|
||||
dated(assignments).select{ |assignment| assignment.due_at < time }
|
||||
end
|
||||
|
|
|
@ -68,41 +68,6 @@ describe SortsAssignments do
|
|||
end
|
||||
end
|
||||
|
||||
describe "vdd_map" do
|
||||
|
||||
it "returns a new array of overridden assignments" do
|
||||
user = stub
|
||||
varied_due_date = 2.days.from_now
|
||||
assignment_ids = assignments.map(&:id)
|
||||
assignments.each do |assignment|
|
||||
assignment.expects(:due_at).returns(varied_due_date)
|
||||
assignment.expects(:overridden_for).returns(assignment)
|
||||
end
|
||||
|
||||
SortsAssignments.vdd_map(assignments,user).reject{ |assignment|
|
||||
assignment_ids.include?(assignment.id) &&
|
||||
assignment.due_at == varied_due_date
|
||||
}.size.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "select_originals" do
|
||||
|
||||
it "returns the assignments where the id matches the id in vdd_map" do
|
||||
vdd_map =
|
||||
[
|
||||
stub( :id => due_yesterday.id ),
|
||||
stub( :id => due_today.id )
|
||||
]
|
||||
SortsAssignments.select_originals(assignments,vdd_map).should =~
|
||||
[
|
||||
due_yesterday,
|
||||
due_today
|
||||
]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "up_to" do
|
||||
|
||||
it "gives all the assignments due before the given time" do
|
||||
|
@ -183,12 +148,12 @@ describe SortsAssignments do
|
|||
|
||||
end
|
||||
|
||||
describe "by_varied_due_date" do
|
||||
describe "by_due_date" do
|
||||
let(:user) { stub }
|
||||
let(:session) { stub }
|
||||
let( :submissions ) { [] }
|
||||
let(:sorted_assignments) {
|
||||
SortsAssignments.by_varied_due_date({
|
||||
SortsAssignments.by_due_date({
|
||||
:assignments => assignments,
|
||||
:user => user,
|
||||
:session => session,
|
||||
|
@ -198,7 +163,7 @@ describe SortsAssignments do
|
|||
}
|
||||
|
||||
it "raises an IndexError if a required field is not passed" do
|
||||
lambda { SortsAssignments.by_varied_due_date({}) }.
|
||||
lambda { SortsAssignments.by_due_date({}) }.
|
||||
should raise_error IndexError
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue