Skip to content

Commit

Permalink
feat: integrate openedx-search-api
Browse files Browse the repository at this point in the history
  • Loading branch information
qasimgulzar authored and qasimgulzar committed Aug 13, 2024
1 parent 13fe121 commit dc174f0
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Courseware Content Classes
"""
import logging

from opaque_keys.edx.keys import CourseKey
Expand All @@ -11,6 +14,12 @@

class CoursewareContent:
def prepare_data(self, item, structure_key):
"""
Prepares data structure.
:param item:
:param structure_key:
:return:
"""
location_info = {
"course": str(structure_key),
"org": structure_key.org,
Expand All @@ -27,6 +36,12 @@ def prepare_data(self, item, structure_key):
return [_index_dictionary] + children

def fetch_course_blocks(self, modulestore, course_key):
"""
Extracts data from module store.
:param modulestore:
:param course_key:
:return:
"""
blocks = []
with modulestore.branch_setting(ModuleStoreEnum.RevisionOption.published_only):
structure = modulestore.get_course(course_key, depth=None)
Expand All @@ -35,7 +50,14 @@ def fetch_course_blocks(self, modulestore, course_key):
blocks.extend(self.prepare_data(item, course_key))
return blocks

def fetch(self, course_key=None, *args, **kwargs):
def fetch(self, *args, course_key=None, **kwargs):
"""
Returns data for indexing.
:param course_key:
:param args:
:param kwargs:
:return:
"""
modulestore = ModuleStore()
if not course_key:
course_keys = CourseOverview.objects.values_list('id', flat=True)
Expand Down

0 comments on commit dc174f0

Please sign in to comment.