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:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user