def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable=unused-argument """ Receives publishing signal and performs publishing related workflows, such as registering proctored exams, building up credit requirements, and performing search indexing """ # first is to registered exams, the credit subsystem will assume that # all proctored exams have already been registered, so we have to do that first try: register_special_exams(course_key) # pylint: disable=broad-except except Exception as exception: log.exception(exception) # then call into the credit subsystem (in /openedx/djangoapps/credit) # to perform any 'on_publish' workflow on_course_publish(course_key) # Finally call into the course search subsystem # to kick off an indexing action if CoursewareSearchIndexer.indexing_is_enabled(): # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded from cms.djangoapps.contentstore.tasks import update_search_index update_search_index.delay(six.text_type(course_key), datetime.now(UTC).isoformat())
def update_special_exams_and_publish(course_key_str): """ Registers special exams for a given course and calls publishing flow. on_course_publish expects that the edx-proctoring subsystem has been refreshed before being executed, so both functions are called here synchronously. """ from cms.djangoapps.contentstore.proctoring import register_special_exams from openedx.core.djangoapps.credit.signals import on_course_publish course_key = CourseKey.from_string(course_key_str) LOGGER.info('Attempting to register exams for course %s', course_key_str) try: register_special_exams(course_key) LOGGER.info('Successfully registered exams for course %s', course_key_str) # pylint: disable=broad-except except Exception as exception: LOGGER.exception(exception) LOGGER.info('Publishing course %s', course_key_str) on_course_publish(course_key)
def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable=unused-argument """ Receives publishing signal and performs publishing related workflows, such as registering proctored exams, building up credit requirements, and performing search indexing """ is_enabled = ENABLE_ASYNC_REGISTER_EXAMS.is_enabled(course_key) if is_enabled: from cms.djangoapps.contentstore.tasks import update_special_exams_and_publish course_key_str = str(course_key) update_special_exams_and_publish.delay(course_key_str) else: # first is to registered exams, the credit subsystem will assume that # all proctored exams have already been registered, so we have to do that first try: register_special_exams(course_key) # pylint: disable=broad-except except Exception as exception: log.exception(exception) # then call into the credit subsystem (in /openedx/djangoapps/credit) # to perform any 'on_publish' workflow on_course_publish(course_key) # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded from cms.djangoapps.contentstore.tasks import update_outline_from_modulestore_task, update_search_index if key_supports_outlines(course_key): # Push the course outline to learning_sequences asynchronously. update_outline_from_modulestore_task.delay(str(course_key)) # Finally call into the course search subsystem # to kick off an indexing action if CoursewareSearchIndexer.indexing_is_enabled( ) and CourseAboutSearchIndexer.indexing_is_enabled(): update_search_index.delay(str(course_key), datetime.now(UTC).isoformat())