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
d8af16dc
Commit
d8af16dc
authored
Sep 20, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1058 from edx/fix/vik/oe-staff-error
Fix OE AJAX post error
parents
c3a155da
d6a2e06d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
4 deletions
+47
-4
lms/djangoapps/open_ended_grading/staff_grading_service.py
+13
-2
lms/djangoapps/open_ended_grading/tests.py
+34
-2
No files found.
lms/djangoapps/open_ended_grading/staff_grading_service.py
View file @
d8af16dc
...
...
@@ -264,15 +264,26 @@ def get_problem_list(request, course_id):
min_for_ml: the number of responses that need to be graded before
the ml can be run
'error': if success is False, will have an error message with more info.
"""
_check_access
(
request
.
user
,
course_id
)
try
:
response
=
staff_grading_service
()
.
get_problem_list
(
course_id
,
unique_id_for_user
(
request
.
user
))
response
=
json
.
loads
(
response
)
problem_list
=
response
[
'problem_list'
]
# If 'problem_list' is in the response, then we got a list of problems from the ORA server.
# If it is not, then ORA could not find any problems.
if
'problem_list'
in
response
:
problem_list
=
response
[
'problem_list'
]
else
:
problem_list
=
[]
# Make an error messages to reflect that we could not find anything to grade.
response
[
'error'
]
=
(
"Cannot find any open response problems in this course. "
"Have you submitted answers to any open response assessment questions? "
"If not, please do so and return to this page."
)
valid_problem_list
=
[]
for
i
in
xrange
(
0
,
len
(
problem_list
)):
#
Needed to ensure that the 'location' key can be accessed
#
Needed to ensure that the 'location' key can be accessed.
try
:
problem_list
[
i
]
=
json
.
loads
(
problem_list
[
i
])
except
Exception
:
...
...
lms/djangoapps/open_ended_grading/tests.py
View file @
d8af16dc
...
...
@@ -34,6 +34,17 @@ from courseware.tests import factories
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
,
check_for_get_code
,
check_for_post_code
class
EmptyStaffGradingService
(
object
):
"""
A staff grading service that does not return a problem list from get_problem_list.
Used for testing to see if error message for empty problem list is correctly displayed.
"""
def
get_problem_list
(
self
,
course_id
,
user_id
):
"""
Return a staff grading response that is missing a problem list key.
"""
return
json
.
dumps
({
'success'
:
True
,
'error'
:
'No problems found.'
})
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
TestStaffGradingService
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
...
...
@@ -134,8 +145,29 @@ class TestStaffGradingService(ModuleStoreTestCase, LoginEnrollmentTestCase):
response
=
check_for_post_code
(
self
,
200
,
url
,
data
)
content
=
json
.
loads
(
response
.
content
)
self
.
assertTrue
(
content
[
'success'
],
str
(
content
))
self
.
assertIsNotNone
(
content
[
'problem_list'
])
self
.
assertTrue
(
content
[
'success'
])
self
.
assertEqual
(
content
[
'problem_list'
],
[])
@patch
(
'open_ended_grading.staff_grading_service._service'
,
EmptyStaffGradingService
())
def
test_get_problem_list_missing
(
self
):
"""
Test to see if a staff grading response missing a problem list is given the appropriate error.
Mock the staff grading service to enable the key to be missing.
"""
# Get a valid user object.
instructor
=
User
.
objects
.
get
(
email
=
self
.
instructor
)
# Mock a request object.
request
=
Mock
(
user
=
instructor
,
)
# Get the response and load its content.
response
=
json
.
loads
(
staff_grading_service
.
get_problem_list
(
request
,
self
.
course_id
)
.
content
)
# A valid response will have an "error" key.
self
.
assertTrue
(
'error'
in
response
)
# Check that the error text is correct.
self
.
assertIn
(
"Cannot find"
,
response
[
'error'
])
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
...
...
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