Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: date label for instructor paced courses #36061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor

@asadali145 asadali145 Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have an impact on 2 cases:

  • Instructor-paced course with past dates:
    • Course Starts replaced by Enrollment Date
  • Self Paced course with start date in past and end date in future:
    • 'Course Starts' replaced by Enrollment Date, Regardless of user enrollment. If user is not enrolled and you visit dates tab, it will display Enrollment Date label

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. It displayed the wrong label due to cache.

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
Loading