feat: reindex course and recreate upstream links post import and course re-run (#37237)

Index the newly created course after import and course re-run. Also recreate upstream links after course re-run.

We make use of newly created COURSE_RERUN_COMPLETED signal to run post re-run processes.
This commit is contained in:
Navin Karkera
2025-08-21 23:45:55 +05:30
committed by GitHub
parent d132efa08d
commit 617b6447cc
9 changed files with 80 additions and 34 deletions

View File

@@ -23,6 +23,7 @@ from openedx_events.content_authoring.data import (
from openedx_events.content_authoring.signals import (
COURSE_CATALOG_INFO_CHANGED,
COURSE_IMPORT_COMPLETED,
COURSE_RERUN_COMPLETED,
LIBRARY_BLOCK_DELETED,
LIBRARY_CONTAINER_DELETED,
XBLOCK_CREATED,
@@ -304,10 +305,10 @@ def delete_upstream_downstream_link_handler(**kwargs):
).delete()
@receiver(COURSE_IMPORT_COMPLETED)
def handle_new_course_import(**kwargs):
@receiver([COURSE_IMPORT_COMPLETED, COURSE_RERUN_COMPLETED])
def handle_upstream_links_on_signal(**kwargs):
"""
Automatically create upstream->downstream links for course in database on new import.
Automatically create upstream->downstream links for course in database on new import or rerun.
"""
course_data = kwargs.get("course", None)
if not course_data or not isinstance(course_data, CourseData):

View File

@@ -35,6 +35,8 @@ from olxcleaner.reporting import report_error_summary, report_errors
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey
from opaque_keys.edx.locator import LibraryContainerLocator, LibraryLocator, BlockUsageLocator
from openedx_events.content_authoring.data import CourseData
from openedx_events.content_authoring.signals import COURSE_RERUN_COMPLETED
from organizations.api import add_organization_course, ensure_organization
from organizations.exceptions import InvalidOrganizationException
from organizations.models import Organization
@@ -176,6 +178,12 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
# update state: Succeeded
CourseRerunState.objects.succeeded(course_key=destination_course_key)
COURSE_RERUN_COMPLETED.send_event(
time=datetime.now(timezone.utc),
course=CourseData(
course_key=destination_course_key
)
)
# call edxval to attach videos to the rerun
copy_course_videos(source_course_key, destination_course_key)