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
99cd3faf
Commit
99cd3faf
authored
Mar 27, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added error handling of XModule processing errors to CMS
Added tests for SchematicResponse error handling
parent
ac86687f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
cms/djangoapps/contentstore/views.py
+7
-1
common/lib/capa/capa/tests/test_responsetypes.py
+17
-4
No files found.
cms/djangoapps/contentstore/views.py
View file @
99cd3faf
...
...
@@ -42,7 +42,7 @@ from xmodule.modulestore.mongo import MongoUsage
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
xmodule.modulestore.django
import
modulestore
from
xmodule_modifiers
import
replace_static_urls
,
wrap_xmodule
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
,
ProcessingError
from
functools
import
partial
from
xmodule.contentstore.django
import
contentstore
...
...
@@ -448,9 +448,15 @@ def preview_dispatch(request, preview_id, location, dispatch=None):
# Let the module handle the AJAX
try
:
ajax_return
=
instance
.
handle_ajax
(
dispatch
,
request
.
POST
)
except
NotFoundError
:
log
.
exception
(
"Module indicating to user that request doesn't exist"
)
raise
Http404
except
ProcessingError
:
log
.
exception
(
"Module raised an error while processing AJAX request"
)
raise
Http404
except
:
log
.
exception
(
"error processing ajax call"
)
raise
...
...
common/lib/capa/capa/tests/test_responsetypes.py
View file @
99cd3faf
...
...
@@ -13,7 +13,8 @@ import textwrap
from
.
import
test_system
import
capa.capa_problem
as
lcp
from
capa.responsetypes
import
LoncapaProblemError
,
StudentInputError
from
capa.responsetypes
import
LoncapaProblemError
,
\
StudentInputError
,
ResponseError
from
capa.correctmap
import
CorrectMap
from
capa.util
import
convert_files_to_filenames
from
capa.xqueue_interface
import
dateformat
...
...
@@ -865,7 +866,7 @@ class CustomResponseTest(ResponseTest):
problem
=
self
.
build_problem
(
script
=
script
,
cfn
=
"check_func"
)
# Expect that an exception gets raised when we check the answer
with
self
.
assertRaises
(
StudentInput
Error
):
with
self
.
assertRaises
(
Response
Error
):
problem
.
grade_answers
({
'1_2_1'
:
'42'
})
def
test_script_exception_inline
(
self
):
...
...
@@ -875,7 +876,7 @@ class CustomResponseTest(ResponseTest):
problem
=
self
.
build_problem
(
answer
=
script
)
# Expect that an exception gets raised when we check the answer
with
self
.
assertRaises
(
StudentInput
Error
):
with
self
.
assertRaises
(
Response
Error
):
problem
.
grade_answers
({
'1_2_1'
:
'42'
})
def
test_invalid_dict_exception
(
self
):
...
...
@@ -889,7 +890,7 @@ class CustomResponseTest(ResponseTest):
problem
=
self
.
build_problem
(
script
=
script
,
cfn
=
"check_func"
)
# Expect that an exception gets raised when we check the answer
with
self
.
assertRaises
(
LoncapaProblem
Error
):
with
self
.
assertRaises
(
Response
Error
):
problem
.
grade_answers
({
'1_2_1'
:
'42'
})
...
...
@@ -922,6 +923,18 @@ class SchematicResponseTest(ResponseTest):
# is what we expect)
self
.
assertEqual
(
correct_map
.
get_correctness
(
'1_2_1'
),
'correct'
)
def
test_script_exception
(
self
):
# Construct a script that will raise an exception
script
=
"raise Exception('test')"
problem
=
self
.
build_problem
(
answer
=
script
)
# Expect that an exception gets raised when we check the answer
with
self
.
assertRaises
(
ResponseError
):
submission_dict
=
{
'test'
:
'test'
}
input_dict
=
{
'1_2_1'
:
json
.
dumps
(
submission_dict
)}
problem
.
grade_answers
(
input_dict
)
class
AnnotationResponseTest
(
ResponseTest
):
from
response_xml_factory
import
AnnotationResponseXMLFactory
...
...
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