edx-platform
edx-platform copied to clipboard
feat: add hasUnmetPrerequisitesList in CoursewareAccessSerializer
Description
This pull request enhances the prerequisite course serialization in the learner home API by adding a new field that provides detailed information about unmet prerequisites. It introduces a new serializer method to return a list of prerequisite courses not yet completed, including their display names and URLs, and adds corresponding unit tests to ensure correct behavior.
Prerequisite course serialization improvements:
- Added a new serializer field
hasUnmetPrerequisitesListtoCoursewareAccessSerializer, which returns detailed info for each unmet prerequisite course, including display name, course home URL, and about page URL. [1] [2] - Implemented the helper method
_get_course_about_url_for_keyto reliably generate the course about page URL, handling cases where the course overview does not exist.
Testing enhancements:
- Added unit tests to verify that
hasUnmetPrerequisitesListreturns an empty list when there are no unmet prerequisites and correctly serializes prerequisite course info when present.
Dependency and import updates:
- Imported new helper functions and models (
get_link_for_about_page,get_pre_requisite_courses_not_completed,CourseOverview) to support the new functionality.
Supporting information
https://github.com/openedx/frontend-app-learner-dashboard/issues/753
Testing instructions
- Create a simple course in Studio.
- Go to "Advanced settings" and set "Enable subsection prerequisites" ON (true).
- Go to "Schedule & details" and set in "Prerequisite course" whatever you want.
- Check the
/api/learner_home/initendpoint. Locate your created course and find the attributehasUnmetPrerequisitesList. You will see the following information:
"hasUnmetPrerequisitesList": [
{
"display": "PruebaReq1 PruebaReq1",
"url": "http://apps.local.openedx.io:2000/learning/course/course-v1:PruebaReq1+PruebaReq1+PruebaReq1/home",
"about_url": "http://local.openedx.io:8000/courses/course-v1:PruebaReq1+PruebaReq1+PruebaReq1/about"
},
{
"display": "Another Course Another Org",
"about_url": "https://google.com/"
}
]
Deadline
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.