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
40d7e8ad
Commit
40d7e8ad
authored
Mar 05, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved problem HTML error handling to its own function
parent
60855242
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
common/lib/xmodule/xmodule/capa_module.py
+23
-7
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
40d7e8ad
...
...
@@ -319,13 +319,15 @@ class CapaModule(XModule):
else
:
return
True
def
get_problem_html
(
self
,
encapsulate
=
True
):
'''Return html for the problem. Adds check, reset, save buttons
as necessary based on the problem config and state.'''
def
handle_problem_html_error
(
self
,
err
):
"""
Change our problem to a dummy problem containing
a warning message to display to users.
try
:
html
=
self
.
lcp
.
get_html
()
except
Exception
,
err
:
Returns the HTML to show to users
*err* is the Exception encountered while rendering the problem HTML.
"""
log
.
exception
(
err
)
# TODO (vshnayder): another switch on DEBUG.
...
...
@@ -337,9 +339,10 @@ class CapaModule(XModule):
msg
+=
'<p>Error:</p><p><pre>
%
s</pre></p>'
%
str
(
err
)
.
replace
(
'<'
,
'<'
)
msg
+=
'<p><pre>
%
s</pre></p>'
%
traceback
.
format_exc
()
.
replace
(
'<'
,
'<'
)
html
=
msg
else
:
# We're in non-debug mode, and possibly even in production. We want
# to avoid bricking of problem as much as possible
else
:
# Presumably, student submission has corrupted LoncapaProblem HTML.
# First, pull down all student answers
...
...
@@ -380,6 +383,19 @@ class CapaModule(XModule):
log
.
exception
(
err
)
raise
return
html
def
get_problem_html
(
self
,
encapsulate
=
True
):
'''Return html for the problem. Adds check, reset, save buttons
as necessary based on the problem config and state.'''
try
:
html
=
self
.
lcp
.
get_html
()
except
Exception
,
err
:
return
self
.
handle_problem_html_error
(
err
)
content
=
{
'name'
:
self
.
display_name
,
'html'
:
html
,
'weight'
:
self
.
descriptor
.
weight
,
...
...
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