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
906008dc
Commit
906008dc
authored
Sep 15, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset CapaProblem when state HTML is corrupt
parent
04c83d52
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
common/lib/xmodule/xmodule/capa_module.py
+29
-7
No files found.
common/lib/xmodule/xmodule/capa_module.py
View file @
906008dc
...
...
@@ -131,17 +131,17 @@ class CapaModule(XModule):
self
.
weight
=
None
if
self
.
rerandomize
==
'never'
:
seed
=
1
se
lf
.
se
ed
=
1
elif
self
.
rerandomize
==
"per_student"
and
hasattr
(
self
.
system
,
'id'
):
seed
=
system
.
id
se
lf
.
se
ed
=
system
.
id
else
:
seed
=
None
se
lf
.
se
ed
=
None
try
:
# TODO (vshnayder): move as much as possible of this work and error
# checking to descriptor load time
self
.
lcp
=
LoncapaProblem
(
self
.
definition
[
'data'
],
self
.
location
.
html_id
(),
instance_state
,
seed
=
seed
,
system
=
self
.
system
)
instance_state
,
seed
=
se
lf
.
se
ed
,
system
=
self
.
system
)
except
Exception
as
err
:
msg
=
'cannot create LoncapaProblem {loc}: {err}'
.
format
(
loc
=
self
.
location
.
url
(),
err
=
err
)
...
...
@@ -160,7 +160,7 @@ class CapaModule(XModule):
(
self
.
location
.
url
(),
msg
))
self
.
lcp
=
LoncapaProblem
(
problem_text
,
self
.
location
.
html_id
(),
instance_state
,
seed
=
seed
,
system
=
self
.
system
)
instance_state
,
seed
=
se
lf
.
se
ed
,
system
=
self
.
system
)
else
:
# add extra info and raise
raise
Exception
(
msg
),
None
,
sys
.
exc_info
()[
2
]
...
...
@@ -220,9 +220,10 @@ class CapaModule(XModule):
try
:
html
=
self
.
lcp
.
get_html
()
except
Exception
,
err
:
log
.
exception
(
err
)
# TODO (vshnayder): another switch on DEBUG.
if
self
.
system
.
DEBUG
:
log
.
exception
(
err
)
msg
=
(
'[courseware.capa.capa_module] <font size="+1" color="red">'
'Failed to generate HTML for problem
%
s</font>'
%
...
...
@@ -231,7 +232,28 @@ class CapaModule(XModule):
msg
+=
'<p><pre>
%
s</pre></p>'
%
traceback
.
format_exc
()
.
replace
(
'<'
,
'<'
)
html
=
msg
else
:
raise
# We're in non-debug mode, and possibly even in production. We want
# to avoid bricking of problem as much as possible
# Presumably, student submission has corrupted LoncapaProblem HTML.
# So, let's try generate a fresh LoncapaProblem
self
.
lcp
=
LoncapaProblem
(
self
.
definition
[
'data'
],
self
.
location
.
html_id
(),
state
=
None
,
# Tabula rasa
seed
=
self
.
seed
,
system
=
self
.
system
)
# Prepend a scary warning to the student
warning
=
'<div class="capa_reset">'
warning
+=
'<p>Problem state was corruped by invalid input. '
warning
+=
'Problem reset to initial state! '
warning
+=
'If problem persists, please contact the course staff.</p>'
warning
+=
'</div>'
html
=
warning
try
:
html
+=
self
.
lcp
.
get_html
()
except
Exception
,
err
:
# Couldn't do it. Give up
log
.
exception
(
err
)
raise
content
=
{
'name'
:
self
.
display_name
,
'html'
:
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