Change completion API to work with any learning context
This commit is contained in:
@@ -61,7 +61,7 @@ class BlockCompletionTransformer(BlockStructureTransformer):
|
||||
|
||||
completions = BlockCompletion.objects.filter(
|
||||
user=usage_info.user,
|
||||
course_key=usage_info.course_key,
|
||||
context_key=usage_info.course_key,
|
||||
).values_list(
|
||||
'block_key',
|
||||
'completion',
|
||||
|
||||
@@ -82,7 +82,6 @@ class BlockCompletionTransformerTestCase(TransformerRegistryTestMixin, Completio
|
||||
block = ItemFactory.create(category='comp', parent=course)
|
||||
BlockCompletion.objects.submit_completion(
|
||||
user=self.user,
|
||||
course_key=block.location.course_key,
|
||||
block_key=block.location,
|
||||
completion=self.COMPLETION_TEST_VALUE,
|
||||
)
|
||||
|
||||
@@ -569,7 +569,6 @@ def get_module_system_for_user(
|
||||
else:
|
||||
BlockCompletion.objects.submit_completion(
|
||||
user=user,
|
||||
course_key=course_id,
|
||||
block_key=block.scope_ids.usage_id,
|
||||
completion=event['completion'],
|
||||
)
|
||||
@@ -614,7 +613,6 @@ def get_module_system_for_user(
|
||||
if not getattr(block, 'has_custom_completion', False):
|
||||
BlockCompletion.objects.submit_completion(
|
||||
user=user,
|
||||
course_key=course_id,
|
||||
block_key=block.scope_ids.usage_id,
|
||||
completion=1.0,
|
||||
)
|
||||
|
||||
@@ -37,7 +37,9 @@ def evaluate_subsection_completion_milestones(**kwargs):
|
||||
evaluation of any milestone which can be completed.
|
||||
"""
|
||||
instance = kwargs['instance']
|
||||
course_id = six.text_type(instance.course_key)
|
||||
course_id = six.text_type(instance.context_key)
|
||||
if not instance.context_key.is_course:
|
||||
return # Content in a library or some other thing that doesn't support milestones
|
||||
block_id = six.text_type(instance.block_key)
|
||||
user_id = instance.user_id
|
||||
task_evaluate_subsection_completion_milestones(course_id, block_id, user_id)
|
||||
|
||||
@@ -142,7 +142,7 @@ class LmsModuleSystem(ModuleSystem): # pylint: disable=abstract-method
|
||||
services = kwargs.setdefault('services', {})
|
||||
user = kwargs.get('user')
|
||||
if user and user.is_authenticated:
|
||||
services['completion'] = CompletionService(user=user, course_key=kwargs.get('course_id'))
|
||||
services['completion'] = CompletionService(user=user, context_key=kwargs.get('course_id'))
|
||||
services['fs'] = xblock.reference.plugins.FSService()
|
||||
services['i18n'] = ModuleI18nService
|
||||
services['library_tools'] = LibraryToolsService(store)
|
||||
|
||||
Reference in New Issue
Block a user