Skip to content

Commit

Permalink
fix: date label for instructor paced courses
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas12091101 committed Jan 10, 2025
1 parent 5ae7187 commit 0e81db7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/date_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def date_type(self):
@property
def title(self):
enrollment = CourseEnrollment.get_enrollment(self.user, self.course_id)
if enrollment and self.course.end and enrollment.created > self.course.end:
if self.course.self_paced and enrollment and self.course.start and enrollment.created > self.course.start:
return gettext_lazy('Enrollment Date')
return gettext_lazy('Course starts')

Expand Down
31 changes: 31 additions & 0 deletions lms/djangoapps/courseware/tests/test_date_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,37 @@ def test_course_start_date(self):
block = CourseStartDate(course, user)
assert block.date == course.start

@ddt.data(
# Instructor-paced course: Use course start date
(False, datetime(2025, 1, 10, tzinfo=utc), datetime(2025, 1, 12, tzinfo=utc),
datetime(2025, 1, 10, tzinfo=utc), 'Course starts'),
# Self-paced course: Enrollment created later than course start
(True, datetime(2025, 1, 10, tzinfo=utc), datetime(2025, 1, 12), datetime(2025, 1, 12, tzinfo=utc),
'Enrollment Date'),
# Self-paced course: Enrollment created earlier than course start
(True, datetime(2025, 1, 10, tzinfo=utc), datetime(2025, 1, 8), datetime(2025, 1, 10, tzinfo=utc),
'Course starts'),
# Self-paced course: No enrollment
(True, datetime(2025, 1, 10, tzinfo=utc), None, datetime(2025, 1, 10, tzinfo=utc), 'Course starts'),
)
@ddt.unpack
def test_course_start_date_label(self, self_paced, course_start, enrollment_created, expected_date, expected_title):
"""
Test the CourseStartDate class has correct label for course start date
"""
course = CourseFactory(self_paced=self_paced, start=course_start)
user = create_user()
if enrollment_created:
enrollment = CourseEnrollmentFactory(course_id=course.id, user=user, mode=CourseMode.VERIFIED)
enrollment.created = enrollment_created
enrollment.save()
date_summary = CourseStartDate(user=user, course=course)
self.assertEqual(date_summary.date, expected_date)
self.assertEqual(str(date_summary.title), expected_title)

## Tests Course End Date Block
def test_course_end_date_for_certificate_eligible_mode(self):
course = create_course_run(days_till_start=-1)
Expand Down

0 comments on commit 0e81db7

Please sign in to comment.