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
f6d4f960
Commit
f6d4f960
authored
Jun 28, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make custom tags work in the LMS
parent
42c0445e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
13 deletions
+35
-13
common/lib/xmodule/setup.py
+8
-2
common/lib/xmodule/template_module.py
+10
-11
common/lib/xmodule/translation_module.py
+17
-0
No files found.
common/lib/xmodule/setup.py
View file @
f6d4f960
...
...
@@ -13,15 +13,21 @@ setup(
# for a description of entry_points
entry_points
=
{
'xmodule.v1'
:
[
"book = xmodule.translation_module:TranslateCustomTagDescriptor"
,
"chapter = xmodule.seq_module:SequenceDescriptor"
,
"course = xmodule.seq_module:SequenceDescriptor"
,
"customtag = xmodule.template_module:CustomTagDescriptor"
,
"discuss = xmodule.translation_module:TranslateCustomTagDescriptor"
,
"html = xmodule.html_module:HtmlDescriptor"
,
"image = xmodule.translation_module:TranslateCustomTagDescriptor"
,
"problem = xmodule.capa_module:CapaDescriptor"
,
"problemset = xmodule.seq_module:SequenceDescriptor"
,
"section = xmodule.translation_module:SemanticSectionDescriptor"
,
"sequential = xmodule.seq_module:SequenceDescriptor"
,
"slides = xmodule.translation_module:TranslateCustomTagDescriptor"
,
"vertical = xmodule.vertical_module:VerticalDescriptor"
,
"problem = xmodule.capa_module:CapaDescriptor"
,
"problemset = xmodule.seq_module:SequenceDescriptor"
,
"video = xmodule.video_module:VideoDescriptor"
,
"videodev = xmodule.translation_module:TranslateCustomTagDescriptor"
,
"videosequence = xmodule.seq_module:SequenceDescriptor"
,
]
}
...
...
common/lib/xmodule/template_module.py
View file @
f6d4f960
import
json
from
x_module
import
XModule
,
XModuleDescriptor
from
xmodule.x_module
import
XModule
from
xmodule.raw_module
import
RawDescriptor
from
lxml
import
etree
class
ModuleDescriptor
(
XModuleDescriptor
):
pass
class
Module
(
XModule
):
class
CustomTagModule
(
XModule
):
"""
This module supports tags of the form
<customtag option="val" option2="val2">
...
...
@@ -34,9 +29,13 @@ class Module(XModule):
def
get_html
(
self
):
return
self
.
html
def
__init__
(
self
,
system
,
xml
,
item_id
,
instance_state
=
None
,
shared_state
=
None
):
XModule
.
__init__
(
self
,
system
,
xml
,
item_id
,
instance_state
,
shared_state
)
xmltree
=
etree
.
fromstring
(
xml
)
def
__init__
(
self
,
system
,
location
,
definition
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
instance_state
,
shared_state
,
**
kwargs
)
xmltree
=
etree
.
fromstring
(
self
.
definition
[
'data'
]
)
filename
=
xmltree
.
find
(
'impl'
)
.
text
params
=
dict
(
xmltree
.
items
())
self
.
html
=
self
.
system
.
render_template
(
filename
,
params
,
namespace
=
'custom_tags'
)
class
CustomTagDescriptor
(
RawDescriptor
):
module_class
=
CustomTagModule
common/lib/xmodule/translation_module.py
View file @
f6d4f960
...
...
@@ -65,3 +65,20 @@ class SemanticSectionDescriptor(XModuleDescriptor):
else
:
xml_object
.
tag
=
'sequence'
return
system
.
process_xml
(
etree
.
tostring
(
xml_object
))
class
TranslateCustomTagDescriptor
(
XModuleDescriptor
):
@classmethod
def
from_xml
(
cls
,
xml_data
,
system
,
org
=
None
,
course
=
None
):
"""
Transforms the xml_data from <$custom_tag attr="" attr=""/> to
<customtag attr="" attr=""><impl>$custom_tag</impl></customtag>
"""
xml_object
=
etree
.
fromstring
(
xml_data
)
tag
=
xml_object
.
tag
xml_object
.
tag
=
'customtag'
impl
=
etree
.
SubElement
(
xml_object
,
'impl'
)
impl
.
text
=
tag
return
system
.
process_xml
(
etree
.
tostring
(
xml_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