Skip to content
1 change: 0 additions & 1 deletion cms/djangoapps/contentstore/views/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def _preview_module_system(request, descriptor, field_data):
track_function=lambda event_type, event: None,
get_module=partial(_load_preview_module, request),
mixins=settings.XBLOCK_MIXINS,
course_id=course_id,

# Set up functions to modify the fragment produced by student_view
wrappers=wrappers,
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/tests/test_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_cache(self):
def test_replace_urls(self):
html = '<a href="/static/id">'
assert self.runtime.replace_urls(html) == \
static_replace.replace_static_urls(html, course_id=self.runtime.course_id)
static_replace.replace_static_urls(html, course_id=self.course.id)

def test_anonymous_user_id_preview(self):
assert self.runtime.anonymous_student_id == 'student'
Expand Down
32 changes: 26 additions & 6 deletions lms/djangoapps/courseware/module_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import logging
import textwrap
from collections import OrderedDict

from functools import partial

from completion.waffle import ENABLE_COMPLETION_TRACKING_SWITCH
from completion.models import BlockCompletion
from completion.services import CompletionService
from django.conf import settings
from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user
from django.core.cache import cache
Expand All @@ -22,7 +24,7 @@
from django.utils.text import slugify
from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.decorators.csrf import csrf_exempt
from edx_django_utils.cache import RequestCache
from edx_django_utils.cache import DEFAULT_REQUEST_CACHE, RequestCache
from edx_django_utils.monitoring import set_custom_attributes_for_course_key, set_monitoring_transaction_name
from edx_proctoring.api import get_attempt_status_summary
from edx_proctoring.services import ProctoringService
Expand All @@ -39,12 +41,18 @@
from xblock.reference.plugins import FSService
from xblock.runtime import KvsFieldData

from lms.djangoapps.badges.service import BadgingService
from lms.djangoapps.badges.utils import badges_enabled
from lms.djangoapps.teams.services import TeamsService
from openedx.core.lib.xblock_services.call_to_action import CallToActionService
from xmodule.contentstore.django import contentstore
from xmodule.exceptions import NotFoundError, ProcessingError
from xmodule.modulestore.django import modulestore
from xmodule.library_tools import LibraryToolsService
from xmodule.modulestore.django import ModuleI18nService, modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.partitions.partitions_service import PartitionService
from xmodule.util.sandboxing import SandboxService
from xmodule.services import RebindUserService
from xmodule.services import RebindUserService, SettingsService, TeamsConfigurationService
from common.djangoapps.static_replace.services import ReplaceURLService
from common.djangoapps.static_replace.wrapper import replace_urls_wrapper
from common.djangoapps.xblock_django.constants import ATTR_KEY_USER_ID
Expand All @@ -63,7 +71,7 @@
from lms.djangoapps.grades.api import GradesUtilService
from lms.djangoapps.grades.api import signals as grades_signals
from lms.djangoapps.lms_xblock.field_data import LmsFieldData
from lms.djangoapps.lms_xblock.runtime import LmsModuleSystem
from lms.djangoapps.lms_xblock.runtime import LmsModuleSystem, UserTagsService
from lms.djangoapps.verify_student.services import XBlockVerificationService
from openedx.core.djangoapps.bookmarks.services import BookmarksService
from openedx.core.djangoapps.crawlers.models import CrawlersConfig
Expand Down Expand Up @@ -678,12 +686,12 @@ def handle_deprecated_progress_event(block, event):
field_data = DateLookupFieldData(descriptor._field_data, course_id, user) # pylint: disable=protected-access
field_data = LmsFieldData(field_data, student_data)

store = modulestore()

system = LmsModuleSystem(
track_function=track_function,
get_module=inner_get_module,
user=user,
publish=publish,
course_id=course_id,
# TODO: When we merge the descriptor and module systems, we can stop reaching into the mixologist (cpennington)
mixins=descriptor.runtime.mixologist._mixins, # pylint: disable=protected-access
wrappers=block_wrappers,
Expand All @@ -706,6 +714,18 @@ def handle_deprecated_progress_event(block, event):
'xqueue': xqueue_service,
'replace_urls': replace_url_service,
'rebind_user': rebind_user_service,
'completion': CompletionService(user=user, context_key=course_id)
if user and user.is_authenticated
else None,
'i18n': ModuleI18nService,
'library_tools': LibraryToolsService(store, user_id=user.id if user else None),
'partitions': PartitionService(course_id=course_id, cache=DEFAULT_REQUEST_CACHE.data),
'settings': SettingsService(),
'user_tags': UserTagsService(user=user, course_id=course_id),
'badging': BadgingService(course_id=course_id, modulestore=store) if badges_enabled() else None,
'teams': TeamsService(),
'teams_configuration': TeamsConfigurationService(),
'call_to_action': CallToActionService(),
},
descriptor_runtime=descriptor._runtime, # pylint: disable=protected-access
request_token=request_token,
Expand Down
6 changes: 3 additions & 3 deletions lms/djangoapps/courseware/student_field_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _get_overrides_for_user(user, block):
location = block.location

query = StudentFieldOverride.objects.filter(
course_id=block.runtime.course_id,
course_id=block.scope_ids.usage_id.context_key,
location=location,
student_id=user.id,
)
Expand All @@ -76,7 +76,7 @@ def override_field_for_user(user, block, name, value):
value to set for the given field.
"""
override, _ = StudentFieldOverride.objects.get_or_create(
course_id=block.runtime.course_id,
course_id=block.scope_ids.usage_id.context_key,
location=block.location,
student_id=user.id,
field=name)
Expand All @@ -94,7 +94,7 @@ def clear_override_for_user(user, block, name):
"""
try:
StudentFieldOverride.objects.get(
course_id=block.runtime.course_id,
course_id=block.scope_ids.usage_id.context_key,
student_id=user.id,
location=block.location,
field=name).delete()
Expand Down
Loading