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
d61c91c1
Commit
d61c91c1
authored
Dec 18, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors around error descriptors and custom tag modules
parent
8693d288
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
19 deletions
+17
-19
common/lib/xmodule/xmodule/error_module.py
+6
-2
common/lib/xmodule/xmodule/raw_module.py
+6
-2
common/lib/xmodule/xmodule/template_module.py
+2
-7
lms/djangoapps/courseware/views.py
+3
-8
No files found.
common/lib/xmodule/xmodule/error_module.py
View file @
d61c91c1
...
...
@@ -22,6 +22,10 @@ log = logging.getLogger(__name__)
class
ErrorModule
(
XModule
):
contents
=
String
(
scope
=
Scope
.
content
)
error_msg
=
String
(
scope
=
Scope
.
content
)
def
get_html
(
self
):
'''Show an error to staff.
TODO (vshnayder): proper style, divs, etc.
...
...
@@ -29,8 +33,8 @@ class ErrorModule(XModule):
# staff get to see all the details
return
self
.
system
.
render_template
(
'module-error.html'
,
{
'staff_access'
:
True
,
'data'
:
self
.
definition
[
'data'
][
'contents'
]
,
'error'
:
self
.
definition
[
'data'
][
'error_msg'
]
,
'data'
:
self
.
contents
,
'error'
:
self
.
error_msg
,
})
...
...
common/lib/xmodule/xmodule/raw_module.py
View file @
d61c91c1
...
...
@@ -3,25 +3,29 @@ from xmodule.editing_module import XMLEditingDescriptor
from
xmodule.xml_module
import
XmlDescriptor
import
logging
import
sys
from
.model
import
String
,
Scope
log
=
logging
.
getLogger
(
__name__
)
class
RawDescriptor
(
XmlDescriptor
,
XMLEditingDescriptor
):
"""
Module that provides a raw editing view of its data and children. It
requires that the definition xml is valid.
"""
data
=
String
(
help
=
"XML data for the module"
,
scope
=
Scope
.
content
)
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
return
{
'data'
:
etree
.
tostring
(
xml_object
,
pretty_print
=
True
)},
[]
def
definition_to_xml
(
self
,
resource_fs
):
try
:
return
etree
.
fromstring
(
self
.
d
efinition
[
'data'
]
)
return
etree
.
fromstring
(
self
.
d
ata
)
except
etree
.
XMLSyntaxError
as
err
:
# Can't recover here, so just add some info and
# re-raise
lines
=
self
.
d
efinition
[
'data'
]
.
split
(
'
\n
'
)
lines
=
self
.
d
ata
.
split
(
'
\n
'
)
line
,
offset
=
err
.
position
msg
=
(
"Unable to create xml for problem {loc}. "
"Context: '{context}'"
.
format
(
...
...
common/lib/xmodule/xmodule/template_module.py
View file @
d61c91c1
...
...
@@ -27,11 +27,6 @@ class CustomTagModule(XModule):
More information given in <a href="/book/234">the text</a>
"""
def
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
=
None
,
shared_state
=
None
,
**
kwargs
):
XModule
.
__init__
(
self
,
system
,
location
,
definition
,
descriptor
,
instance_state
,
shared_state
,
**
kwargs
)
def
get_html
(
self
):
return
self
.
descriptor
.
rendered_html
...
...
@@ -62,14 +57,14 @@ class CustomTagDescriptor(RawDescriptor):
template_loc
=
self
.
location
.
_replace
(
category
=
'custom_tag_template'
,
name
=
template_name
)
template_module
=
modulestore
()
.
get_instance
(
system
.
course_id
,
template_loc
)
template_module_data
=
template_module
.
d
efinition
[
'data'
]
template_module_data
=
template_module
.
d
ata
template
=
Template
(
template_module_data
)
return
template
.
render
(
**
params
)
@property
def
rendered_html
(
self
):
return
self
.
render_template
(
self
.
system
,
self
.
d
efinition
[
'data'
]
)
return
self
.
render_template
(
self
.
system
,
self
.
d
ata
)
def
export_to_file
(
self
):
"""
...
...
lms/djangoapps/courseware/views.py
View file @
d61c91c1
...
...
@@ -143,10 +143,9 @@ def redirect_to_course_position(course_module, first_time):
'chapter'
:
chapter
.
url_name
,
'section'
:
section
.
url_name
}))
def
save_child_position
(
seq_module
,
child_name
,
instance_module
):
def
save_child_position
(
seq_module
,
child_name
):
"""
child_name: url_name of the child
instance_module: the StudentModule object for the seq_module
"""
for
i
,
c
in
enumerate
(
seq_module
.
get_display_items
()):
if
c
.
url_name
==
child_name
:
...
...
@@ -155,8 +154,6 @@ def save_child_position(seq_module, child_name, instance_module):
# Only save if position changed
if
position
!=
seq_module
.
position
:
seq_module
.
position
=
position
instance_module
.
state
=
seq_module
.
get_instance_state
()
instance_module
.
save
()
@login_required
@ensure_csrf_cookie
...
...
@@ -222,8 +219,7 @@ def index(request, course_id, chapter=None, section=None,
chapter_descriptor
=
course
.
get_child_by_url_name
(
chapter
)
if
chapter_descriptor
is
not
None
:
instance_module
=
get_instance_module
(
course_id
,
request
.
user
,
course_module
,
student_module_cache
)
save_child_position
(
course_module
,
chapter
,
instance_module
)
save_child_position
(
course_module
,
chapter
)
else
:
raise
Http404
...
...
@@ -250,8 +246,7 @@ def index(request, course_id, chapter=None, section=None,
raise
Http404
# Save where we are in the chapter
instance_module
=
get_instance_module
(
course_id
,
request
.
user
,
chapter_module
,
student_module_cache
)
save_child_position
(
chapter_module
,
section
,
instance_module
)
save_child_position
(
chapter_module
,
section
)
context
[
'content'
]
=
section_module
.
get_html
()
...
...
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