diff --git a/src/components/CourseChecklist/CourseChecklist.test.jsx b/src/components/CourseChecklist/CourseChecklist.test.jsx index 813bf787..a08510aa 100644 --- a/src/components/CourseChecklist/CourseChecklist.test.jsx +++ b/src/components/CourseChecklist/CourseChecklist.test.jsx @@ -54,6 +54,8 @@ const testData = { assignments: { assignments_with_dates_after_end: [], assignments_with_dates_before_start: [], + assignments_with_ora_dates_after_end: [], + assignments_with_ora_dates_before_start: [], }, is_self_paced: true, grades: { diff --git a/src/components/CourseChecklist/index.jsx b/src/components/CourseChecklist/index.jsx index 0d2548a4..407afd4c 100644 --- a/src/components/CourseChecklist/index.jsx +++ b/src/components/CourseChecklist/index.jsx @@ -231,9 +231,23 @@ class CourseChecklist extends React.Component { ); getAssignmentDeadlineCommentSection = () => { - const gradedAssignmentsOutsideDateRange = [].concat( + const allGradedAssignmentsOutsideDateRange = [].concat( this.props.data.assignments.assignments_with_dates_before_start, this.props.data.assignments.assignments_with_dates_after_end, + this.props.data.assignments.assignments_with_ora_dates_before_start, + this.props.data.assignments.assignments_with_ora_dates_after_end, + ); + + // de-dupe in case one assignment has multiple violations + const assignmentsMap = new Map(); + allGradedAssignmentsOutsideDateRange.forEach( + (assignment) => { assignmentsMap.set(assignment.id, assignment); }, + ); + const gradedAssignmentsOutsideDateRange = []; + assignmentsMap.forEach( + (value) => { + gradedAssignmentsOutsideDateRange.push(value); + }, ); const message = ( @@ -297,7 +311,9 @@ class CourseChecklist extends React.Component { Object.keys(this.props.data).length > 0 && ( this.props.data.assignments.assignments_with_dates_before_start.length > 0 || - this.props.data.assignments.assignments_with_dates_after_end.length > 0 + this.props.data.assignments.assignments_with_dates_after_end.length > 0 || + this.props.data.assignments.assignments_with_ora_dates_before_start.length > 0 || + this.props.data.assignments.assignments_with_ora_dates_after_end.length > 0 ) ) @@ -395,6 +411,8 @@ CourseChecklist.propTypes = { total_visible: PropTypes.number, assignments_with_dates_before_start: PropTypes.array, assignments_with_dates_after_end: PropTypes.array, + assignments_with_ora_dates_before_start: PropTypes.array, + assignments_with_ora_dates_after_end: PropTypes.array, }), dates: PropTypes.shape({ has_start_date: PropTypes.bool, diff --git a/src/components/CourseChecklistPage/CourseChecklistPage.test.jsx b/src/components/CourseChecklistPage/CourseChecklistPage.test.jsx index 3e4ec4b0..f069778a 100644 --- a/src/components/CourseChecklistPage/CourseChecklistPage.test.jsx +++ b/src/components/CourseChecklistPage/CourseChecklistPage.test.jsx @@ -283,7 +283,7 @@ describe('CourseChecklistPage', () => { expect(getCourseValidationSpy).toHaveBeenCalledTimes(1); expect(getCourseValidationSpy).toHaveBeenCalledWith( - { graded_only: true }, + { graded_only: true, validate_oras: true }, defaultProps.studioDetails.course, ); }); diff --git a/src/components/CourseChecklistPage/index.jsx b/src/components/CourseChecklistPage/index.jsx index 47caaca0..dccf2334 100644 --- a/src/components/CourseChecklistPage/index.jsx +++ b/src/components/CourseChecklistPage/index.jsx @@ -10,7 +10,10 @@ import WrappedMessage from '../../utils/i18n/formattedMessageWrapper'; export default class CourseChecklistPage extends React.Component { componentDidMount() { this.props.getCourseBestPractices({ exclude_graded: true }, this.props.studioDetails.course); - this.props.getCourseLaunch({ graded_only: true }, this.props.studioDetails.course); + this.props.getCourseLaunch( + { graded_only: true, validate_oras: true }, + this.props.studioDetails.course, + ); } getAriaLiveRegion = (isCourseLaunchChecklistLoading, isCourseBestPracticeChecklistLoading) => { diff --git a/src/utils/CourseChecklist/courseChecklistValidators.js b/src/utils/CourseChecklist/courseChecklistValidators.js index 56828dfe..d9d125d5 100644 --- a/src/utils/CourseChecklist/courseChecklistValidators.js +++ b/src/utils/CourseChecklist/courseChecklistValidators.js @@ -23,6 +23,10 @@ export const hasAssignmentDeadlines = (assignments, dates) => { return false; } else if (assignments.assignments_with_dates_after_end.length > 0) { return false; + } else if (assignments.assignments_with_ora_dates_before_start.length > 0) { + return false; + } else if (assignments.assignments_with_ora_dates_after_end.length > 0) { + return false; } return true; diff --git a/src/utils/CourseChecklist/courseChecklistValidators.test.js b/src/utils/CourseChecklist/courseChecklistValidators.test.js index 5d695747..f8da88d0 100644 --- a/src/utils/CourseChecklist/courseChecklistValidators.test.js +++ b/src/utils/CourseChecklist/courseChecklistValidators.test.js @@ -71,6 +71,8 @@ describe('courseCheckValidators utility functions', () => { { assignments_with_dates_before_start: 0, assignments_with_dates_after_end: 0, + assignments_with_ora_dates_after_end: 0, + assignments_with_ora_dates_before_start: 0, }, { has_start_date: true, @@ -106,6 +108,8 @@ describe('courseCheckValidators utility functions', () => { { assignments_with_dates_before_start: ['test'], assignments_with_dates_after_end: 0, + assignments_with_ora_dates_after_end: 0, + assignments_with_ora_dates_before_start: 0, }, { has_start_date: true, @@ -119,6 +123,8 @@ describe('courseCheckValidators utility functions', () => { { assignments_with_dates_before_start: 0, assignments_with_dates_after_end: ['test'], + assignments_with_ora_dates_after_end: 0, + assignments_with_ora_dates_before_start: 0, }, { has_start_date: true, @@ -128,6 +134,42 @@ describe('courseCheckValidators utility functions', () => { }); }); + it( + 'returns false when a course run has start and end date and an ora with a date before start', + () => { + expect(validators.hasAssignmentDeadlines( + { + assignments_with_dates_before_start: 0, + assignments_with_dates_after_end: 0, + assignments_with_ora_dates_after_end: 0, + assignments_with_ora_dates_before_start: ['test'], + }, + { + has_start_date: true, + has_end_date: true, + }, + )).toEqual(false); + }, + ); + + it( + 'returns false when a course run has start and end date and an ora with a date after end', + () => { + expect(validators.hasAssignmentDeadlines( + { + assignments_with_dates_before_start: 0, + assignments_with_dates_after_end: 0, + assignments_with_ora_dates_after_end: ['test'], + assignments_with_ora_dates_before_start: 0, + }, + { + has_start_date: true, + has_end_date: true, + }, + )).toEqual(false); + }, + ); + describe('hasShortVideoDuration', () => { it('returns true if course run has no videos', () => { expect(validators.hasShortVideoDuration({ total_number: 0 })).toEqual(true);