Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
bae90ab1
Commit
bae90ab1
authored
12 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Make custom tags work in the LMS
parent
c140fe87
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/lib/xmodule/setup.py
+8
-2
8 additions, 2 deletions
common/lib/xmodule/setup.py
common/lib/xmodule/template_module.py
+10
-11
10 additions, 11 deletions
common/lib/xmodule/template_module.py
common/lib/xmodule/translation_module.py
+17
-0
17 additions, 0 deletions
common/lib/xmodule/translation_module.py
with
35 additions
and
13 deletions
common/lib/xmodule/setup.py
+
8
−
2
View file @
bae90ab1
...
...
@@ -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
"
,
]
}
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/template_module.py
+
10
−
11
View file @
bae90ab1
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
This diff is collapsed.
Click to expand it.
common/lib/xmodule/translation_module.py
+
17
−
0
View file @
bae90ab1
...
...
@@ -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
))
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment