Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions cms/djangoapps/contentstore/course_group_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,26 +114,26 @@ def get_user_partition(self):
raise GroupConfigurationsValidationError(_("unable to load this type of group configuration")) # lint-amnesty, pylint: disable=raise-missing-from

@staticmethod
def _get_usage_dict(course, unit, item, scheme_name=None):
def _get_usage_dict(course, unit, block, scheme_name=None):
"""
Get usage info for unit/module.
Get usage info for unit/block.
"""
parent_unit = get_parent_unit(item)
parent_unit = get_parent_unit(block)

if unit == parent_unit and not item.has_children:
if unit == parent_unit and not block.has_children:
# Display the topmost unit page if
# the item is a child of the topmost unit and doesn't have its own children.
unit_for_url = unit
elif (not parent_unit and unit.get_parent()) or (unit == parent_unit and item.has_children):
elif (not parent_unit and unit.get_parent()) or (unit == parent_unit and block.has_children):
# Display the item's page rather than the unit page if
# the item is one level below the topmost unit and has children, or
# the item itself *is* the topmost unit (and thus does not have a parent unit, but is not an orphan).
unit_for_url = item
unit_for_url = block
else:
# If the item is nested deeper than two levels (the topmost unit > vertical > ... > item)
# display the page for the nested vertical element.
parent = item.get_parent()
nested_vertical = item
parent = block.get_parent()
nested_vertical = block
while parent != parent_unit:
nested_vertical = parent
parent = parent.get_parent()
Expand All @@ -144,9 +144,9 @@ def _get_usage_dict(course, unit, item, scheme_name=None):
course.location.course_key.make_usage_key(unit_for_url.location.block_type, unit_for_url.location.block_id)
)

usage_dict = {'label': f"{unit.display_name} / {item.display_name}", 'url': unit_url}
usage_dict = {'label': f"{unit.display_name} / {block.display_name}", 'url': unit_url}
if scheme_name == RANDOM_SCHEME:
validation_summary = item.general_validation_message()
validation_summary = block.general_validation_message()
usage_dict.update({'validation': validation_summary.to_json() if validation_summary else None})
return usage_dict

Expand Down Expand Up @@ -204,7 +204,7 @@ def _get_content_experiment_usage_info(store, course, split_tests): # pylint: d
usage_info[split_test.user_partition_id].append(GroupConfiguration._get_usage_dict(
course=course,
unit=unit,
item=split_test,
block=split_test,
scheme_name=RANDOM_SCHEME,
))
return usage_info
Expand Down Expand Up @@ -233,16 +233,16 @@ def get_partitions_usage_info(store, course):
items = store.get_items(course.id, settings={'group_access': {'$exists': True}}, include_orphans=False)

usage_info = defaultdict(lambda: defaultdict(list))
for item, partition_id, group_id in GroupConfiguration._iterate_items_and_group_ids(course, items):
unit = item.get_parent()
for block, partition_id, group_id in GroupConfiguration._iterate_items_and_group_ids(course, items):
unit = block.get_parent()
if not unit:
log.warning("Unable to find parent for component %s", item.location)
log.warning("Unable to find parent for component %s", block.location)
continue

usage_info[partition_id][group_id].append(GroupConfiguration._get_usage_dict(
course,
unit=unit,
item=item,
block=block,
))

return usage_info
Expand Down Expand Up @@ -280,11 +280,11 @@ def _get_content_groups_items_usage_info(course, items):
}
"""
usage_info = defaultdict(lambda: defaultdict(list))
for item, partition_id, group_id in GroupConfiguration._iterate_items_and_group_ids(course, items):
for block, partition_id, group_id in GroupConfiguration._iterate_items_and_group_ids(course, items):
usage_info[partition_id][group_id].append(GroupConfiguration._get_usage_dict(
course,
unit=item,
item=item,
unit=block,
block=block,
))

return usage_info
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/courseware_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ def index_about_information(cls, modulestore, course):
'image_url': course_image_url(course),
}

# load data for all of the 'about' modules for this course into a dictionary
# load data for all of the 'about' blocks for this course into a dictionary
about_dictionary = {
item.location.block_id: item.data
for item in modulestore.get_items(course.id, qualifiers={"category": "about"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey

from cms.djangoapps.contentstore.views.item import _delete_orphans
from cms.djangoapps.contentstore.views.block import _delete_orphans
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order


Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/management/commands/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def handle(self, *args, **options):
mstore = modulestore()

course_items = import_course_from_xml(
mstore, ModuleStoreEnum.UserID.mgmt_command, data_dir, source_dirs, load_error_modules=False,
mstore, ModuleStoreEnum.UserID.mgmt_command, data_dir, source_dirs, load_error_blocks=False,
static_content_store=contentstore(), verbose=True,
do_import_static=do_import_static, do_import_python_lib=do_import_python_lib,
create_if_not_present=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def handle(self, *args, **options):
import_library_from_xml(
modulestore(), user.id,
settings.GITHUB_REPO_ROOT, [rel_xml_path],
load_error_modules=False,
load_error_blocks=False,
static_content_store=contentstore(),
target_id=courselike_key
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_delete_orphans_commit(self):

call_command('delete_orphans', str(course.id), '--commit')

# make sure this module wasn't deleted
# make sure this block wasn't deleted
self.assertTrue(self.store.has_item(course.id.make_usage_key('html', 'multi_parent_html')))

# and make sure that these were
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/management/commands/xlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ def handle(self, *args, **options):
data=data_dir,
courses=source_dirs))

perform_xlint(data_dir, source_dirs, load_error_modules=False)
perform_xlint(data_dir, source_dirs, load_error_blocks=False)
10 changes: 5 additions & 5 deletions cms/djangoapps/contentstore/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
LibrarySearchIndexer,
)
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 common.djangoapps.util.block_utils import yield_dynamic_descriptor_descendants
from lms.djangoapps.grades.api import task_compute_all_grades_for_course
from openedx.core.djangoapps.content.learning_sequences.api import key_supports_outlines
from openedx.core.djangoapps.discussions.tasks import update_discussions_settings_from_course_task
Expand Down Expand Up @@ -204,12 +204,12 @@ def handle_item_deleted(**kwargs):
# Strip branch info
usage_key = usage_key.for_branch(None)
course_key = usage_key.course_key
deleted_module = modulestore().get_item(usage_key)
for module in yield_dynamic_descriptor_descendants(deleted_module, kwargs.get('user_id')):
deleted_block = modulestore().get_item(usage_key)
for block in yield_dynamic_descriptor_descendants(deleted_block, kwargs.get('user_id')):
# Remove prerequisite milestone data
gating_api.remove_prerequisite(module.location)
gating_api.remove_prerequisite(block.location)
# Remove any 'requires' course content milestone relationships
gating_api.set_required_content(course_key, module.location, None, None, None)
gating_api.set_required_content(course_key, block.location, None, None, None)


@receiver(GRADING_POLICY_CHANGED)
Expand Down
14 changes: 7 additions & 7 deletions cms/djangoapps/contentstore/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,13 @@ def export_olx(self, user_id, course_key_string, language):
return

if isinstance(courselike_key, LibraryLocator):
courselike_module = modulestore().get_library(courselike_key)
courselike_block = modulestore().get_library(courselike_key)
else:
courselike_module = modulestore().get_course(courselike_key)
courselike_block = modulestore().get_course(courselike_key)

try:
self.status.set_state('Exporting')
tarball = create_export_tarball(courselike_module, courselike_key, {}, self.status)
tarball = create_export_tarball(courselike_block, courselike_key, {}, self.status)
artifact = UserTaskArtifact(status=self.status, name='Output')
artifact.file.save(name=os.path.basename(tarball.name), content=File(tarball))
artifact.save()
Expand Down Expand Up @@ -541,11 +541,11 @@ def get_dir_for_filename(directory, filename):
is_course = not is_library
if is_library:
root_name = LIBRARY_ROOT
courselike_module = modulestore().get_library(courselike_key)
courselike_block = modulestore().get_library(courselike_key)
import_func = import_library_from_xml
else:
root_name = COURSE_ROOT
courselike_module = modulestore().get_course(courselike_key)
courselike_block = modulestore().get_course(courselike_key)
import_func = import_course_from_xml

# Locate the uploaded OLX archive (and download it from S3 if necessary)
Expand Down Expand Up @@ -581,7 +581,7 @@ def read_chunk():
# If the course has an entrance exam then remove it and its corresponding milestone.
# current course state before import.
if is_course:
if courselike_module.entrance_exam_enabled:
if courselike_block.entrance_exam_enabled:
fake_request = RequestFactory().get('/')
fake_request.user = user
from .views.entrance_exam import remove_entrance_exam_milestone_reference
Expand Down Expand Up @@ -635,7 +635,7 @@ def read_chunk():
courselike_items = import_func(
modulestore(), user.id,
settings.GITHUB_REPO_ROOT, [dirpath],
load_error_modules=False,
load_error_blocks=False,
static_content_store=contentstore(),
target_id=courselike_key,
verbose=True,
Expand Down
34 changes: 17 additions & 17 deletions cms/djangoapps/contentstore/tests/test_contentstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def test_empty_data_roundtrip(self):

parent = verticals[0]

# Create a module, and ensure that its `data` field is empty
# Create a block, and ensure that its `data` field is empty
word_cloud = BlockFactory.create(
parent_location=parent.location, category="word_cloud", display_name="untitled")
del word_cloud.data
Expand Down Expand Up @@ -478,7 +478,7 @@ def test_export_course_without_content_store(self):

def test_export_course_no_xml_attributes(self):
"""
Test that a module without an `xml_attributes` attr will still be
Test that a block without an `xml_attributes` attr will still be
exported successfully
"""
content_store = contentstore()
Expand Down Expand Up @@ -732,7 +732,7 @@ def test_get_items(self):
def test_draft_metadata(self):
"""
This verifies a bug we had where inherited metadata was getting written to the
module as 'own-metadata' when publishing. Also verifies the metadata inheritance is
block as 'own-metadata' when publishing. Also verifies the metadata inheritance is
properly computed
"""
# refetch course so it has all the children correct
Expand All @@ -752,7 +752,7 @@ def test_draft_metadata(self):
self.assertEqual(problem.graceperiod, course.graceperiod)
self.assertNotIn('graceperiod', own_metadata(problem))

# publish module
# publish block
self.store.publish(problem.location, self.user.id)

# refetch to check metadata
Expand Down Expand Up @@ -831,7 +831,7 @@ def test_import_polls(self):

def test_module_preview_in_whitelist(self):
"""
Tests the ajax callback to render an XModule
Tests the ajax callback to render an XBlock
"""
with override_settings(COURSES_WITH_UNSAFE_CODE=[str(self.course.id)]):
# also try a custom response which will trigger the 'is this course in whitelist' logic
Expand Down Expand Up @@ -971,7 +971,7 @@ def test_delete_course(self):
# delete the course
self.store.delete_course(self.course.id, self.user.id)

# assert that there's absolutely no non-draft modules in the course
# assert that there's absolutely no non-draft blocks in the course
# this should also include all draft items
with self.assertRaises(ItemNotFoundError):
self.store.get_items(self.course.id)
Expand All @@ -992,7 +992,7 @@ def test_course_handouts_rewrites(self):
}
)

# get module info (json)
# get block info (json)
resp = self.client.get(get_url('xblock_handler', handouts.location))

# make sure we got a successful response
Expand All @@ -1015,10 +1015,10 @@ def test_prefetch_children(self):
course = self.store.get_course(self.course.id, depth=2, lazy=False)

# make sure we pre-fetched a known sequential which should be at depth=2
self.assertIn(BlockKey.from_usage_key(self.seq_loc), course.system.module_data)
self.assertIn(BlockKey.from_usage_key(self.seq_loc), course.runtime.module_data)

# make sure we don't have a specific vertical which should be at depth=3
self.assertNotIn(BlockKey.from_usage_key(self.vert_loc), course.system.module_data)
self.assertNotIn(BlockKey.from_usage_key(self.vert_loc), course.runtime.module_data)

# Now, test with the branch set to draft. No extra round trips b/c it doesn't go deep enough to get
# beyond direct only categories
Expand Down Expand Up @@ -1386,7 +1386,7 @@ def test_course_overview_view_with_course(self):
html=True
)

def test_create_item(self):
def test_create_block(self):
"""Test creating a new xblock instance."""
course = CourseFactory.create()

Expand Down Expand Up @@ -1493,11 +1493,11 @@ def test_import_into_new_course_id(self):

import_course_from_xml(self.store, self.user.id, TEST_DATA_DIR, ['toy'], target_id=target_id)

modules = self.store.get_items(target_id)
blocks = self.store.get_items(target_id)

# we should have a number of modules in there
# we should have a number of blocks in there
# we can't specify an exact number since it'll always be changing
self.assertGreater(len(modules), 10)
self.assertGreater(len(blocks), 10)

#
# test various re-namespacing elements
Expand Down Expand Up @@ -1602,7 +1602,7 @@ def test_metadata_inheritance(self):

self.assertGreater(len(verticals), 0)

# crate a new module and add it as a child to a vertical
# crate a new block and add it as a child to a vertical
parent = verticals[0]
new_block = self.store.create_child(
self.user.id, parent.location, 'html', 'new_component'
Expand Down Expand Up @@ -1743,13 +1743,13 @@ def test_metadata_not_persistence(self):

self.assertNotIn('html5_sources', own_metadata(self.video_descriptor))
self.store.update_item(self.video_descriptor, self.user.id)
module = self.store.get_item(location)
block = self.store.get_item(location)

self.assertNotIn('html5_sources', own_metadata(module))
self.assertNotIn('html5_sources', own_metadata(block))

def test_metadata_persistence(self):
# TODO: create the same test as `test_metadata_not_persistence`,
# but check persistence for some other module.
# but check persistence for some other block.
pass


Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/tests/test_courseware_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _get_default_search(self):

def _test_indexing_course(self, store):
""" indexing course tests """
# Only published modules should be in the index
# Only published blocks should be in the index
added_to_index = self.reindex_course(store) # This reindex may not be necessary (it may already be indexed)
self.assertEqual(added_to_index, 3)
response = self.search()
Expand Down Expand Up @@ -1164,7 +1164,7 @@ def test_content_group_gets_indexed(self):
Indexing course with content groups added test.
"""

# Only published modules should be in the index
# Only published blocks should be in the index
added_to_index = self.reindex_course(self.store)
self.assertEqual(added_to_index, 16)
response = self.searcher.search(field_dictionary={"course": str(self.course.id)})
Expand Down
4 changes: 2 additions & 2 deletions cms/djangoapps/contentstore/tests/test_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_temporary_xblocks(self):
)

test_chapter = self.store.create_xblock(
test_course.system, test_course.id, 'chapter', fields={'display_name': 'chapter n'},
test_course.runtime, test_course.id, 'chapter', fields={'display_name': 'chapter n'},
parent_xblock=test_course
)
self.assertIsInstance(test_chapter, SequenceBlock)
Expand All @@ -100,7 +100,7 @@ def test_temporary_xblocks(self):
# test w/ a definition (e.g., a problem)
test_def_content = '<problem>boo</problem>'
test_problem = self.store.create_xblock(
test_course.system, test_course.id, 'problem', fields={'data': test_def_content},
test_course.runtime, test_course.id, 'problem', fields={'data': test_def_content},
parent_xblock=test_chapter
)
self.assertIsInstance(test_problem, ProblemBlock)
Expand Down
Loading