Commit 257c6162 by Xavier Antoviaque

Merge pull request #8 from open-craft/opaque-keys-follow-up-gse

Remove serialize_opaque_key
parents 4d1cce78 c180f007
...@@ -31,8 +31,7 @@ from xblock.fragment import Fragment ...@@ -31,8 +31,7 @@ from xblock.fragment import Fragment
from .light_children import LightChild, Boolean, Scope, String from .light_children import LightChild, Boolean, Scope, String
from .models import Answer from .models import Answer
from .utils import render_template, serialize_opaque_key from .utils import render_template
# Globals ########################################################### # Globals ###########################################################
...@@ -134,7 +133,7 @@ class AnswerBlock(LightChild): ...@@ -134,7 +133,7 @@ class AnswerBlock(LightChild):
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`? # TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
student_id = self.xmodule_runtime.anonymous_student_id student_id = self.xmodule_runtime.anonymous_student_id
course_id = serialize_opaque_key(self.xmodule_runtime.course_id) course_id = self.xmodule_runtime.course_id
answer_data, created = Answer.objects.get_or_create( answer_data, created = Answer.objects.get_or_create(
student_id=student_id, student_id=student_id,
......
...@@ -40,7 +40,7 @@ except: ...@@ -40,7 +40,7 @@ except:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench # TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
replace_jump_to_id_urls = lambda a,b,c,d,frag,f: frag replace_jump_to_id_urls = lambda a,b,c,d,frag,f: frag
from .utils import serialize_opaque_key, XBlockWithChildrenFragmentsMixin from .utils import XBlockWithChildrenFragmentsMixin
# Globals ########################################################### # Globals ###########################################################
...@@ -179,7 +179,7 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock): ...@@ -179,7 +179,7 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
""" """
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`? # TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
try: try:
course_id = serialize_opaque_key(self.xmodule_runtime.course_id) course_id = self.xmodule_runtime.course_id
except AttributeError: except AttributeError:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench # TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
course_id = 'sample-course' course_id = 'sample-course'
......
...@@ -82,28 +82,6 @@ def load_scenarios_from_path(scenarios_path): ...@@ -82,28 +82,6 @@ def load_scenarios_from_path(scenarios_path):
""" """
return get_scenarios_from_path(scenarios_path, include_identifier=True) return get_scenarios_from_path(scenarios_path, include_identifier=True)
def serialize_opaque_key(key):
"""
Gracefully handle opaque keys, both before and after the transition.
https://github.com/edx/edx-platform/wiki/Opaque-Keys
From https://github.com/edx/edx-ora2/pull/330
Currently uses `to_deprecated_string()` to ensure that new keys
are backwards-compatible with keys we store in ORA2 database models.
Args:
key (unicode or OpaqueKey subclass): The key to serialize.
Returns:
unicode
"""
if hasattr(key, 'to_deprecated_string'):
return key.to_deprecated_string()
else:
return unicode(key)
# Classes ########################################################### # Classes ###########################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment