Respect section start/end dates when outside of course dates
if a section has a start date before the course start date, or and end date after a course end date, then dates in those ranges should still be valid, even when 'Students can only participate in the course between these dates' is not checked closes LX-2085 flag=none test plan: - create a course with at least one section - add a start date and end date to the course. - add a start date to the section that is before the course start date. - add an end date to the section that is after the course end date. - do not check 'Students can only participate in the course between these dates' - create a learning object and add dates to the section. Assign a date that is before the course start but not before the section start. The date should be valid. - assign a date that is after course end but not after section end. the date should be valid. - dates outside of the section's dates should still be invalid. - change the start/end dates of the section so the start date is after course start date and the end date is before the course end date. - ensure that you can still assign the section to dates within the course start/end dates even if they are outside the section dates. Change-Id: I274c5d09f2f2831e403091d0cb53c51bd1dd1036 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/361783 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Drake Harper <drake.harper@instructure.com> QA-Review: Drake Harper <drake.harper@instructure.com> Product-Review: Sarah Gerard <sarah.gerard@instructure.com>
This commit is contained in:
parent
ea3df97136
commit
5f092e96a2
|
@ -236,16 +236,25 @@ export default class DateValidator {
|
|||
}
|
||||
|
||||
getSectionRange(section) {
|
||||
if (!section.override_course_and_term_dates) return this.dateRange
|
||||
|
||||
const dateRange = {...this.dateRange}
|
||||
if (section.start_at) {
|
||||
const override_course_dates = section.override_course_and_term_dates
|
||||
// if !override_course_dates, then use the earlier start date and the later end date
|
||||
// if override_course_dates, then use the section start and end dates
|
||||
if (
|
||||
section.start_at &&
|
||||
(override_course_dates ||
|
||||
this._formatDatetime(section.start_at) < this._formatDatetime(dateRange.start_at.date))
|
||||
) {
|
||||
dateRange.start_at = {
|
||||
date: section.start_at,
|
||||
date_context: 'section',
|
||||
}
|
||||
}
|
||||
if (section.end_at) {
|
||||
if (
|
||||
section.end_at &&
|
||||
(override_course_dates ||
|
||||
this._formatDatetime(section.end_at) > this._formatDatetime(dateRange.end_at.date))
|
||||
) {
|
||||
dateRange.end_at = {
|
||||
date: section.end_at,
|
||||
date_context: 'section',
|
||||
|
|
|
@ -384,6 +384,12 @@ describe('section dates', () => {
|
|||
end_at: null,
|
||||
override_course_and_term_dates: null,
|
||||
},
|
||||
{
|
||||
id: 678,
|
||||
start_at: '2020-03-01T00:00:00Z',
|
||||
end_at: '2020-08-01T00:00:00Z',
|
||||
override_course_and_term_dates: false,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
@ -492,4 +498,25 @@ describe('section dates', () => {
|
|||
const validator = makeIndividualValidator()
|
||||
expect(isValid(validator, data)).toBe(false)
|
||||
})
|
||||
|
||||
test('allows a lock date after the course end date if it is before the section end date', () => {
|
||||
const data = generateData({
|
||||
lock_at: '2020-07-01T00:00:00Z',
|
||||
student_ids: null,
|
||||
course_section_id: 678,
|
||||
})
|
||||
const validator = makeIndividualValidator({termEnd: '2020-06-01T00:00:00Z'})
|
||||
expect(isValid(validator, data)).toBe(true)
|
||||
})
|
||||
|
||||
test('allows an unlock date before the course start date if it is after the section start date', () => {
|
||||
const data = generateData({
|
||||
unlock_at: '2020-05-01T00:00:00Z',
|
||||
due_at: '2020-06-01T00:00:00Z',
|
||||
student_ids: null,
|
||||
course_section_id: 678,
|
||||
})
|
||||
const validator = makeIndividualValidator({termStart: '2020-07-01T00:00:00Z'})
|
||||
expect(isValid(validator, data)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue