Skip to content

Commit

Permalink
refactor: rename learning classes
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 17, 2025
1 parent 60b4f43 commit bd9014a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,7 @@ def create_or_update_xblock_upstream_link(xblock, course_key: str, course_name:
authoring_api.update_or_create_entity_link(
lib_component,
upstream_usage_key=xblock.upstream,
upstream_context_key=str(upstream_usage_key.context_key),
downstream_context_key=course_key,
downstream_context_title=course_name,
downstream_usage_key=str(xblock.usage_key),
Expand Down
14 changes: 7 additions & 7 deletions openedx/core/djangoapps/content_libraries/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
from opaque_keys.edx.locator import BlockUsageLocator
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.lib import ensure_cms
from openedx_learning.api.authoring import get_entity_links, get_or_create_course_link_status
from openedx_learning.api.authoring_models import CourseLinksStatusChoices
from openedx_learning.api.authoring import get_entity_links, get_or_create_learning_context_link_status
from openedx_learning.api.authoring_models import LearningContextLinksStatusChoices
from xmodule.capa_block import ProblemBlock
from xmodule.library_content_block import ANY_CAPA_TYPE_VALUE, LegacyLibraryContentBlock
from xmodule.modulestore import ModuleStoreEnum
Expand Down Expand Up @@ -203,15 +203,15 @@ def create_or_update_upstream_links(course_key_str: str, force: bool = False, cr

if not created:
created = datetime.now(timezone.utc)
course_status = get_or_create_course_link_status(course_key_str, created)
course_status = get_or_create_learning_context_link_status(course_key_str, created)
if course_status.status in [
CourseLinksStatusChoices.COMPLETED,
CourseLinksStatusChoices.PROCESSING
LearningContextLinksStatusChoices.COMPLETED,
LearningContextLinksStatusChoices.PROCESSING
] and not force:
return
store = modulestore()
course_key = CourseKey.from_string(course_key_str)
course_status.status = CourseLinksStatusChoices.PROCESSING
course_status.status = LearningContextLinksStatusChoices.PROCESSING
course_status.save()
try:
course_name = CourseOverview.get_from_id(course_key).display_name_with_default
Expand All @@ -221,7 +221,7 @@ def create_or_update_upstream_links(course_key_str: str, force: bool = False, cr
xblocks = store.get_items(course_key, settings={"upstream": lambda x: x is not None})
for xblock in xblocks:
api.create_or_update_xblock_upstream_link(xblock, course_key_str, course_name, created)
course_status.status = CourseLinksStatusChoices.COMPLETED
course_status.status = LearningContextLinksStatusChoices.COMPLETED
course_status.save()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ def test_create_or_update_upstream_links_task(self, mock_api):
]
assert [(x[0][0].usage_key, x[0][1], x[0][2], x[0][3]) for x in mock_api.call_args_list] == expected_calls
mock_api.reset_mock()
# call again with same course, it should not be processed again as its CourseLinksStatusChoices = COMPLETED
# call again with same course, it should not be processed again
# as its LearningContextLinksStatusChoices = COMPLETED
create_or_update_upstream_links(str(self.course_key), force=False)
mock_api.assert_not_called()
# again with same course but with force=True, it should be processed now
Expand Down

0 comments on commit bd9014a

Please sign in to comment.