Skip to content

Commit

Permalink
Merge pull request #51 from open-craft/cliff/mckin-9202-exclude-unreg…
Browse files Browse the repository at this point in the history
…istered-block-types

MCKIN-9202: Exclude unregistered block types from completion.
  • Loading branch information
jcdyer authored Jan 16, 2019
2 parents eb8aee2 + a3de9be commit e306c85
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion completion_aggregator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

from __future__ import absolute_import, unicode_literals

__version__ = '1.5.18'
__version__ = '1.5.19'

default_app_config = 'completion_aggregator.apps.CompletionAggregatorAppConfig' # pylint: disable=invalid-name
7 changes: 6 additions & 1 deletion completion_aggregator/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import six
from xblock.completable import XBlockCompletionMode
from xblock.core import XBlock
from xblock.plugin import PluginMissingError

from django.utils import timezone

Expand Down Expand Up @@ -171,7 +172,11 @@ def update_for_block(self, block, affected_aggregators, force=False):
Dispatches to an appropriate method given the block's completion_mode.
"""
mode = XBlockCompletionMode.get_mode(XBlock.load_class(block.block_type))
try:
mode = XBlockCompletionMode.get_mode(XBlock.load_class(block.block_type))
except PluginMissingError:
# Do not count blocks that aren't registered
mode = XBlockCompletionMode.EXCLUDED
if mode == XBlockCompletionMode.EXCLUDED:
return self.update_for_excluded()
elif mode == XBlockCompletionMode.COMPLETABLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def add_arguments(self, parser):
"""
parser.add_argument(
'--batch-size',
help='Maximum number of CourseModuleCompletions to migrate, per celery task. (default: 10000)',
default=10000,
help='Maximum number of StaleCompletions to process, per celery task. (default: 1000)',
default=1000,
type=int,
)
parser.add_argument(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ def setUp(self):
self.course_key.make_usage_key('html', 'course-chapter1-block2'),
self.course_key.make_usage_key('html', 'course-chapter2-block1'),
self.course_key.make_usage_key('html', 'course-chapter2-block2'),
# image_explorer is an unregistered block type, and should be
# treated as EXCLUDED from aggregation.
self.course_key.make_usage_key('image_explorer', 'course-chapter2-badblock'),
self.course_key.make_usage_key('chapter', 'course-zeropossible'),
]
patch = mock.patch('completion_aggregator.core.compat', StubCompat(self.blocks))
Expand Down

0 comments on commit e306c85

Please sign in to comment.