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
4909b849
Commit
4909b849
authored
Jan 10, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up code and make the arguments for get and post more logical.
parent
19bc6574
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
15 deletions
+19
-15
lms/djangoapps/open_ended_grading/grading_service.py
+2
-2
lms/djangoapps/open_ended_grading/peer_grading_service.py
+15
-9
lms/djangoapps/open_ended_grading/staff_grading_service.py
+2
-4
No files found.
lms/djangoapps/open_ended_grading/grading_service.py
View file @
4909b849
...
@@ -44,7 +44,7 @@ class GradingService(object):
...
@@ -44,7 +44,7 @@ class GradingService(object):
return
response
.
json
return
response
.
json
def
post
(
self
,
url
,
allow_redirects
,
data
):
def
post
(
self
,
url
,
data
,
allow_redirects
=
False
):
"""
"""
Make a post request to the grading controller
Make a post request to the grading controller
"""
"""
...
@@ -58,7 +58,7 @@ class GradingService(object):
...
@@ -58,7 +58,7 @@ class GradingService(object):
return
r
.
text
return
r
.
text
def
get
(
self
,
url
,
allow_redirects
,
params
):
def
get
(
self
,
url
,
params
,
allow_redirects
=
False
):
"""
"""
Make a get request to the grading controller
Make a get request to the grading controller
"""
"""
...
...
lms/djangoapps/open_ended_grading/peer_grading_service.py
View file @
4909b849
...
@@ -16,6 +16,10 @@ from student.models import unique_id_for_user
...
@@ -16,6 +16,10 @@ from student.models import unique_id_for_user
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
"""
This is a mock peer grading service that can be used for unit tests
without making actual service calls to the grading controller
"""
class
MockPeerGradingService
(
object
):
class
MockPeerGradingService
(
object
):
def
get_next_submission
(
self
,
problem_location
,
grader_id
):
def
get_next_submission
(
self
,
problem_location
,
grader_id
):
return
json
.
dumps
({
'success'
:
True
,
return
json
.
dumps
({
'success'
:
True
,
...
@@ -26,7 +30,8 @@ class MockPeerGradingService(object):
...
@@ -26,7 +30,8 @@ class MockPeerGradingService(object):
'rubric'
:
'fake rubric'
,
'rubric'
:
'fake rubric'
,
'max_score'
:
4
})
'max_score'
:
4
})
def
save_grade
(
self
,
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
):
def
save_grade
(
self
,
location
,
grader_id
,
submission_id
,
score
,
feedback
,
submission_key
):
return
json
.
dumps
({
'success'
:
True
})
return
json
.
dumps
({
'success'
:
True
})
def
is_student_calibrated
(
self
,
problem_location
,
grader_id
):
def
is_student_calibrated
(
self
,
problem_location
,
grader_id
):
...
@@ -41,15 +46,16 @@ class MockPeerGradingService(object):
...
@@ -41,15 +46,16 @@ class MockPeerGradingService(object):
'rubric'
:
'fake rubric'
,
'rubric'
:
'fake rubric'
,
'max_score'
:
4
})
'max_score'
:
4
})
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
):
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
):
return
{
'success'
:
True
,
'actual_score'
:
2
}
return
{
'success'
:
True
,
'actual_score'
:
2
}
def
get_problem_list
(
self
,
course_id
,
grader_id
):
def
get_problem_list
(
self
,
course_id
,
grader_id
):
return
json
.
dumps
({
'success'
:
True
,
return
json
.
dumps
({
'success'
:
True
,
'problem_list'
:
[
'problem_list'
:
[
json
.
dumps
({
'location'
:
'i4x://MITx/3.091x/problem/open_ended_demo1'
,
\
json
.
dumps
({
'location'
:
'i4x://MITx/3.091x/problem/open_ended_demo1'
,
'problem_name'
:
"Problem 1"
,
'num_graded'
:
3
,
'num_pending'
:
5
}),
'problem_name'
:
"Problem 1"
,
'num_graded'
:
3
,
'num_pending'
:
5
}),
json
.
dumps
({
'location'
:
'i4x://MITx/3.091x/problem/open_ended_demo2'
,
\
json
.
dumps
({
'location'
:
'i4x://MITx/3.091x/problem/open_ended_demo2'
,
'problem_name'
:
"Problem 2"
,
'num_graded'
:
1
,
'num_pending'
:
5
})
'problem_name'
:
"Problem 2"
,
'num_graded'
:
1
,
'num_pending'
:
5
})
]})
]})
...
@@ -78,15 +84,15 @@ class PeerGradingService(GradingService):
...
@@ -78,15 +84,15 @@ class PeerGradingService(GradingService):
'feedback'
:
feedback
,
'feedback'
:
feedback
,
'submission_key'
:
submission_key
,
'submission_key'
:
submission_key
,
'location'
:
location
}
'location'
:
location
}
return
self
.
post
(
self
.
save_grade_url
,
False
,
data
)
return
self
.
post
(
self
.
save_grade_url
,
data
)
def
is_student_calibrated
(
self
,
problem_location
,
grader_id
):
def
is_student_calibrated
(
self
,
problem_location
,
grader_id
):
params
=
{
'problem_id'
:
problem_location
,
'student_id'
:
grader_id
}
params
=
{
'problem_id'
:
problem_location
,
'student_id'
:
grader_id
}
return
self
.
get
(
self
.
is_student_calibrated_url
,
False
,
params
)
return
self
.
get
(
self
.
is_student_calibrated_url
,
params
)
def
show_calibration_essay
(
self
,
problem_location
,
grader_id
):
def
show_calibration_essay
(
self
,
problem_location
,
grader_id
):
params
=
{
'problem_id'
:
problem_location
,
'student_id'
:
grader_id
}
params
=
{
'problem_id'
:
problem_location
,
'student_id'
:
grader_id
}
return
self
.
get
(
self
.
show_calibration_essay_url
,
False
,
params
)
return
self
.
get
(
self
.
show_calibration_essay_url
,
params
)
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
):
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
):
data
=
{
'location'
:
problem_location
,
data
=
{
'location'
:
problem_location
,
...
@@ -95,11 +101,11 @@ class PeerGradingService(GradingService):
...
@@ -95,11 +101,11 @@ class PeerGradingService(GradingService):
'submission_key'
:
submission_key
,
'submission_key'
:
submission_key
,
'score'
:
score
,
'score'
:
score
,
'feedback'
:
feedback
}
'feedback'
:
feedback
}
return
self
.
post
(
self
.
save_calibration_essay_url
,
False
,
data
)
return
self
.
post
(
self
.
save_calibration_essay_url
,
data
)
def
get_problem_list
(
self
,
course_id
,
grader_id
):
def
get_problem_list
(
self
,
course_id
,
grader_id
):
params
=
{
'course_id'
:
course_id
,
'student_id'
:
grader_id
}
params
=
{
'course_id'
:
course_id
,
'student_id'
:
grader_id
}
response
=
self
.
get
(
self
.
get_problem_list_url
,
False
,
params
)
response
=
self
.
get
(
self
.
get_problem_list_url
,
params
)
return
response
return
response
...
...
lms/djangoapps/open_ended_grading/staff_grading_service.py
View file @
4909b849
...
@@ -85,7 +85,7 @@ class StaffGradingService(GradingService):
...
@@ -85,7 +85,7 @@ class StaffGradingService(GradingService):
GradingServiceError: something went wrong with the connection.
GradingServiceError: something went wrong with the connection.
"""
"""
params
=
{
'course_id'
:
course_id
,
'grader_id'
:
grader_id
}
params
=
{
'course_id'
:
course_id
,
'grader_id'
:
grader_id
}
return
self
.
get
(
self
.
get_problem_list_url
,
False
,
params
)
return
self
.
get
(
self
.
get_problem_list_url
,
params
)
def
get_next
(
self
,
course_id
,
location
,
grader_id
):
def
get_next
(
self
,
course_id
,
location
,
grader_id
):
...
@@ -107,7 +107,6 @@ class StaffGradingService(GradingService):
...
@@ -107,7 +107,6 @@ class StaffGradingService(GradingService):
GradingServiceError: something went wrong with the connection.
GradingServiceError: something went wrong with the connection.
"""
"""
return
self
.
get
(
self
.
get_next_url
,
return
self
.
get
(
self
.
get_next_url
,
allow_redirects
=
False
,
params
=
{
'location'
:
location
,
params
=
{
'location'
:
location
,
'grader_id'
:
grader_id
})
'grader_id'
:
grader_id
})
...
@@ -131,8 +130,7 @@ class StaffGradingService(GradingService):
...
@@ -131,8 +130,7 @@ class StaffGradingService(GradingService):
'grader_id'
:
grader_id
,
'grader_id'
:
grader_id
,
'skipped'
:
skipped
}
'skipped'
:
skipped
}
return
self
.
post
(
self
.
save_grade_url
,
data
=
data
,
return
self
.
post
(
self
.
save_grade_url
,
data
=
data
)
allow_redirects
=
False
)
# don't initialize until staff_grading_service() is called--means that just
# don't initialize until staff_grading_service() is called--means that just
# importing this file doesn't create objects that may not have the right config
# importing this file doesn't create objects that may not have the right config
...
...
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