Skip to content

Commit

Permalink
fix: implement right logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-canon committed Nov 17, 2023
1 parent 989d6b6 commit 83b1d4e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions eox_nelp/edxapp_wrapper/backends/course_overviews_m_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This file contains all the necessary dependencies from
https://github.com/eduNEXT/edunext-platform/tree/master/openedx/core/djangoapps/content/course_overviews
"""
from openedx.core.djangoapps.content.course_overviews.api import get_course_overviews # pylint: disable=import-error
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview # pylint: disable=import-error


Expand All @@ -14,3 +15,13 @@ def get_course_overview_model():
CourseOverview model.
"""
return CourseOverview


def get_course_overviews_method():
"""Allow to get get_course_overviews method from
https://github.com/eduNEXT/edunext-platform/blob/master/openedx/core/djangoapps/content/course_overviews/api.py
Returns:
get_course_overviews method.
"""
return get_course_overviews
2 changes: 2 additions & 0 deletions eox_nelp/edxapp_wrapper/course_overviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Attributes:
backend:Imported module by using the plugin settings.
CourseOverview: Wrapper CourseOverview model.
get_course_overviews: Wrapper of et_course_overviews method.
"""
from importlib import import_module

Expand All @@ -12,3 +13,4 @@
backend = import_module(settings.EOX_NELP_COURSE_OVERVIEWS_BACKEND)

CourseOverview = backend.get_course_overview_model()
get_course_overviews = backend.get_course_overviews_method()
4 changes: 2 additions & 2 deletions eox_nelp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from opaque_keys.edx.keys import CourseKey

from eox_nelp.edxapp_wrapper.course_overviews import CourseOverview
from eox_nelp.edxapp_wrapper.course_overviews import get_course_overviews

NATIONAL_ID_REGEX = r"^[1-2]\d{9}$"
COURSE_ID_REGEX = r'(course-v1:[^/+]+(/|\+)[^/+]+(/|\+)[^/?]+)'
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_course_from_id(course_id):
Course
"""
course_key = CourseKey.from_string(course_id)
course_overviews = CourseOverview.get_from_ids([course_key])
course_overviews = get_course_overviews([course_key])

if course_overviews:
return course_overviews[0]
Expand Down

0 comments on commit 83b1d4e

Please sign in to comment.