Convert Course, Section and Sequence XModules to XBlocks. (#25965)
This commit is contained in:
@@ -33,7 +33,7 @@ from openedx.core.djangoapps.models.course_details import CourseDetails
|
||||
from openedx.core.lib.cache_utils import request_cached, RequestCache
|
||||
from common.djangoapps.static_replace.models import AssetBaseUrlConfig
|
||||
from xmodule import block_metadata_utils, course_metadata_utils
|
||||
from xmodule.course_module import DEFAULT_START_DATE, CourseDescriptor
|
||||
from xmodule.course_module import DEFAULT_START_DATE, CourseBlock
|
||||
from xmodule.error_module import ErrorBlock
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.tabs import CourseTab
|
||||
@@ -138,13 +138,13 @@ class CourseOverview(TimeStampedModel):
|
||||
@classmethod
|
||||
def _create_or_update(cls, course): # lint-amnesty, pylint: disable=too-many-statements
|
||||
"""
|
||||
Creates or updates a CourseOverview object from a CourseDescriptor.
|
||||
Creates or updates a CourseOverview object from a CourseBlock.
|
||||
|
||||
Does not touch the database, simply constructs and returns an overview
|
||||
from the given course.
|
||||
|
||||
Arguments:
|
||||
course (CourseDescriptor): any course descriptor object
|
||||
course (CourseBlock): any course descriptor object
|
||||
|
||||
Returns:
|
||||
CourseOverview: created or updated overview extracted from the given course
|
||||
@@ -244,7 +244,7 @@ class CourseOverview(TimeStampedModel):
|
||||
@classmethod
|
||||
def load_from_module_store(cls, course_id):
|
||||
"""
|
||||
Load a CourseDescriptor, create or update a CourseOverview from it, cache the
|
||||
Load a CourseBlock, create or update a CourseOverview from it, cache the
|
||||
overview, and return it.
|
||||
|
||||
Arguments:
|
||||
@@ -266,7 +266,7 @@ class CourseOverview(TimeStampedModel):
|
||||
store = modulestore()
|
||||
with store.bulk_operations(course_id):
|
||||
course = store.get_course(course_id)
|
||||
if isinstance(course, CourseDescriptor):
|
||||
if isinstance(course, CourseBlock):
|
||||
try:
|
||||
course_overview = cls._create_or_update(course)
|
||||
with transaction.atomic():
|
||||
|
||||
@@ -72,16 +72,16 @@ class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase, Cache
|
||||
def check_course_overview_against_course(self, course):
|
||||
"""
|
||||
Compares a CourseOverview object against its corresponding
|
||||
CourseDescriptor object.
|
||||
CourseBlock object.
|
||||
|
||||
Specifically, given a course, test that data within the following three
|
||||
objects match each other:
|
||||
- the CourseDescriptor itself
|
||||
- the CourseBlock itself
|
||||
- a CourseOverview that was newly constructed from _create_or_update
|
||||
- a CourseOverview that was loaded from the MySQL database
|
||||
|
||||
Arguments:
|
||||
course (CourseDescriptor): the course to be checked.
|
||||
course (CourseBlock): the course to be checked.
|
||||
"""
|
||||
|
||||
def get_seconds_since_epoch(date_time):
|
||||
@@ -257,7 +257,7 @@ class CourseOverviewTestCase(CatalogIntegrationMixin, ModuleStoreTestCase, Cache
|
||||
@ddt.unpack
|
||||
def test_course_overview_behavior(self, course_kwargs, modulestore_type):
|
||||
"""
|
||||
Tests if CourseOverviews and CourseDescriptors behave the same
|
||||
Tests if CourseOverviews and CourseBlocks behave the same
|
||||
by comparing pairs of them given a variety of scenarios.
|
||||
|
||||
Arguments:
|
||||
|
||||
@@ -74,11 +74,11 @@ def config_course_cohorts_legacy(
|
||||
the cohort config on the course descriptor.
|
||||
|
||||
Since cohort settings are now stored in models.CourseCohortSettings,
|
||||
this is only used for testing data migration from the CourseDescriptor
|
||||
this is only used for testing data migration from the CourseBlock
|
||||
to the table.
|
||||
|
||||
Arguments:
|
||||
course: CourseDescriptor
|
||||
course: CourseBlock
|
||||
cohorted: bool.
|
||||
auto_cohort_groups: optional list of strings
|
||||
(names of groups to put students into).
|
||||
@@ -113,7 +113,7 @@ def config_course_cohorts(
|
||||
Set and configure cohorts for a course.
|
||||
|
||||
Arguments:
|
||||
course: CourseDescriptor
|
||||
course: CourseBlock
|
||||
is_cohorted (bool): Is the course cohorted?
|
||||
discussion_division_scheme (String): the division scheme for discussions. Default is
|
||||
CourseDiscussionSettings.COHORT.
|
||||
|
||||
@@ -294,7 +294,7 @@ def get_gated_content(course, user):
|
||||
Returns the unfulfilled gated content usage keys in the given course.
|
||||
|
||||
Arguments:
|
||||
course (CourseDescriptor): The course
|
||||
course (CourseBlock): The course
|
||||
user (User): The user
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -100,6 +100,7 @@ class TestXblockUtils(SharedModuleStoreTestCase):
|
||||
Verify that new content is added and the resources are the same.
|
||||
"""
|
||||
fragment = self.create_fragment(u"<h1>Test!</h1>")
|
||||
fragment.initialize_js('BlockMain') # wrap_block() sets some attributes only if there is JS.
|
||||
course = getattr(self, course_id)
|
||||
test_wrap_output = wrap_xblock(
|
||||
runtime_class='TestRuntime',
|
||||
|
||||
@@ -30,7 +30,7 @@ from xblock.scorable import ScorableXBlockMixin
|
||||
|
||||
from common.djangoapps import static_replace
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_string
|
||||
from xmodule.seq_module import SequenceModule
|
||||
from xmodule.seq_module import SequenceBlock
|
||||
from xmodule.util.xmodule_django import add_webpack_to_fragment
|
||||
from xmodule.vertical_block import VerticalBlock
|
||||
from xmodule.x_module import (
|
||||
@@ -319,7 +319,7 @@ def add_staff_markup(user, disable_staff_debug_info, block, view, frag, context)
|
||||
definition of the xmodule, and a link to view the module in Studio
|
||||
if it is a Studio edited, mongo stored course.
|
||||
|
||||
Does nothing if module is a SequenceModule.
|
||||
Does nothing if module is a SequenceBlock.
|
||||
"""
|
||||
if context and context.get('hide_staff_markup', False):
|
||||
# If hide_staff_markup is passed, don't add the markup
|
||||
@@ -328,7 +328,7 @@ def add_staff_markup(user, disable_staff_debug_info, block, view, frag, context)
|
||||
if isinstance(block, VerticalBlock) and (not context or not context.get('child_of_vertical', False)):
|
||||
return frag
|
||||
|
||||
if isinstance(block, SequenceModule) or getattr(block, 'HIDDEN', False):
|
||||
if isinstance(block, SequenceBlock) or getattr(block, 'HIDDEN', False):
|
||||
return frag
|
||||
|
||||
block_id = block.location
|
||||
|
||||
Reference in New Issue
Block a user