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
210cdf87
Commit
210cdf87
authored
Jan 24, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates to the mock peer grading service and new tests.
parent
dc3dd41a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
4 deletions
+73
-4
lms/djangoapps/open_ended_grading/peer_grading_service.py
+12
-3
lms/djangoapps/open_ended_grading/tests.py
+61
-1
No files found.
lms/djangoapps/open_ended_grading/peer_grading_service.py
View file @
210cdf87
...
...
@@ -29,6 +29,15 @@ 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
):
# TODO: get this rubric parsed and working
rubric
=
"""<rubric>
<category>
<description>Description</description>
<option>First option</option>
<option>Second option</option>
</category>
</rubric>"""
def
get_next_submission
(
self
,
problem_location
,
grader_id
):
return
json
.
dumps
({
'success'
:
True
,
'submission_id'
:
1
,
...
...
@@ -56,15 +65,15 @@ class MockPeerGradingService(object):
def
save_calibration_essay
(
self
,
problem_location
,
grader_id
,
calibration_essay_id
,
submission_key
,
score
,
feedback
):
return
{
'success'
:
True
,
'actual_score'
:
2
}
return
json
.
dumps
({
'success'
:
True
,
'actual_score'
:
2
})
def
get_problem_list
(
self
,
course_id
,
grader_id
):
return
json
.
dumps
({
'success'
:
True
,
'problem_list'
:
[
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
,
'num_required'
:
7
}),
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
,
'num_required'
:
8
})
]})
class
PeerGradingService
(
GradingService
):
...
...
lms/djangoapps/open_ended_grading/tests.py
View file @
210cdf87
...
...
@@ -18,6 +18,8 @@ from nose import SkipTest
from
mock
import
patch
,
Mock
import
json
import
logging
log
=
logging
.
getLogger
(
__name__
)
from
override_settings
import
override_settings
...
...
@@ -182,7 +184,7 @@ class TestPeerGradingService(ct.PageLoader):
self
.
assertFalse
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'error'
]
.
find
(
'Missing required keys:'
)
>
-
1
)
def
test_is_calibrated
(
self
):
def
test_is_calibrated
_success
(
self
):
self
.
login
(
self
.
student
,
self
.
password
)
url
=
reverse
(
'peer_grading_is_student_calibrated'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
data
=
{
'location'
:
self
.
location
}
...
...
@@ -191,3 +193,61 @@ class TestPeerGradingService(ct.PageLoader):
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
'calibrated'
in
d
)
def
test_is_calibrated_failure
(
self
):
self
.
login
(
self
.
student
,
self
.
password
)
url
=
reverse
(
'peer_grading_is_student_calibrated'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
data
=
{}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
'calibrated'
in
d
)
def
test_show_calibration_essay_success
(
self
):
self
.
login
(
self
.
student
,
self
.
password
)
url
=
reverse
(
'peer_grading_show_calibration_essay'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
data
=
{
'location'
:
self
.
location
}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
self
.
assertIsNotNone
(
d
[
'submission_key'
])
self
.
assertIsNotNone
(
d
[
'max_score'
])
def
test_show_calibration_essay_missing_key
(
self
):
self
.
login
(
self
.
student
,
self
.
password
)
url
=
reverse
(
'peer_grading_show_calibration_essay'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
data
=
{}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertEqual
(
d
[
'error'
],
"Missing required keys: location"
)
def
test_save_calibration_essay_success
(
self
):
self
.
login
(
self
.
student
,
self
.
password
)
url
=
reverse
(
'peer_grading_save_calibration_essay'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
data
=
{
'location'
:
self
.
location
,
'submission_id'
:
'1'
,
'submission_key'
:
'fake key'
,
'score'
:
'2'
,
'feedback'
:
'This is feedback'
}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
'actual_score'
in
d
)
def
test_save_calibration_essay_missing_keys
(
self
):
self
.
login
(
self
.
student
,
self
.
password
)
url
=
reverse
(
'peer_grading_save_calibration_essay'
,
kwargs
=
{
'course_id'
:
self
.
course_id
})
data
=
{}
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'error'
]
.
find
(
'Missing required keys:'
)
>
-
1
)
self
.
assertFalse
(
'actual_score'
in
d
)
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