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
bacce3e6
Commit
bacce3e6
authored
Jun 29, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load module contents from the file specified by the filename attribute
parent
9c715b60
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
+29
-1
common/lib/xmodule/html_module.py
+5
-0
common/lib/xmodule/xml_module.py
+24
-1
No files found.
common/lib/xmodule/html_module.py
View file @
bacce3e6
...
...
@@ -24,6 +24,11 @@ class HtmlDescriptor(RawDescriptor):
"""
mako_template
=
"widgets/html-edit.html"
module_class
=
HtmlModule
filename_extension
=
"html"
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/module/html.coffee'
)]}
js_module
=
'HTML'
@classmethod
def
definition_from_file
(
cls
,
file
,
system
):
return
{
'data'
:
file
.
read
()}
common/lib/xmodule/xml_module.py
View file @
bacce3e6
...
...
@@ -56,15 +56,30 @@ class XmlDescriptor(XModuleDescriptor):
Mixin class for standardized parsing of from xml
"""
# Extension to append to filename paths
filename_extension
=
'xml'
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
"""
Return the definition to be passed to the newly created descriptor
during from_xml
xml_object: An etree Element
"""
raise
NotImplementedError
(
"
%
s does not implement definition_from_xml"
%
cls
.
__name__
)
@classmethod
def
definition_from_file
(
cls
,
file
,
system
):
"""
Return the definition to be passed to the newly created descriptor
during from_xml
file: File pointer
"""
return
cls
.
definition_from_xml
(
etree
.
parse
(
file
),
system
)
@classmethod
def
from_xml
(
cls
,
xml_data
,
system
,
org
=
None
,
course
=
None
):
"""
Creates an instance of this descriptor from the supplied xml_data.
...
...
@@ -93,9 +108,17 @@ class XmlDescriptor(XModuleDescriptor):
return
metadata
def
definition_loader
():
filename
=
xml_object
.
get
(
'filename'
)
if
filename
is
None
:
return
cls
.
definition_from_xml
(
xml_object
,
system
)
else
:
filepath
=
'{type}/{name}.{ext}'
.
format
(
type
=
xml_object
.
tag
,
name
=
filename
,
ext
=
cls
.
filename_extension
)
return
cls
.
definition_from_file
(
system
.
resources_fs
.
open
(
filepath
),
system
)
return
cls
(
system
,
LazyLoadingDict
(
lambda
:
cls
.
definition_from_xml
(
xml_object
,
system
)
),
LazyLoadingDict
(
definition_loader
),
location
=
[
'i4x'
,
org
,
course
,
...
...
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