Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _update_node_tree_and_dictionary(block, link, link_state, node_tree, diction
# Add block-level details for the last xblock in the path (URL and broken/locked links)
updated_dictionary[xblock_id].setdefault(
'url',
f'/course/{block.course_id}/editor/{block.category}/{block.location}'
f'/course/{block.context_key}/editor/{block.scope_ids.block_type}/{block.location}'
)

# The link_state == True condition is maintained for backward compatibility.
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ def handle_create_xblock_upstream_link(usage_key):
return
if xblock.top_level_downstream_parent_key is not None:
block_key = BlockKey.from_string(xblock.top_level_downstream_parent_key)
top_level_parent_usage_key = block_key.to_usage_key(xblock.course_id)
top_level_parent_usage_key = block_key.to_usage_key(xblock.context_key)
try:
ContainerLink.get_by_downstream_usage_key(top_level_parent_usage_key)
except ContainerLink.DoesNotExist:
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/course_blocks/transformers/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def update_block(block):
Helper method to update the block in the modulestore
"""
store = modulestore()
with store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, block.course_id):
with store.branch_setting(ModuleStoreEnum.Branch.draft_preferred, block.context_key):
return store.update_item(block, ModuleStoreEnum.UserID.test)


Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_lti_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def setUp(self):
mocked_decoded_signature = 'my_signature='

# Note: this course_id is actually a course_key
context_id = str(self.block.course_id)
context_id = str(self.block.context_key)
user_service = self.block.runtime.service(self.block, 'user')
user_id = str(user_service.get_current_user().opt_attrs.get(ATTR_KEY_ANONYMOUS_USER_ID))
hostname = settings.LMS_BASE
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/mobile_api/tests/test_course_info_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_course_sharing_utm_parameters(self):
def test_course_about_url(self):
response = self.verify_response(url=self.url)

course_overview = CourseOverview.objects.get(id=self.course.course_id)
course_overview = CourseOverview.objects.get(id=self.course.id)
expected_course_about_link = get_link_for_about_page(course_overview)

self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down Expand Up @@ -495,7 +495,7 @@ def verify_course_info_overview(self, response):
expected_course_modes = [{'slug': 'audit', 'sku': None, 'android_sku': None, 'ios_sku': None, 'min_price': 0}]
self.assertListEqual(course_info['course_modes'], expected_course_modes)

course_overview = CourseOverview.objects.get(id=self.course.course_id)
course_overview = CourseOverview.objects.get(id=self.course.id)
expected_course_about_link = get_link_for_about_page(course_overview)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(course_info['course_about'], expected_course_about_link)
Expand Down
24 changes: 12 additions & 12 deletions lms/djangoapps/mobile_api/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,9 +1451,9 @@ def test_user_have_only_active_enrollments_and_no_completions(self) -> None:
response = self.api_response(api_version=API_V1)

expected_response = [
{'course_id': str(courses[0].course_id), 'course_name': courses[0].display_name, 'recently_active': True},
{'course_id': str(courses[1].course_id), 'course_name': courses[1].display_name, 'recently_active': True},
{'course_id': str(courses[2].course_id), 'course_name': courses[2].display_name, 'recently_active': True},
{'course_id': str(courses[0].id), 'course_name': courses[0].display_name, 'recently_active': True},
{'course_id': str(courses[1].id), 'course_name': courses[1].display_name, 'recently_active': True},
{'course_id': str(courses[2].id), 'course_name': courses[2].display_name, 'recently_active': True},
]

self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand All @@ -1466,17 +1466,17 @@ def test_user_have_active_and_inactive_enrollments_and_no_completions(self) -> N
self.enroll(course.id)
old_course = CourseFactory.create(org="edx", mobile_available=True)
self.enroll(old_course.id)
old_enrollment = CourseEnrollment.objects.filter(user=self.user, course=old_course.course_id).first()
old_enrollment = CourseEnrollment.objects.filter(user=self.user, course=old_course.id).first()
old_enrollment.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=31)
old_enrollment.save()

response = self.api_response(api_version=API_V1)

expected_response = [
{'course_id': str(courses[0].course_id), 'course_name': courses[0].display_name, 'recently_active': True},
{'course_id': str(courses[1].course_id), 'course_name': courses[1].display_name, 'recently_active': True},
{'course_id': str(courses[2].course_id), 'course_name': courses[2].display_name, 'recently_active': True},
{'course_id': str(old_course.course_id), 'course_name': old_course.display_name, 'recently_active': False}
{'course_id': str(courses[0].id), 'course_name': courses[0].display_name, 'recently_active': True},
{'course_id': str(courses[1].id), 'course_name': courses[1].display_name, 'recently_active': True},
{'course_id': str(courses[2].id), 'course_name': courses[2].display_name, 'recently_active': True},
{'course_id': str(old_course.id), 'course_name': old_course.display_name, 'recently_active': False}
]

self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand All @@ -1494,15 +1494,15 @@ def test_different_enrollment_dates(self, enrolled_days_ago: int, recently_activ
self.login()
course = CourseFactory.create(org="edx", mobile_available=True, run='1001')
self.enroll(course.id)
enrollment = CourseEnrollment.objects.filter(user=self.user, course=course.course_id).first()
enrollment = CourseEnrollment.objects.filter(user=self.user, course=course.id).first()
enrollment.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=enrolled_days_ago)
enrollment.save()

response = self.api_response(api_version=API_V1)

expected_response = [
{
'course_id': str(course.course_id),
'course_id': str(course.id),
'course_name': course.display_name,
'recently_active': recently_active_status
}
Expand All @@ -1527,7 +1527,7 @@ def test_different_completion_dates(self, completed_days_ago: int, recently_acti
category='chapter',
)
self.enroll(course.id)
enrollment = CourseEnrollment.objects.filter(user=self.user, course=course.course_id).first()
enrollment = CourseEnrollment.objects.filter(user=self.user, course=course.id).first()
# make enrollment older 30 days ago
enrollment.created = datetime.datetime.now(pytz.UTC) - datetime.timedelta(days=50)
enrollment.save()
Expand All @@ -1545,7 +1545,7 @@ def test_different_completion_dates(self, completed_days_ago: int, recently_acti

expected_response = [
{
'course_id': str(course.course_id),
'course_id': str(course.id),
'course_name': course.display_name,
'recently_active': recently_active_status
}
Expand Down
2 changes: 1 addition & 1 deletion xmodule/capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def generate_report_data(self, user_state_iterator, limit_responses=None):
# Capture a backtrace for errors from failed loncapa problems
log.exception(
"An error occurred generating a problem report on course %s, problem %s, and student %s",
self.course_id,
self.context_key,
self.scope_ids.usage_id,
self.scope_ids.user_id,
)
Expand Down
2 changes: 1 addition & 1 deletion xmodule/library_content_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def v2_update_children_upstream_version(self, user_id=None):
"""
from cms.djangoapps.modulestore_migrator import api as migrator_api
store = modulestore()
with store.bulk_operations(self.course_id):
with store.bulk_operations(self.context_key):
children = self.get_children()
# These are the v1 library item upstream UsageKeys
child_old_upstream_keys = [
Expand Down
6 changes: 3 additions & 3 deletions xmodule/lti_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ def get_course(self):

Returns None if the current block is not part of a course (i.e part of a library).
"""
if isinstance(self.course_id, CourseKey):
return self.runtime.modulestore.get_course(self.course_id)
if isinstance(self.context_key, CourseKey):
return self.runtime.modulestore.get_course(self.context_key)
return None

@property
Expand All @@ -630,7 +630,7 @@ def context_id(self):
context_id is an opaque identifier that uniquely identifies the context (e.g., a course)
that contains the link being launched.
"""
return str(self.course_id)
return str(self.context_key)

@property
def role(self):
Expand Down
2 changes: 1 addition & 1 deletion xmodule/tests/test_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_poll_export_with_unescaped_characters_xml(self):
unescaped characters.
"""
module_system = DummyModuleStoreRuntime(load_error_blocks=True)
module_system.id_generator.target_course_id = self.xblock.course_id
module_system.id_generator.target_course_id = self.xblock.context_key
sample_poll_xml = '''
<poll_question display_name="Poll Question">
<p>How old are you?</p>
Expand Down
4 changes: 2 additions & 2 deletions xmodule/video_block/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def get_html(self, view=STUDENT_VIEW, context=None): # lint-amnesty, pylint: di
try:
val_profiles = ["youtube", "desktop_webm", "desktop_mp4"]

if self.is_hls_playback_enabled(self.course_id):
if self.is_hls_playback_enabled(self.context_key):
val_profiles.append('hls')

# strip edx_video_id to prevent ValVideoNotFoundError error if unwanted spaces are there. TNL-5769
Expand Down Expand Up @@ -489,7 +489,7 @@ def get_html(self, view=STUDENT_VIEW, context=None): # lint-amnesty, pylint: di
}
video_config_service = self.runtime.service(self, 'video_config')
if video_config_service:
template_context.update(video_config_service.get_public_sharing_context(self, self.course_id))
template_context.update(video_config_service.get_public_sharing_context(self, self.context_key))

return loader.render_django_template("templates/video.html", template_context)

Expand Down
11 changes: 0 additions & 11 deletions xmodule/x_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,6 @@ def system(self):
)
return self.runtime

@property
def course_id(self):
"""
Return the key of the block to which this Course belongs.

New code should always used `context_key`, which is the key of the Learning Context to which
this block belongs. "Learning Context" is a generalized notion of Courses which is inclusive
of Content Libraries, et al.
"""
return self.context_key

@property
def category(self):
"""
Expand Down
Loading