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
efb86f21
Commit
efb86f21
authored
Jan 12, 2016
by
Dmitry Viskov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XBlockAsides Hello world example
parent
1ebb78c9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
0 deletions
+128
-0
cms/djangoapps/contentstore/views/preview.py
+14
-0
cms/lib/xblock/tagging.py
+92
-0
cms/templates/structured_tags_block.html
+16
-0
cms/templates/studio_xblock_wrapper.html
+2
-0
common/lib/xmodule/setup.py
+4
-0
No files found.
cms/djangoapps/contentstore/views/preview.py
View file @
efb86f21
...
@@ -119,6 +119,20 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method
...
@@ -119,6 +119,20 @@ class PreviewModuleSystem(ModuleSystem): # pylint: disable=abstract-method
"""
"""
return
self
.
wrap_xblock
(
block
,
view_name
,
Fragment
(),
context
)
return
self
.
wrap_xblock
(
block
,
view_name
,
Fragment
(),
context
)
def
layout_asides
(
self
,
block
,
context
,
frag
,
view_name
,
aside_frag_fns
):
position_for_asides
=
'<!-- footer for xblock_aside -->'
result
=
Fragment
()
result
.
add_frag_resources
(
frag
)
for
aside
,
aside_fn
in
aside_frag_fns
:
aside_frag
=
self
.
wrap_aside
(
block
,
aside
,
view_name
,
aside_fn
(
block
,
context
),
context
)
aside
.
save
()
result
.
add_frag_resources
(
aside_frag
)
frag
.
content
=
frag
.
content
.
replace
(
position_for_asides
,
position_for_asides
+
aside_frag
.
content
)
result
.
add_content
(
frag
.
content
)
return
result
class
StudioPermissionsService
(
object
):
class
StudioPermissionsService
(
object
):
"""
"""
...
...
cms/lib/xblock/tagging.py
0 → 100644
View file @
efb86f21
"""
Example implementation of Structured Tagging based on XBlockAsides
"""
from
xblock.core
import
XBlockAside
from
xblock.fragment
import
Fragment
from
xblock.fields
import
Scope
,
Dict
from
xmodule.x_module
import
STUDENT_VIEW
from
xmodule.capa_module
import
CapaModule
from
abc
import
ABCMeta
,
abstractproperty
from
edxmako.shortcuts
import
render_to_string
_
=
lambda
text
:
text
class
AbstractTag
(
object
):
"""
Abstract class for tags
"""
__metaclass__
=
ABCMeta
@abstractproperty
def
key
(
self
):
"""
Subclasses must implement key
"""
raise
NotImplementedError
(
'Subclasses must implement key'
)
@abstractproperty
def
name
(
self
):
"""
Subclasses must implement name
"""
raise
NotImplementedError
(
'Subclasses must implement name'
)
@abstractproperty
def
allowed_values
(
self
):
"""
Subclasses must implement allowed_values
"""
raise
NotImplementedError
(
'Subclasses must implement allowed_values'
)
class
LearningOutcomeTag
(
AbstractTag
):
"""
Particular implementation tags for learning outcomes
"""
@property
def
key
(
self
):
""" Identifier for the learning outcome selector """
return
'learning_outcome_tag'
@property
def
name
(
self
):
""" Label for the learning outcome selector """
return
_
(
'Learning outcomes'
)
@property
def
allowed_values
(
self
):
""" Allowed values for the learning outcome selector """
return
{
'test1'
:
'Test 1'
,
'test2'
:
'Test 2'
,
'test3'
:
'Test 3'
}
class
StructuredTagsAside
(
XBlockAside
):
"""
Aside that allows tagging blocks
"""
saved_tags
=
Dict
(
help
=
_
(
"Dictionary with the available tags"
),
scope
=
Scope
.
content
,
default
=
{},)
available_tags
=
[
LearningOutcomeTag
()]
@XBlockAside.aside_for
(
STUDENT_VIEW
)
def
student_view_aside
(
self
,
block
,
context
):
"""
Display the tag selector with specific categories and allowed values,
depending on the context.
"""
if
isinstance
(
block
,
CapaModule
):
tags
=
[]
for
tag
in
self
.
available_tags
:
tags
.
append
({
'key'
:
tag
.
key
,
'title'
:
tag
.
name
,
'values'
:
tag
.
allowed_values
,
'current_value'
:
self
.
saved_tags
.
get
(
tag
.
key
,
None
),
})
return
Fragment
(
render_to_string
(
'structured_tags_block.html'
,
{
'tags'
:
tags
}))
#return Fragment(u'<div class="xblock-render">Hello world!!!</div>')
else
:
return
Fragment
(
u''
)
cms/templates/structured_tags_block.html
0 → 100644
View file @
efb86f21
<div
class=
"xblock-render"
>
% for tag in tags:
<label
for=
"problem_tags_${tag['key']}"
>
${tag['title']}
</label>
:
<select
id=
"problem_tags_${tag['key']}"
name=
"problem_tags_${tag['key']}"
>
% for k,v in tag['values'].iteritems():
<
%
selected =
''
if
k =
=
tag
['
current_value
']
:
selected =
'selected'
%
>
<option
value=
"${k}"
${
selected
}
>
${v}
</option>
% endfor
% endfor
</select>
</div>
\ No newline at end of file
cms/templates/studio_xblock_wrapper.html
View file @
efb86f21
...
@@ -150,7 +150,9 @@ messages = xblock.validate().to_json()
...
@@ -150,7 +150,9 @@ messages = xblock.validate().to_json()
% endif
% endif
% if not is_root:
% if not is_root:
<!-- footer for xblock_aside -->
</section>
</section>
% if is_reorderable:
% if is_reorderable:
</li>
</li>
% else:
% else:
...
...
common/lib/xmodule/setup.py
View file @
efb86f21
...
@@ -44,6 +44,9 @@ XBLOCKS = [
...
@@ -44,6 +44,9 @@ XBLOCKS = [
"vertical = xmodule.vertical_block:VerticalBlock"
,
"vertical = xmodule.vertical_block:VerticalBlock"
,
"wrapper = xmodule.wrapper_module:WrapperBlock"
,
"wrapper = xmodule.wrapper_module:WrapperBlock"
,
]
]
XBLOCKS_ASIDES
=
[
'tagging_aside = cms.lib.xblock.tagging:StructuredTagsAside'
,
]
setup
(
setup
(
name
=
"XModule"
,
name
=
"XModule"
,
...
@@ -66,6 +69,7 @@ setup(
...
@@ -66,6 +69,7 @@ setup(
entry_points
=
{
entry_points
=
{
'xblock.v1'
:
XMODULES
+
XBLOCKS
,
'xblock.v1'
:
XMODULES
+
XBLOCKS
,
'xmodule.v1'
:
XMODULES
,
'xmodule.v1'
:
XMODULES
,
'xblock_asides.v1'
:
XBLOCKS_ASIDES
,
'console_scripts'
:
[
'console_scripts'
:
[
'xmodule_assets = xmodule.static_content:main'
,
'xmodule_assets = xmodule.static_content:main'
,
],
],
...
...
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