feat: remove use of ENABLE_ASYNC_REGISTER_EXAMS waffle flag

This commit addresses MST-793. In MST-757, exam registration was moved to an asychronous task to improve the performance of saving content in Studio. This feature was gated behind a waffle flag, ENABLE_ASYNC_REGISTER_EXAMS, to avoid interrupting course teams during the testing and roll out of this feature.

This feature has been tested and rolled out, and so the aforementioned waffle flag is ready to be removed.

The effect of this change is that asynchronous exam registration will no longer be gated by the aforementioned waffle flag, and this feature will be rolled out across all of the edX platform.
This commit is contained in:
Michael Roytman
2021-05-11 11:28:13 -04:00
parent 4c0f856962
commit 22f9822e5d
3 changed files with 13 additions and 47 deletions

View File

@@ -52,22 +52,6 @@ SHOW_REVIEW_RULES_FLAG = CourseWaffleFlag( # lint-amnesty, pylint: disable=togg
module_name=__name__,
)
# Waffle flag to move the registration of special exams to an async celery task
# .. toggle_name: contentstore.async_register_exams
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: Toggles the asynchronous registration of special exams
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2021-04-21
# .. toggle_target_removal_date: 2021-05-07
# .. toggle_warnings:
# .. toggle_tickets: https://openedx.atlassian.net/browse/MST-757
ENABLE_ASYNC_REGISTER_EXAMS = CourseWaffleFlag(
waffle_namespace=waffle_flags(),
flag_name='async_register_exams',
module_name=__name__,
)
# Waffle flag to redirect to the library authoring MFE.
# .. toggle_name: contentstore.library_authoring_mfe
# .. toggle_implementation: WaffleFlag

View File

@@ -14,17 +14,14 @@ from cms.djangoapps.contentstore.courseware_index import (
CoursewareSearchIndexer,
LibrarySearchIndexer
)
from cms.djangoapps.contentstore.proctoring import register_special_exams
from common.djangoapps.track.event_transaction_utils import get_event_transaction_id, get_event_transaction_type
from common.djangoapps.util.module_utils import yield_dynamic_descriptor_descendants
from lms.djangoapps.grades.api import task_compute_all_grades_for_course
from openedx.core.djangoapps.credit.signals import on_course_publish
from openedx.core.djangoapps.content.learning_sequences.api import key_supports_outlines
from openedx.core.lib.gating import api as gating_api
from xmodule.modulestore.django import SignalHandler, modulestore
from .signals import GRADING_POLICY_CHANGED
from ..config.waffle import ENABLE_ASYNC_REGISTER_EXAMS
log = logging.getLogger(__name__)
@@ -52,34 +49,25 @@ def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable=
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
from cms.djangoapps.contentstore.tasks import (
update_outline_from_modulestore_task,
update_search_index,
update_special_exams_and_publish
)
# register special exams asynchronously
course_key_str = str(course_key)
update_special_exams_and_publish.delay(course_key_str)
if key_supports_outlines(course_key):
# Push the course outline to learning_sequences asynchronously.
update_outline_from_modulestore_task.delay(str(course_key))
update_outline_from_modulestore_task.delay(course_key_str)
# 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())
update_search_index.delay(course_key_str, datetime.now(UTC).isoformat())
@receiver(SignalHandler.library_updated)

View File

@@ -9,11 +9,9 @@ from unittest.mock import patch
import ddt
from django.conf import settings
from edx_proctoring.api import get_all_exams_for_course, get_review_policy_by_exam_id
from edx_toggles.toggles.testutils import override_waffle_flag
from pytz import UTC
from cms.djangoapps.contentstore.signals.handlers import listen_for_course_publish
from cms.djangoapps.contentstore.config.waffle import ENABLE_ASYNC_REGISTER_EXAMS
from common.djangoapps.student.tests.factories import UserFactory
from common.lib.xmodule.xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
@@ -102,9 +100,7 @@ class TestProctoredExams(ModuleStoreTestCase):
is_onboarding_exam=is_onboarding_exam,
)
with patch('cms.djangoapps.contentstore.tasks.update_special_exams_and_publish') as mock_task:
listen_for_course_publish(self, self.course.id)
mock_task.delay.assert_not_called()
listen_for_course_publish(self, self.course.id)
self._verify_exam_data(sequence, True)
@@ -319,7 +315,6 @@ class TestProctoredExams(ModuleStoreTestCase):
exams = get_all_exams_for_course(str(self.course.id))
assert exams[0]['due_date'] is not None
@override_waffle_flag(ENABLE_ASYNC_REGISTER_EXAMS, active=True)
def test_async_waffle_flag_publishes(self):
chapter = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section')
sequence = ItemFactory.create(
@@ -341,7 +336,6 @@ class TestProctoredExams(ModuleStoreTestCase):
self.assertEqual(len(exams), 1)
self._verify_exam_data(sequence, True)
@override_waffle_flag(ENABLE_ASYNC_REGISTER_EXAMS, active=True)
def test_async_waffle_flag_task(self):
chapter = ItemFactory.create(parent=self.course, category='chapter', display_name='Test Section')
ItemFactory.create(