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
6c06b39b
Commit
6c06b39b
authored
Mar 26, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Centralize when json parsing of responses from controller_query_service happens
parent
d0daa617
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
27 deletions
+47
-27
common/lib/xmodule/xmodule/open_ended_grading_classes/controller_query_service.py
+41
-10
common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py
+0
-4
lms/djangoapps/open_ended_grading/open_ended_notifications.py
+1
-2
lms/djangoapps/open_ended_grading/tests.py
+2
-5
lms/djangoapps/open_ended_grading/utils.py
+1
-3
lms/djangoapps/open_ended_grading/views.py
+2
-3
No files found.
common/lib/xmodule/xmodule/open_ended_grading_classes/controller_query_service.py
View file @
6c06b39b
...
...
@@ -25,7 +25,7 @@ class ControllerQueryService(GradingService):
'location'
:
location
,
}
response
=
self
.
get
(
self
.
check_eta_url
,
params
)
return
response
return
response
.
json
()
def
check_combined_notifications
(
self
,
course_id
,
student_id
,
user_is_staff
,
last_time_viewed
):
params
=
{
...
...
@@ -36,7 +36,7 @@ class ControllerQueryService(GradingService):
}
log
.
debug
(
self
.
combined_notifications_url
)
response
=
self
.
get
(
self
.
combined_notifications_url
,
params
)
return
response
return
response
.
json
()
def
get_grading_status_list
(
self
,
course_id
,
student_id
):
params
=
{
...
...
@@ -45,7 +45,7 @@ class ControllerQueryService(GradingService):
}
response
=
self
.
get
(
self
.
grading_status_list_url
,
params
)
return
response
return
response
.
json
()
def
get_flagged_problem_list
(
self
,
course_id
):
params
=
{
...
...
@@ -53,7 +53,7 @@ class ControllerQueryService(GradingService):
}
response
=
self
.
get
(
self
.
flagged_problem_list_url
,
params
)
return
response
return
response
.
json
()
def
take_action_on_flags
(
self
,
course_id
,
student_id
,
submission_id
,
action_type
):
params
=
{
...
...
@@ -64,7 +64,7 @@ class ControllerQueryService(GradingService):
}
response
=
self
.
post
(
self
.
take_action_on_flags_url
,
params
)
return
response
return
response
.
json
()
class
MockControllerQueryService
(
object
):
...
...
@@ -84,15 +84,47 @@ class MockControllerQueryService(object):
pass
def
check_combined_notifications
(
self
,
*
args
,
**
kwargs
):
combined_notifications
=
'{"flagged_submissions_exist": false, "version": 1, "new_student_grading_to_view": false, "success": true, "staff_needs_to_grade": false, "student_needs_to_peer_grade": true, "overall_need_to_check": true}'
combined_notifications
=
{
"flagged_submissions_exist"
:
False
,
"version"
:
1
,
"new_student_grading_to_view"
:
False
,
"success"
:
True
,
"staff_needs_to_grade"
:
False
,
"student_needs_to_peer_grade"
:
True
,
"overall_need_to_check"
:
True
}
return
combined_notifications
def
get_grading_status_list
(
self
,
*
args
,
**
kwargs
):
grading_status_list
=
'{"version": 1, "problem_list": [{"problem_name": "Science Question -- Machine Assessed", "grader_type": "NA", "eta_available": true, "state": "Waiting to be Graded", "eta": 259200, "location": "i4x://MITx/oe101x/combinedopenended/Science_SA_ML"}, {"problem_name": "Humanities Question -- Peer Assessed", "grader_type": "NA", "eta_available": true, "state": "Waiting to be Graded", "eta": 259200, "location": "i4x://MITx/oe101x/combinedopenended/Humanities_SA_Peer"}], "success": true}'
grading_status_list
=
{
"version"
:
1
,
"problem_list"
:
[
{
"problem_name"
:
"Science Question -- Machine Assessed"
,
"grader_type"
:
"NA"
,
"eta_available"
:
True
,
"state"
:
"Waiting to be Graded"
,
"eta"
:
259200
,
"location"
:
"i4x://MITx/oe101x/combinedopenended/Science_SA_ML"
},
{
"problem_name"
:
"Humanities Question -- Peer Assessed"
,
"grader_type"
:
"NA"
,
"eta_available"
:
True
,
"state"
:
"Waiting to be Graded"
,
"eta"
:
259200
,
"location"
:
"i4x://MITx/oe101x/combinedopenended/Humanities_SA_Peer"
}
],
"success"
:
True
}
return
grading_status_list
def
get_flagged_problem_list
(
self
,
*
args
,
**
kwargs
):
flagged_problem_list
=
'{"version": 1, "success": false, "error": "No flagged submissions exist for course: MITx/oe101x/2012_Fall"}'
flagged_problem_list
=
{
"version"
:
1
,
"success"
:
False
,
"error"
:
"No flagged submissions exist for course: MITx/oe101x/2012_Fall"
}
return
flagged_problem_list
def
take_action_on_flags
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -113,5 +145,4 @@ def convert_seconds_to_human_readable(seconds):
else
:
human_string
=
"{0} days"
.
format
(
round
(
seconds
/
(
60
*
60
*
24
),
1
))
eta_string
=
"{0}"
.
format
(
human_string
)
return
eta_string
return
human_string
common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py
View file @
6c06b39b
...
...
@@ -533,10 +533,6 @@ class OpenEndedChild(object):
def
get_eta
(
self
):
if
self
.
controller_qs
:
response
=
self
.
controller_qs
.
check_for_eta
(
self
.
location_string
)
try
:
response
=
json
.
loads
(
response
)
except
:
pass
else
:
return
""
...
...
lms/djangoapps/open_ended_grading/open_ended_notifications.py
View file @
6c06b39b
...
...
@@ -165,9 +165,8 @@ def combined_notifications(course, user):
try
:
#Get the notifications from the grading controller
controller_response
=
controller_qs
.
check_combined_notifications
(
course
.
id
,
student_id
,
user_is_staff
,
notifications
=
controller_qs
.
check_combined_notifications
(
course
.
id
,
student_id
,
user_is_staff
,
last_time_viewed
)
notifications
=
json
.
loads
(
controller_response
)
if
notifications
.
get
(
'success'
):
if
(
notifications
.
get
(
'staff_needs_to_grade'
)
or
notifications
.
get
(
'student_needs_to_peer_grade'
)):
...
...
lms/djangoapps/open_ended_grading/tests.py
View file @
6c06b39b
...
...
@@ -62,10 +62,9 @@ class StudentProblemListMockQuery(object):
def
get_grading_status_list
(
self
,
*
args
,
**
kwargs
):
"""
Get a mock grading status list with locations from the open_ended test course.
@returns:
json formatted grading status message
.
@returns:
grading status message dictionary
.
"""
grading_status_list
=
json
.
dumps
(
{
return
{
"version"
:
1
,
"problem_list"
:
[
{
...
...
@@ -95,8 +94,6 @@ class StudentProblemListMockQuery(object):
],
"success"
:
True
}
)
return
grading_status_list
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
...
...
lms/djangoapps/open_ended_grading/utils.py
View file @
6c06b39b
...
...
@@ -118,12 +118,10 @@ class StudentProblemList(object):
self
.
success
=
False
try
:
#Get list of all open ended problems that the grading server knows about
problem_list_
json
=
self
.
controller_qs
.
get_grading_status_list
(
self
.
course_id
,
self
.
user_id
)
problem_list_
dict
=
self
.
controller_qs
.
get_grading_status_list
(
self
.
course_id
,
self
.
user_id
)
except
GradingServiceError
:
log
.
error
(
"Problem contacting open ended grading service "
+
self
.
course_error_ending
)
return
self
.
success
try
:
problem_list_dict
=
json
.
loads
(
problem_list_json
)
except
ValueError
:
log
.
error
(
"Problem with results from external grading service for open ended"
+
self
.
course_error_ending
)
return
self
.
success
...
...
lms/djangoapps/open_ended_grading/views.py
View file @
6c06b39b
...
...
@@ -197,8 +197,7 @@ def flagged_problem_list(request, course_id):
# Make a service that can query edX ORA.
controller_qs
=
create_controller_query_service
()
try
:
problem_list_json
=
controller_qs
.
get_flagged_problem_list
(
course_id
)
problem_list_dict
=
json
.
loads
(
problem_list_json
)
problem_list_dict
=
controller_qs
.
get_flagged_problem_list
(
course_id
)
success
=
problem_list_dict
[
'success'
]
if
'error'
in
problem_list_dict
:
error_text
=
problem_list_dict
[
'error'
]
...
...
@@ -326,7 +325,7 @@ def take_action_on_flags(request, course_id):
controller_qs
=
create_controller_query_service
()
try
:
response
=
controller_qs
.
take_action_on_flags
(
course_id
,
student_id
,
submission_id
,
action_type
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
response
)
,
mimetype
=
"application/json"
)
except
GradingServiceError
:
log
.
exception
(
u"Error taking action on flagged peer grading submissions, "
...
...
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