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
d1c55208
Commit
d1c55208
authored
Jan 31, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up response code
parent
c1583dbb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
25 deletions
+42
-25
common/lib/xmodule/xmodule/peer_grading_module.py
+22
-21
common/lib/xmodule/xmodule/peer_grading_service.py
+20
-4
No files found.
common/lib/xmodule/xmodule/peer_grading_module.py
View file @
d1c55208
...
...
@@ -12,7 +12,6 @@ import requests
import
sys
from
django.conf
import
settings
from
django.http
import
HttpResponse
,
Http404
from
combined_open_ended_rubric
import
CombinedOpenEndedRubric
from
lxml
import
etree
...
...
@@ -81,8 +80,7 @@ class PeerGradingModule(XModule):
"""
Return a HttpResponse with a json dump with success=False, and the given error message.
"""
return
HttpResponse
(
json
.
dumps
({
'success'
:
False
,
'error'
:
msg
}),
mimetype
=
"application/json"
)
return
{
'success'
:
False
,
'error'
:
msg
}
def
_check_required
(
self
,
get
,
required
):
actual
=
set
(
get
.
keys
())
...
...
@@ -107,7 +105,7 @@ class PeerGradingModule(XModule):
Needs to be implemented by child modules. Handles AJAX events.
@return:
"""
log
.
debug
(
get
)
handlers
=
{
'get_next_submission'
:
self
.
get_next_submission
,
'show_calibration_essay'
:
self
.
show_calibration_essay
,
...
...
@@ -123,7 +121,7 @@ class PeerGradingModule(XModule):
d
=
handlers
[
dispatch
](
get
)
log
.
debug
(
d
)
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
def
get_progress
(
self
):
...
...
@@ -159,13 +157,12 @@ class PeerGradingModule(XModule):
try
:
response
=
self
.
peer_gs
.
get_next_submission
(
location
,
grader_id
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
return
response
except
GradingServiceError
:
log
.
exception
(
"Error getting next submission. server url: {0} location: {1}, grader_id: {2}"
.
format
(
self
.
peer_gs
.
url
,
location
,
grader_id
))
return
json
.
dumps
(
{
'success'
:
False
,
'error'
:
'Could not connect to grading service'
}
)
return
{
'success'
:
False
,
'error'
:
'Could not connect to grading service'
}
def
save_grade
(
self
,
get
):
"""
...
...
@@ -199,15 +196,17 @@ class PeerGradingModule(XModule):
try
:
response
=
self
.
peer_gs
.
save_grade
(
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
,
rubric_scores
,
submission_flagged
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
return
response
except
GradingServiceError
:
log
.
exception
(
"""Error saving grade. server url: {0}, location: {1}, submission_id:{2},
submission_key: {3}, score: {4}"""
.
format
(
self
.
peer_gs
.
url
,
location
,
submission_id
,
submission_key
,
score
)
)
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Could not connect to grading service'
})
return
{
'success'
:
False
,
'error'
:
'Could not connect to grading service'
}
def
is_student_calibrated
(
self
,
get
):
"""
...
...
@@ -237,12 +236,14 @@ class PeerGradingModule(XModule):
try
:
response
=
self
.
peer_gs
.
is_student_calibrated
(
location
,
grader_id
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
return
response
except
GradingServiceError
:
log
.
exception
(
"Error from grading service. server url: {0}, grader_id: {0}, location: {1}"
.
format
(
self
.
peer_gs
.
url
,
grader_id
,
location
))
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Could not connect to grading service'
})
return
{
'success'
:
False
,
'error'
:
'Could not connect to grading service'
}
def
show_calibration_essay
(
self
,
get
):
"""
...
...
@@ -278,18 +279,18 @@ class PeerGradingModule(XModule):
location
=
get
[
'location'
]
try
:
response
=
self
.
peer_gs
.
show_calibration_essay
(
location
,
grader_id
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
return
response
except
GradingServiceError
:
log
.
exception
(
"Error from grading service. server url: {0}, location: {0}"
.
format
(
self
.
peer_gs
.
url
,
location
))
return
json
.
dumps
(
{
'success'
:
False
,
'error'
:
'Could not connect to grading service'
}
)
return
{
'success'
:
False
,
'error'
:
'Could not connect to grading service'
}
# if we can't parse the rubric into HTML,
except
etree
.
XMLSyntaxError
:
log
.
exception
(
"Cannot parse rubric string. Raw string: {0}"
.
format
(
rubric
))
return
json
.
dumps
(
{
'success'
:
False
,
'error'
:
'Error displaying submission'
}
)
return
{
'success'
:
False
,
'error'
:
'Error displaying submission'
}
def
save_calibration_essay
(
self
,
get
):
...
...
@@ -326,7 +327,7 @@ class PeerGradingModule(XModule):
try
:
response
=
self
.
peer_gs
.
save_calibration_essay
(
location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
,
rubric_scores
)
return
HttpResponse
(
response
,
mimetype
=
"application/json"
)
return
response
except
GradingServiceError
:
log
.
exception
(
"Error saving calibration grade, location: {0}, submission_id: {1}, submission_key: {2}, grader_id: {3}"
.
format
(
location
,
submission_id
,
submission_key
,
grader_id
))
return
_err_response
(
'Could not connect to grading service'
)
...
...
common/lib/xmodule/xmodule/peer_grading_service.py
View file @
d1c55208
...
...
@@ -36,7 +36,7 @@ class PeerGradingService():
def
get_next_submission
(
self
,
problem_location
,
grader_id
):
response
=
self
.
get
(
self
.
get_next_submission_url
,
{
'location'
:
problem_location
,
'grader_id'
:
grader_id
})
return
json
.
dumps
(
self
.
_render_rubric
(
response
)
)
return
self
.
_render_rubric
(
response
)
def
save_grade
(
self
,
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
,
rubric_scores
,
submission_flagged
):
data
=
{
'grader_id'
:
grader_id
,
...
...
@@ -58,7 +58,7 @@ class PeerGradingService():
def
show_calibration_essay
(
self
,
problem_location
,
grader_id
):
params
=
{
'problem_id'
:
problem_location
,
'student_id'
:
grader_id
}
response
=
self
.
get
(
self
.
show_calibration_essay_url
,
params
)
return
json
.
dumps
(
self
.
_render_rubric
(
response
)
)
return
self
.
_render_rubric
(
response
)
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
,
rubric_scores
):
...
...
@@ -111,7 +111,13 @@ class PeerGradingService():
# reraise as promised GradingServiceError, but preserve stacktrace.
raise
GradingServiceError
,
str
(
err
),
sys
.
exc_info
()[
2
]
return
r
.
text
text
=
r
.
text
try
:
text
=
json
.
loads
(
text
)
except
:
pass
return
text
def
get
(
self
,
url
,
params
,
allow_redirects
=
False
):
"""
...
...
@@ -127,7 +133,13 @@ class PeerGradingService():
# reraise as promised GradingServiceError, but preserve stacktrace.
raise
GradingServiceError
,
str
(
err
),
sys
.
exc_info
()[
2
]
return
r
.
text
text
=
r
.
text
try
:
text
=
json
.
loads
(
text
)
except
:
pass
return
text
def
_try_with_login
(
self
,
operation
):
...
...
@@ -163,6 +175,10 @@ class PeerGradingService():
"""
try
:
response_json
=
json
.
loads
(
response
)
except
:
response_json
=
response
try
:
if
'rubric'
in
response_json
:
rubric
=
response_json
[
'rubric'
]
rubric_renderer
=
CombinedOpenEndedRubric
(
self
.
system
,
False
)
...
...
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