Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx
edx-platform
Commits
b50876fc
Commit
b50876fc
authored
Mar 27, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make XBlockToXModuleShim use json-init-args to record the XModule constructor to shim to
parent
1f17538d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
11 deletions
+22
-11
common/djangoapps/xmodule_modifiers.py
+6
-2
common/lib/xmodule/xmodule/js/src/poll/poll_main.js
+1
-1
common/lib/xmodule/xmodule/js/src/xmodule.js
+9
-3
common/lib/xmodule/xmodule/x_module.py
+2
-1
common/static/js/xblock/core.js
+1
-1
common/templates/xblock_wrapper.html
+2
-2
lms/djangoapps/courseware/tests/test_module_render.py
+1
-1
No files found.
common/djangoapps/xmodule_modifiers.py
View file @
b50876fc
...
...
@@ -77,7 +77,11 @@ def wrap_xblock(runtime_class, block, view, frag, context, usage_id_serializer,
css_classes
=
[
'xblock'
,
'xblock-{}'
.
format
(
markupsafe
.
escape
(
view
))
'xblock-{}'
.
format
(
markupsafe
.
escape
(
view
)),
'xblock-{}-{}'
.
format
(
markupsafe
.
escape
(
view
),
markupsafe
.
escape
(
block
.
scope_ids
.
block_type
),
)
]
if
isinstance
(
block
,
(
XModule
,
XModuleDescriptor
)):
...
...
@@ -90,7 +94,7 @@ def wrap_xblock(runtime_class, block, view, frag, context, usage_id_serializer,
css_classes
.
append
(
'xmodule_'
+
markupsafe
.
escape
(
class_name
))
data
[
'type'
]
=
block
.
js_module_name
shim_xmodule_js
(
frag
)
shim_xmodule_js
(
block
,
frag
)
if
frag
.
js_init_fn
:
data
[
'init'
]
=
frag
.
js_init_fn
...
...
common/lib/xmodule/xmodule/js/src/poll/poll_main.js
View file @
b50876fc
...
...
@@ -273,7 +273,7 @@ function PollMain(el) {
if
(
(
tempEl
.
tagName
.
toLowerCase
()
===
'div'
)
&&
(
$
(
tempEl
).
hasClass
(
'xmodule_WrapperModule'
)
===
true
)
(
$
(
tempEl
).
data
(
'block-type'
)
===
'wrapper'
)
)
{
_this
.
wrapperSectionEl
=
tempEl
;
...
...
common/lib/xmodule/xmodule/js/src/xmodule.js
View file @
b50876fc
...
...
@@ -58,14 +58,20 @@
return
Descriptor
;
}());
this
.
XBlockToXModuleShim
=
function
(
runtime
,
element
)
{
this
.
XBlockToXModuleShim
=
function
(
runtime
,
element
,
initArgs
)
{
/*
* Load a single module (either an edit module or a display module)
* from the supplied element, which should have a data-type attribute
* specifying the class to load
*/
var
moduleType
=
$
(
element
).
data
(
'type'
),
module
;
var
moduleType
,
module
;
if
(
initArgs
)
{
moduleType
=
initArgs
[
'xmodule-type'
];
}
if
(
!
moduleType
)
{
moduleType
=
$
(
element
).
data
(
'type'
);
}
if
(
moduleType
===
'None'
)
{
return
;
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
b50876fc
...
...
@@ -237,12 +237,13 @@ class HTMLSnippet(object):
.
format
(
self
.
__class__
))
def
shim_xmodule_js
(
fragment
):
def
shim_xmodule_js
(
block
,
fragment
):
"""
Set up the XBlock -> XModule shim on the supplied :class:`xblock.fragment.Fragment`
"""
if
not
fragment
.
js_init_fn
:
fragment
.
initialize_js
(
'XBlockToXModuleShim'
)
fragment
.
json_init_args
=
{
'xmodule-type'
:
block
.
js_module_name
}
class
XModuleMixin
(
XBlockMixin
):
...
...
common/static/js/xblock/core.js
View file @
b50876fc
...
...
@@ -32,7 +32,7 @@
}
function
initArgs
(
element
)
{
var
initargs
=
$
(
'.xblock_json_init_args'
,
element
).
text
();
var
initargs
=
$
(
element
).
children
(
'.xblock-json-init-args'
).
remove
(
).
text
();
return
initargs
?
JSON
.
parse
(
initargs
)
:
{};
}
...
...
common/templates/xblock_wrapper.html
View file @
b50876fc
<div
class=
"${' '.join(classes) | n}"
${
data_attributes
}
>
% if js_init_parameters:
<script
type=
"json/xblock-args"
class=
"xblock
_json_init_
args"
>
<script
type=
"json/xblock-args"
class=
"xblock
-json-init-
args"
>
$
{
js_init_parameters
}
</script>
% endif
${content}
${content}
</div>
lms/djangoapps/courseware/tests/test_module_render.py
View file @
b50876fc
...
...
@@ -432,7 +432,7 @@ class TestHandleXBlockCallback(ModuleStoreTestCase, LoginEnrollmentTestCase):
for
section
in
expected
:
self
.
assertIn
(
section
,
content
)
doc
=
PyQuery
(
content
[
'html'
])
self
.
assertEquals
(
len
(
doc
(
'div.xblock
.xblock-student_view
'
)),
1
)
self
.
assertEquals
(
len
(
doc
(
'div.xblock
-student_view-videosequence
'
)),
1
)
@ddt.ddt
...
...
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