Merge branch 'master' into edx-depr31
This commit is contained in:
@@ -10,23 +10,6 @@ from openedx.core.lib.cache_utils import request_cached
|
||||
from .models import BlockStructureConfiguration
|
||||
|
||||
# Switches
|
||||
# .. toggle_name: block_structure.invalidate_cache_on_publish
|
||||
# .. toggle_implementation: WaffleSwitch
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: When enabled, the block structure cache is invalidated when changes to
|
||||
# courses are published. If `block_structure.storage_backing_for_cache` is active, all block
|
||||
# structures related to the published course are also cleared from storage.
|
||||
# .. toggle_warning: This switch will likely be deprecated and removed.
|
||||
# .. toggle_use_cases: temporary
|
||||
# .. toggle_creation_date: 2017-02-23
|
||||
# .. toggle_target_removal_date: 2017-05-23
|
||||
# .. toggle_tickets: https://github.com/openedx/edx-platform/pull/14358,
|
||||
# https://github.com/openedx/edx-platform/pull/14571,
|
||||
# https://openedx.atlassian.net/browse/DEPR-144
|
||||
INVALIDATE_CACHE_ON_PUBLISH = WaffleSwitch(
|
||||
"block_structure.invalidate_cache_on_publish", __name__
|
||||
)
|
||||
|
||||
# .. toggle_name: block_structure.storage_backing_for_cache
|
||||
# .. toggle_implementation: WaffleSwitch
|
||||
# .. toggle_default: False
|
||||
|
||||
@@ -10,9 +10,7 @@ from opaque_keys.edx.locator import LibraryLocator
|
||||
|
||||
from xmodule.modulestore.django import SignalHandler
|
||||
|
||||
from . import config
|
||||
from .api import clear_course_from_cache
|
||||
from .models import BlockStructureNotFound
|
||||
from .tasks import update_course_in_cache_v2
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -28,15 +26,6 @@ def update_block_structure_on_course_publish(sender, course_key, **kwargs): # p
|
||||
if isinstance(course_key, LibraryLocator):
|
||||
return
|
||||
|
||||
if config.INVALIDATE_CACHE_ON_PUBLISH.is_enabled():
|
||||
try:
|
||||
clear_course_from_cache(course_key)
|
||||
except BlockStructureNotFound:
|
||||
log.warning(
|
||||
"BlockStructure: %s not found when trying to clear course from cache",
|
||||
course_key,
|
||||
)
|
||||
|
||||
update_course_in_cache_v2.apply_async(
|
||||
kwargs=dict(course_id=str(course_key)),
|
||||
countdown=settings.BLOCK_STRUCTURES_SETTINGS['COURSE_PUBLISH_TASK_DELAY'],
|
||||
|
||||
@@ -5,14 +5,12 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import ddt
|
||||
from edx_toggles.toggles.testutils import override_waffle_switch
|
||||
from opaque_keys.edx.locator import CourseLocator, LibraryLocator
|
||||
from xmodule.modulestore.exceptions import ItemNotFoundError
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory
|
||||
|
||||
from ..api import get_block_structure_manager
|
||||
from ..config import INVALIDATE_CACHE_ON_PUBLISH
|
||||
from ..signals import update_block_structure_on_course_publish
|
||||
from .helpers import is_course_in_block_structure_cache
|
||||
|
||||
@@ -45,17 +43,6 @@ class CourseBlocksSignalTest(ModuleStoreTestCase):
|
||||
updated_block_structure = bs_manager.get_collected()
|
||||
assert test_display_name == updated_block_structure.get_xblock_field(self.course_usage_key, 'display_name')
|
||||
|
||||
@ddt.data(True, False)
|
||||
@patch('openedx.core.djangoapps.content.block_structure.manager.BlockStructureManager.clear')
|
||||
def test_cache_invalidation(self, invalidate_cache_enabled, mock_bs_manager_clear):
|
||||
test_display_name = "Jedi 101"
|
||||
|
||||
with override_waffle_switch(INVALIDATE_CACHE_ON_PUBLISH, active=invalidate_cache_enabled):
|
||||
self.course.display_name = test_display_name
|
||||
self.update_course(self.course, self.user.id)
|
||||
|
||||
assert mock_bs_manager_clear.called == invalidate_cache_enabled
|
||||
|
||||
def test_course_delete(self):
|
||||
bs_manager = get_block_structure_manager(self.course.id)
|
||||
assert bs_manager.get_collected() is not None
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.2.19 on 2023-06-28 13:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('course_overviews', '0027_auto_20221102_1109'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='courseoverview',
|
||||
name='force_on_flexible_peer_openassessments',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='historicalcourseoverview',
|
||||
name='force_on_flexible_peer_openassessments',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -64,7 +64,7 @@ class CourseOverview(TimeStampedModel):
|
||||
app_label = 'course_overviews'
|
||||
|
||||
# IMPORTANT: Bump this whenever you modify this model and/or add a migration.
|
||||
VERSION = 18
|
||||
VERSION = 19
|
||||
|
||||
# Cache entry versioning.
|
||||
version = models.IntegerField()
|
||||
@@ -144,6 +144,9 @@ class CourseOverview(TimeStampedModel):
|
||||
entrance_exam_id = models.CharField(max_length=255, blank=True)
|
||||
entrance_exam_minimum_score_pct = models.FloatField(default=0.65)
|
||||
|
||||
# Open Response Assessment configuration
|
||||
force_on_flexible_peer_openassessments = models.BooleanField(default=False)
|
||||
|
||||
external_id = models.CharField(max_length=128, null=True, blank=True)
|
||||
|
||||
language = models.TextField(null=True)
|
||||
@@ -268,6 +271,8 @@ class CourseOverview(TimeStampedModel):
|
||||
else:
|
||||
course_overview.entrance_exam_minimum_score_pct = course.entrance_exam_minimum_score_pct
|
||||
|
||||
course_overview.force_on_flexible_peer_openassessments = course.force_on_flexible_peer_openassessments
|
||||
|
||||
if not CatalogIntegration.is_enabled():
|
||||
course_overview.language = course.language
|
||||
|
||||
|
||||
Reference in New Issue
Block a user