Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
a1fb76d6
Commit
a1fb76d6
authored
Sep 13, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #78 from open-craft/opaque-keys-follow-up
Opaque keys follow up
parents
6c6dee36
58cd1a2c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
30 deletions
+7
-30
mentoring/answer.py
+2
-2
mentoring/dataexport.py
+2
-2
mentoring/light_children.py
+3
-3
mentoring/utils.py
+0
-23
No files found.
mentoring/answer.py
View file @
a1fb76d6
...
...
@@ -31,7 +31,7 @@ from xblock.fragment import Fragment
from
.light_children
import
LightChild
,
Boolean
,
Scope
,
String
,
Integer
,
Float
from
.models
import
Answer
from
.utils
import
render_js_template
,
serialize_opaque_key
from
.utils
import
render_js_template
# Globals ###########################################################
...
...
@@ -144,7 +144,7 @@ class AnswerBlock(LightChild):
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
student_id
=
self
.
xmodule_runtime
.
anonymous_student_id
course_id
=
se
rialize_opaque_key
(
self
.
xmodule_runtime
.
course_id
)
course_id
=
se
lf
.
xmodule_runtime
.
course_id
answer_data
,
created
=
Answer
.
objects
.
get_or_create
(
student_id
=
student_id
,
...
...
mentoring/dataexport.py
View file @
a1fb76d6
...
...
@@ -32,7 +32,7 @@ from xblock.fields import String, Scope
from
xblock.fragment
import
Fragment
from
.models
import
Answer
from
.utils
import
list2csv
,
render_template
,
serialize_opaque_key
from
.utils
import
list2csv
,
render_template
# Globals ###########################################################
...
...
@@ -73,7 +73,7 @@ class MentoringDataExportBlock(XBlock):
return
response
def
get_csv
(
self
):
course_id
=
se
rialize_opaque_key
(
self
.
xmodule_runtime
.
course_id
)
course_id
=
se
lf
.
xmodule_runtime
.
course_id
answers
=
Answer
.
objects
.
filter
(
course_id
=
course_id
)
.
order_by
(
'student_id'
,
'name'
)
answers_names
=
answers
.
values_list
(
'name'
,
flat
=
True
)
.
distinct
()
.
order_by
(
'name'
)
...
...
mentoring/light_children.py
View file @
a1fb76d6
...
...
@@ -47,7 +47,7 @@ except:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
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 ###########################################################
...
...
@@ -190,7 +190,7 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
"""
# TODO: Why do we need to use `xmodule_runtime` and not `runtime`?
try
:
course_id
=
se
rialize_opaque_key
(
self
.
xmodule_runtime
.
course_id
)
course_id
=
se
lf
.
xmodule_runtime
.
course_id
except
AttributeError
:
# TODO-WORKBENCH-WORKAROUND: To allow to load from the workbench
course_id
=
'sample-course'
...
...
@@ -303,7 +303,7 @@ class LightChild(Plugin, LightChildrenMixin):
raise
ValueError
(
'LightChild.name field need to be set to a non-null/empty value'
)
student_id
=
self
.
xmodule_runtime
.
anonymous_student_id
course_id
=
se
rialize_opaque_key
(
self
.
xmodule_runtime
.
course_id
)
course_id
=
se
lf
.
xmodule_runtime
.
course_id
url_name
=
"
%
s-
%
s"
%
(
self
.
xblock_container
.
url_name
,
name
)
lightchild_data
,
created
=
LightChildModel
.
objects
.
get_or_create
(
...
...
mentoring/utils.py
View file @
a1fb76d6
...
...
@@ -110,29 +110,6 @@ def load_scenarios_from_path(scenarios_path):
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 ###########################################################
class
XBlockWithChildrenFragmentsMixin
(
object
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment