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
8ed33b3d
Commit
8ed33b3d
authored
Jul 29, 2013
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #478 from edx/cale/xmodule-descriptor-studio-view
Cale/xmodule descriptor studio view
parents
50ef0d1c
802d36c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
5 deletions
+83
-5
common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py
+71
-5
common/lib/xmodule/xmodule/x_module.py
+12
-0
No files found.
common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py
View file @
8ed33b3d
...
@@ -53,6 +53,13 @@ CONTAINER_XMODULES = (
...
@@ -53,6 +53,13 @@ CONTAINER_XMODULES = (
CourseDescriptor
,
CourseDescriptor
,
)
)
# These modules are editable in studio yet
NOT_STUDIO_EDITABLE
=
(
CrowdsourceHinterDescriptor
,
GraphicalSliderToolDescriptor
,
PollDescriptor
)
class
TestXBlockWrapper
(
object
):
class
TestXBlockWrapper
(
object
):
...
@@ -60,12 +67,11 @@ class TestXBlockWrapper(object):
...
@@ -60,12 +67,11 @@ class TestXBlockWrapper(object):
def
leaf_module_runtime
(
self
):
def
leaf_module_runtime
(
self
):
runtime
=
Mock
()
runtime
=
Mock
()
runtime
.
render_template
=
lambda
*
args
,
**
kwargs
:
unicode
((
args
,
kwargs
))
runtime
.
render_template
=
lambda
*
args
,
**
kwargs
:
unicode
((
args
,
kwargs
))
runtime
.
anonymous_student_id
=
'anonymous_student_id'
runtime
.
anonymous_student_id
=
'
dummy_
anonymous_student_id'
runtime
.
open_ended_grading_interface
=
{}
runtime
.
open_ended_grading_interface
=
{}
runtime
.
seed
=
5
runtime
.
seed
=
5
runtime
.
get
=
lambda
x
:
getattr
(
runtime
,
x
)
runtime
.
get
=
lambda
x
:
getattr
(
runtime
,
x
)
runtime
.
position
=
2
runtime
.
ajax_url
=
'dummy_ajax_url'
runtime
.
ajax_url
=
'ajax_url'
runtime
.
xblock_model_data
=
lambda
d
:
d
.
_model_data
runtime
.
xblock_model_data
=
lambda
d
:
d
.
_model_data
return
runtime
return
runtime
...
@@ -78,7 +84,7 @@ class TestXBlockWrapper(object):
...
@@ -78,7 +84,7 @@ class TestXBlockWrapper(object):
def
leaf_descriptor
(
self
,
descriptor_cls
):
def
leaf_descriptor
(
self
,
descriptor_cls
):
return
descriptor_cls
(
return
descriptor_cls
(
self
.
leaf_descriptor_runtime
,
self
.
leaf_descriptor_runtime
,
{
'location'
:
'i4x://org/course/cat
a
gory/name'
}
{
'location'
:
'i4x://org/course/cat
e
gory/name'
}
)
)
def
leaf_module
(
self
,
descriptor_cls
):
def
leaf_module
(
self
,
descriptor_cls
):
...
@@ -90,6 +96,7 @@ class TestXBlockWrapper(object):
...
@@ -90,6 +96,7 @@ class TestXBlockWrapper(object):
runtime
.
get_module
.
side_effect
=
lambda
x
:
self
.
leaf_module
(
HtmlDescriptor
)
runtime
.
get_module
.
side_effect
=
lambda
x
:
self
.
leaf_module
(
HtmlDescriptor
)
else
:
else
:
runtime
.
get_module
.
side_effect
=
lambda
x
:
self
.
container_module
(
VerticalDescriptor
,
depth
-
1
)
runtime
.
get_module
.
side_effect
=
lambda
x
:
self
.
container_module
(
VerticalDescriptor
,
depth
-
1
)
runtime
.
position
=
2
return
runtime
return
runtime
@property
@property
...
@@ -102,7 +109,7 @@ class TestXBlockWrapper(object):
...
@@ -102,7 +109,7 @@ class TestXBlockWrapper(object):
return
descriptor_cls
(
return
descriptor_cls
(
self
.
container_descriptor_runtime
,
self
.
container_descriptor_runtime
,
{
{
'location'
:
'i4x://org/course/cat
a
gory/name'
,
'location'
:
'i4x://org/course/cat
e
gory/name'
,
'children'
:
range
(
3
)
'children'
:
range
(
3
)
}
}
)
)
...
@@ -158,3 +165,62 @@ class TestStudentView(TestXBlockWrapper):
...
@@ -158,3 +165,62 @@ class TestStudentView(TestXBlockWrapper):
def
check_student_view_container_node_xblocks_only
(
self
,
descriptor_cls
):
def
check_student_view_container_node_xblocks_only
(
self
,
descriptor_cls
):
raise
SkipTest
(
"XBlock support in XModules not yet fully implemented"
)
raise
SkipTest
(
"XBlock support in XModules not yet fully implemented"
)
class
TestStudioView
(
TestXBlockWrapper
):
# Test that for all of the Descriptors listed in LEAF_XMODULES,
# the studio_view wrapper returns the same thing in its content
# as get_html returns
def
test_studio_view_leaf_node
(
self
):
for
descriptor_cls
in
LEAF_XMODULES
:
yield
self
.
check_studio_view_leaf_node
,
descriptor_cls
# Check that when a descriptor is instantiated from descriptor_cls
# it generates the same thing from studio_view that it does from get_html
def
check_studio_view_leaf_node
(
self
,
descriptor_cls
):
if
descriptor_cls
in
NOT_STUDIO_EDITABLE
:
raise
SkipTest
(
descriptor_cls
.
__name__
+
"is not editable in studio"
)
descriptor
=
self
.
leaf_descriptor
(
descriptor_cls
)
assert_equal
(
descriptor
.
get_html
(),
descriptor
.
studio_view
(
None
)
.
content
)
# Test that for all of the Descriptors listed in CONTAINER_XMODULES
# render the same thing using studio_view as they do using get_html, under the following conditions:
# a) All of its descendents are xmodules
# b) Some of its descendents are xmodules and some are xblocks
# c) All of its descendents are xblocks
def
test_studio_view_container_node
(
self
):
for
descriptor_cls
in
CONTAINER_XMODULES
:
yield
self
.
check_studio_view_container_node_xmodules_only
,
descriptor_cls
yield
self
.
check_studio_view_container_node_mixed
,
descriptor_cls
yield
self
.
check_studio_view_container_node_xblocks_only
,
descriptor_cls
# Check that when a descriptor is generated from descriptor_cls
# with only xmodule children, it generates the same html from studio_view
# as it does using get_html
def
check_studio_view_container_node_xmodules_only
(
self
,
descriptor_cls
):
if
descriptor_cls
in
NOT_STUDIO_EDITABLE
:
raise
SkipTest
(
descriptor_cls
.
__name__
+
"is not editable in studio"
)
descriptor
=
self
.
container_descriptor
(
descriptor_cls
)
assert_equal
(
descriptor
.
get_html
(),
descriptor
.
studio_view
(
None
)
.
content
)
# Check that when a descriptor is generated from descriptor_cls
# with mixed xmodule and xblock children, it generates the same html from studio_view
# as it does using get_html
def
check_studio_view_container_node_mixed
(
self
,
descriptor_cls
):
if
descriptor_cls
in
NOT_STUDIO_EDITABLE
:
raise
SkipTest
(
descriptor_cls
.
__name__
+
"is not editable in studio"
)
raise
SkipTest
(
"XBlock support in XDescriptor not yet fully implemented"
)
# Check that when a descriptor is generated from descriptor_cls
# with only xblock children, it generates the same html from studio_view
# as it does using get_html
def
check_studio_view_container_node_xblocks_only
(
self
,
descriptor_cls
):
if
descriptor_cls
in
NOT_STUDIO_EDITABLE
:
raise
SkipTest
(
descriptor_cls
.
__name__
+
"is not editable in studio"
)
raise
SkipTest
(
"XBlock support in XModules not yet fully implemented"
)
common/lib/xmodule/xmodule/x_module.py
View file @
8ed33b3d
...
@@ -794,6 +794,18 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
...
@@ -794,6 +794,18 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
return
metadata_fields
return
metadata_fields
# ~~~~~~~~~~~~~~~ XBlock API Wrappers ~~~~~~~~~~~~~~~~
def
studio_view
(
self
,
context
):
"""
Return a fragment with the html from this XModuleDescriptor's editing view
Doesn't yet add any of the javascript to the fragment, nor the css.
Also doesn't expect any javascript binding, yet.
Makes no use of the context parameter
"""
return
Fragment
(
self
.
get_html
())
class
DescriptorSystem
(
object
):
class
DescriptorSystem
(
object
):
def
__init__
(
self
,
load_item
,
resources_fs
,
error_tracker
,
**
kwargs
):
def
__init__
(
self
,
load_item
,
resources_fs
,
error_tracker
,
**
kwargs
):
...
...
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