Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
def _filter_by_search(course_queryset, search_term):
    """
    Filters a course queryset by the specified search term.
    """
    if not settings.FEATURES['ENABLE_COURSEWARE_SEARCH'] or not search_term:
        return course_queryset

    # Return all the results, 10K is the maximum allowed value for ElasticSearch.
    # We should use 0 after upgrading to 1.1+:
    #   - https://github.com/elastic/elasticsearch/commit/8b0a863d427b4ebcbcfb1dcd69c996c52e7ae05e
    results_size_infinity = 10000

    search_courses = search.api.course_discovery_search(
        search_term,
        size=results_size_infinity,
    )

    search_courses_ids = {course['data']['id'] for course in search_courses['results']}
    courses = [course for course in course_queryset if str(course.id) in search_courses_ids]
    return LazySequence(
        iter(courses),
        est_len=len(courses)
    )

...

A new endpoint to get the course home data

The endpoint should extend BlocksInCourseView

...

https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/course_api/blocks/views.py#L253

TBD

CourseDetailView

https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/course_api/views.py#L23

TBD

Solution:

...

, and add more data about a course as media, course dates, certificate etc.

Solution:

This endpoint can be added into mobile_api LMS application. In the future, this endpoint can be extended to be a course home endpoint for a mobile.

Example response:
BlocksInCourseView response +

Code Block
"id": "course-v1:test+test1+test1_247",
"name": "test1",
"number": "test1",
"org": "test",
"start": "2022-05-30T00:00:00Z",
"start_display": "May 30, 2022",
"start_type": "timestamp",
"end": "2022-08-28T00:00:00Z",
"media": {
   "image": {
       "raw": "/asset-v1:test+test1+test1_247+type@asset+block@images_course_image.jpg",
        response['certificate_available_date'] = instance.certificate_available_date"small": "/asset-v1:test+test1+test1_247+type@asset+block@images_course_image.jpg",
       "large":  # Add code
    if self.context['request'].user.is_authenticated:
          response['is_enrolled'] = CourseEnrollment.is_enrolled(self.context['request'].user, instance. id)

    return response"/asset-v1:test+test1+test1_247+type@asset+block@images_course_image.jpg"
   }
},
"certificate": {
   "url": "http://localhost:18000/certificates/61630ecf103c4afaa50ff2dd275ab5cf"
},
"is_self_paced": false

...

A new endpoint to return about course information

This view can be based on the CourseDetailView and CourseHomeMetadataView, but additionally should provide if user is enrolled to the course or not (maybe if user has some specific visibility conditions.

Solution:

Add a new endpoint into mobile_api LMS application. URL for the new endpoint /mobile/{api_version}/course_info/{course_id}