My organization wants the courses on the Discover New page to be sorted by the course number, rather than by the standard options (start date or announcement). Previously, I had modified /edx/app/edxapp/edx-platform/common/djangoapps/student/views/management.py and /edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py to use a function I added to /edx/app/edxapp/edx-platform/lms/djangoapps/courseware/courses.py:
def sort_by_display_number(courses):
"""
Sorts a list of courses by their display number (e.g., AI100, GD300)
"""
key = lambda course: course.display_number_with_default
courses = sorted(courses, key=key)
return courses
We recently enabled course discovery, and now the courses on the Discover New page are ordered by their start date again. I assume that’s because course discovery is populating the Discover New page with the results of a query with no search terms.
I have looked around, and I’m wondering if the course_run_sort function in /edx/app/discovery/discovery/course_discovery/apps/course_metadata/models.py controls the sort order returned by course discovery for the Discover New page.
I have two questions:
1- Am I correct that the course_run_sort function is what controls the sort order returned by course discovery on the Discover New page? And if not, what does control the sort order?
2- If so, it seems like I could modify that function to return self.number instead of course_run.start/course_run.enrollment_start. I’m a bit worried though because the comments on number in the Course class say “TODO Remove this field.”
Thank you!
Rebecca