From 4c3fb2d07ed18acf92c07306310dbe1f3f4ce580 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 24 Apr 2015 09:32:13 -0400 Subject: [PATCH] Enforce user-state only for StudentModule backend Client --- lms/djangoapps/courseware/user_state_client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lms/djangoapps/courseware/user_state_client.py b/lms/djangoapps/courseware/user_state_client.py index 19f522d34b..d46a57dcb8 100644 --- a/lms/djangoapps/courseware/user_state_client.py +++ b/lms/djangoapps/courseware/user_state_client.py @@ -37,13 +37,19 @@ class DjangoXBlockUserStateClient(DjangoXBlockUserStateClient): def get_many(username, block_keys, scope=Scope.user_state): """Returns dict of block_id -> state.""" + if scope != Scope.user_state: + raise ValueError("Only Scope.user_state is supported") raise NotImplementedError() def set_many(username, block_keys_to_state, scope=Scope.user_state): + if scope != Scope.user_state: + raise ValueError("Only Scope.user_state is supported") raise NotImplementedError() def get_history(username, block_key, scope=Scope.user_state): """We don't guarantee that history for many blocks will be fast.""" + if scope != Scope.user_state: + raise ValueError("Only Scope.user_state is supported") raise NotImplementedError() def iter_all_for_block(block_key, scope=Scope.user_state, batch_size=None): @@ -52,6 +58,8 @@ class DjangoXBlockUserStateClient(DjangoXBlockUserStateClient): increments. If you're using this method, you should be running in an async task. """ + if scope != Scope.user_state: + raise ValueError("Only Scope.user_state is supported") raise NotImplementedError() def iter_all_for_course(course_key, block_type=None, scope=Scope.user_state, batch_size=None): @@ -60,4 +68,6 @@ class DjangoXBlockUserStateClient(DjangoXBlockUserStateClient): increments. If you're using this method, you should be running in an async task. """ + if scope != Scope.user_state: + raise ValueError("Only Scope.user_state is supported") raise NotImplementedError()