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
835f1879
Commit
835f1879
authored
Nov 30, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests pass again
parent
d28cd4f4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
10 deletions
+45
-10
lms/djangoapps/instructor/staff_grading_service.py
+25
-5
lms/djangoapps/instructor/tests.py
+12
-4
lms/envs/common.py
+3
-0
lms/envs/test.py
+5
-1
No files found.
lms/djangoapps/instructor/staff_grading_service.py
View file @
835f1879
...
@@ -38,7 +38,7 @@ class MockStaffGradingService(object):
...
@@ -38,7 +38,7 @@ class MockStaffGradingService(object):
'rubric'
:
'A rubric'
})
'rubric'
:
'A rubric'
})
def
save_grade
(
self
,
course_id
,
grader_id
,
submission_id
,
score
,
feedback
):
def
save_grade
(
self
,
course_id
,
grader_id
,
submission_id
,
score
,
feedback
):
return
self
.
get_next
(
course_id
)
return
self
.
get_next
(
course_id
,
grader_id
)
class
StaffGradingService
(
object
):
class
StaffGradingService
(
object
):
...
@@ -140,8 +140,28 @@ class StaffGradingService(object):
...
@@ -140,8 +140,28 @@ class StaffGradingService(object):
return
r
.
text
return
r
.
text
_service
=
StaffGradingService
(
settings
.
STAFF_GRADING_INTERFACE
)
# don't initialize until grading_service() is called--means that just
#_service = MockStaffGradingService()
# importing this file doesn't create objects that may not have the right config
_service
=
None
def
grading_service
():
"""
Return a staff grading service instance--if settings.MOCK_STAFF_GRADING is True,
returns a mock one, otherwise a real one.
Caches the result, so changing the setting after the first call to this
function will have no effect.
"""
global
_service
if
_service
is
not
None
:
return
_service
if
settings
.
MOCK_STAFF_GRADING
:
_service
=
MockStaffGradingService
()
else
:
_service
=
StaffGradingService
(
settings
.
STAFF_GRADING_INTERFACE
)
return
_service
def
_err_response
(
msg
):
def
_err_response
(
msg
):
"""
"""
...
@@ -194,7 +214,7 @@ def _get_next(course_id, grader_id):
...
@@ -194,7 +214,7 @@ def _get_next(course_id, grader_id):
"""
"""
try
:
try
:
return
_service
.
get_next
(
course_id
,
grader_id
)
return
grading_service
()
.
get_next
(
course_id
,
grader_id
)
except
GradingServiceError
:
except
GradingServiceError
:
log
.
exception
(
"Error from grading service"
)
log
.
exception
(
"Error from grading service"
)
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Could not connect to grading service'
})
return
json
.
dumps
({
'success'
:
False
,
'error'
:
'Could not connect to grading service'
})
...
@@ -228,7 +248,7 @@ def save_grade(request, course_id):
...
@@ -228,7 +248,7 @@ def save_grade(request, course_id):
p
=
request
.
POST
p
=
request
.
POST
try
:
try
:
result_json
=
_service
.
save_grade
(
course_id
,
result_json
=
grading_service
()
.
save_grade
(
course_id
,
grader_id
,
grader_id
,
p
[
'submission_id'
],
p
[
'submission_id'
],
p
[
'score'
],
p
[
'score'
],
...
...
lms/djangoapps/instructor/tests.py
View file @
835f1879
...
@@ -233,6 +233,14 @@ class TestStaffGradingService(ct.PageLoader):
...
@@ -233,6 +233,14 @@ class TestStaffGradingService(ct.PageLoader):
def
setUp
(
self
):
def
setUp
(
self
):
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
xmodule
.
modulestore
.
django
.
_MODULESTORES
=
{}
self
.
student
=
'view@test.com'
self
.
instructor
=
'view2@test.com'
self
.
password
=
'foo'
self
.
create_account
(
'u1'
,
self
.
student
,
self
.
password
)
self
.
create_account
(
'u2'
,
self
.
instructor
,
self
.
password
)
self
.
activate_user
(
self
.
student
)
self
.
activate_user
(
self
.
instructor
)
self
.
course_id
=
"edX/toy/2012_Fall"
self
.
course_id
=
"edX/toy/2012_Fall"
self
.
toy
=
modulestore
()
.
get_course
(
self
.
course_id
)
self
.
toy
=
modulestore
()
.
get_course
(
self
.
course_id
)
def
make_instructor
(
course
):
def
make_instructor
(
course
):
...
@@ -242,6 +250,8 @@ class TestStaffGradingService(ct.PageLoader):
...
@@ -242,6 +250,8 @@ class TestStaffGradingService(ct.PageLoader):
make_instructor
(
self
.
toy
)
make_instructor
(
self
.
toy
)
self
.
mock_service
=
staff_grading_service
.
grading_service
()
self
.
logout
()
self
.
logout
()
def
test_access
(
self
):
def
test_access
(
self
):
...
@@ -257,7 +267,6 @@ class TestStaffGradingService(ct.PageLoader):
...
@@ -257,7 +267,6 @@ class TestStaffGradingService(ct.PageLoader):
self
.
check_for_post_code
(
404
,
url
)
self
.
check_for_post_code
(
404
,
url
)
@patch.object
(
staff_grading_service
,
'_service'
,
_mock_service
)
def
test_get_next
(
self
):
def
test_get_next
(
self
):
self
.
login
(
self
.
instructor
,
self
.
password
)
self
.
login
(
self
.
instructor
,
self
.
password
)
...
@@ -266,10 +275,9 @@ class TestStaffGradingService(ct.PageLoader):
...
@@ -266,10 +275,9 @@ class TestStaffGradingService(ct.PageLoader):
r
=
self
.
check_for_get_code
(
200
,
url
)
r
=
self
.
check_for_get_code
(
200
,
url
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'success'
])
self
.
assertEquals
(
d
[
'submission_id'
],
_
mock_service
.
cnt
)
self
.
assertEquals
(
d
[
'submission_id'
],
self
.
mock_service
.
cnt
)
@patch.object
(
staff_grading_service
,
'_service'
,
_mock_service
)
def
test_save_grade
(
self
):
def
test_save_grade
(
self
):
self
.
login
(
self
.
instructor
,
self
.
password
)
self
.
login
(
self
.
instructor
,
self
.
password
)
...
@@ -281,6 +289,6 @@ class TestStaffGradingService(ct.PageLoader):
...
@@ -281,6 +289,6 @@ class TestStaffGradingService(ct.PageLoader):
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
r
=
self
.
check_for_post_code
(
200
,
url
,
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertTrue
(
d
[
'success'
],
str
(
d
))
self
.
assertTrue
(
d
[
'success'
],
str
(
d
))
self
.
assertEquals
(
d
[
'submission_id'
],
_
mock_service
.
cnt
)
self
.
assertEquals
(
d
[
'submission_id'
],
self
.
mock_service
.
cnt
)
lms/envs/common.py
View file @
835f1879
...
@@ -325,6 +325,9 @@ WIKI_LINK_DEFAULT_LEVEL = 2
...
@@ -325,6 +325,9 @@ WIKI_LINK_DEFAULT_LEVEL = 2
################################# Staff grading config #####################
################################# Staff grading config #####################
STAFF_GRADING_INTERFACE
=
None
STAFF_GRADING_INTERFACE
=
None
# Used for testing, debugging
MOCK_STAFF_GRADING
=
False
################################# Jasmine ###################################
################################# Jasmine ###################################
JASMINE_TEST_DIRECTORY
=
PROJECT_ROOT
+
'/static/coffee'
JASMINE_TEST_DIRECTORY
=
PROJECT_ROOT
+
'/static/coffee'
...
...
lms/envs/test.py
View file @
835f1879
...
@@ -65,6 +65,10 @@ XQUEUE_INTERFACE = {
...
@@ -65,6 +65,10 @@ XQUEUE_INTERFACE = {
}
}
XQUEUE_WAITTIME_BETWEEN_REQUESTS
=
5
# seconds
XQUEUE_WAITTIME_BETWEEN_REQUESTS
=
5
# seconds
# Don't rely on a real staff grading backend
MOCK_STAFF_GRADING
=
True
# TODO (cpennington): We need to figure out how envs/test.py can inject things
# TODO (cpennington): We need to figure out how envs/test.py can inject things
# into common.py so that we don't have to repeat this sort of thing
# into common.py so that we don't have to repeat this sort of thing
STATICFILES_DIRS
=
[
STATICFILES_DIRS
=
[
...
@@ -99,7 +103,7 @@ DATABASES = {
...
@@ -99,7 +103,7 @@ DATABASES = {
}
}
CACHES
=
{
CACHES
=
{
# This is the cache used for most things.
# This is the cache used for most things.
# In staging/prod envs, the sessions also live here.
# In staging/prod envs, the sessions also live here.
'default'
:
{
'default'
:
{
'BACKEND'
:
'django.core.cache.backends.locmem.LocMemCache'
,
'BACKEND'
:
'django.core.cache.backends.locmem.LocMemCache'
,
...
...
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