End plan on a friday if course ends on a skipped weekend

closes LS-3074
flag=course_paces

test plan:
  - Create a course with course pace enabled
  - In settings set course start on April 4, 2022 and
    end on Monday May 2, 2022. This effectively ends
    the course at fancy midnight Sunday May 1.
  - Create a module with 3 assignments
  - go to the course pacing page
  - in the course pace,  skip weekends.
  - Set the 3 durations to 1, 2, 30 so it has to compress
  > expect the last assignment's due date to be the Friday
    before the pace end date

Change-Id: I6229df7c9894c035774b33c39fff69e6833e6ab1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/288705
Reviewed-by: Robin Kuss <rkuss@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Ed Schiebel <eschiebel@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Ed Schiebel 2022-04-01 10:10:49 -04:00
parent b18f6212d2
commit 2e6fc2a474
2 changed files with 16 additions and 0 deletions

View File

@ -36,6 +36,16 @@ class CoursePaceHardEndDateCompressor
start_date_of_item_group = start_date || enrollment&.start_at || course_pace.start_date
end_date = course_pace.end_date || course_pace.course.end_at&.to_date || course_pace.course.enrollment_term&.end_at&.to_date
# when due dates run over and the end date is on a weekend, the adjustment to due dates
# is off by a day. Pull the end_date back to the previous friday.
if end_date && course_pace.exclude_weekends
wday = end_date.wday
if wday == 0 # sunday
end_date -= 2.days
elsif wday == 6 # saturday
end_date -= 1.day
end
end
due_dates = CoursePaceDueDatesCalculator.new(course_pace).get_due_dates(items, enrollment, start_date: start_date_of_item_group)
if compress_items_after

View File

@ -82,6 +82,12 @@ describe CoursePaceHardEndDateCompressor do
compressed = CoursePaceHardEndDateCompressor.compress(@course_pace, @course_pace.course_pace_module_items)
expect(compressed.pluck(:duration)).to eq([1, 1, 2])
end
it "considers the end date the previous Friday if it falls on the weekend" do
@course.update(conclude_at: "2022-01-02") # Sunday
compressed = CoursePaceHardEndDateCompressor.compress(@course_pace, @course_pace.course_pace_module_items)
expect(compressed.pluck(:duration)).to eq([1, 1, 2])
end
end
end