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
e13de754
Commit
e13de754
authored
Feb 05, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test fixes, err response fixes, address review comments
parent
34dc6e63
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
39 deletions
+39
-39
common/lib/xmodule/xmodule/peer_grading_module.py
+5
-5
lms/djangoapps/open_ended_grading/tests.py
+18
-21
lms/djangoapps/open_ended_grading/views.py
+16
-13
No files found.
common/lib/xmodule/xmodule/peer_grading_module.py
View file @
e13de754
...
@@ -217,7 +217,7 @@ class PeerGradingModule(XModule):
...
@@ -217,7 +217,7 @@ class PeerGradingModule(XModule):
required
=
set
([
'location'
])
required
=
set
([
'location'
])
success
,
message
=
self
.
_check_required
(
get
,
required
)
success
,
message
=
self
.
_check_required
(
get
,
required
)
if
not
success
:
if
not
success
:
return
_err_response
(
message
)
return
self
.
_err_response
(
message
)
grader_id
=
self
.
system
.
anonymous_student_id
grader_id
=
self
.
system
.
anonymous_student_id
location
=
get
[
'location'
]
location
=
get
[
'location'
]
...
@@ -296,7 +296,7 @@ class PeerGradingModule(XModule):
...
@@ -296,7 +296,7 @@ class PeerGradingModule(XModule):
required
=
set
([
'location'
])
required
=
set
([
'location'
])
success
,
message
=
self
.
_check_required
(
get
,
required
)
success
,
message
=
self
.
_check_required
(
get
,
required
)
if
not
success
:
if
not
success
:
return
_err_response
(
message
)
return
self
.
_err_response
(
message
)
grader_id
=
self
.
system
.
anonymous_student_id
grader_id
=
self
.
system
.
anonymous_student_id
location
=
get
[
'location'
]
location
=
get
[
'location'
]
...
@@ -339,7 +339,7 @@ class PeerGradingModule(XModule):
...
@@ -339,7 +339,7 @@ class PeerGradingModule(XModule):
required
=
set
([
'location'
])
required
=
set
([
'location'
])
success
,
message
=
self
.
_check_required
(
get
,
required
)
success
,
message
=
self
.
_check_required
(
get
,
required
)
if
not
success
:
if
not
success
:
return
_err_response
(
message
)
return
self
.
_err_response
(
message
)
grader_id
=
self
.
system
.
anonymous_student_id
grader_id
=
self
.
system
.
anonymous_student_id
...
@@ -381,7 +381,7 @@ class PeerGradingModule(XModule):
...
@@ -381,7 +381,7 @@ class PeerGradingModule(XModule):
required
=
set
([
'location'
,
'submission_id'
,
'submission_key'
,
'score'
,
'feedback'
,
'rubric_scores[]'
])
required
=
set
([
'location'
,
'submission_id'
,
'submission_key'
,
'score'
,
'feedback'
,
'rubric_scores[]'
])
success
,
message
=
self
.
_check_required
(
get
,
required
)
success
,
message
=
self
.
_check_required
(
get
,
required
)
if
not
success
:
if
not
success
:
return
_err_response
(
message
)
return
self
.
_err_response
(
message
)
grader_id
=
self
.
system
.
anonymous_student_id
grader_id
=
self
.
system
.
anonymous_student_id
location
=
get
[
'location'
]
location
=
get
[
'location'
]
...
@@ -397,7 +397,7 @@ class PeerGradingModule(XModule):
...
@@ -397,7 +397,7 @@ class PeerGradingModule(XModule):
return
response
return
response
except
GradingServiceError
:
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
))
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'
)
return
self
.
_err_response
(
'Could not connect to grading service'
)
def
peer_grading
(
self
,
get
=
None
):
def
peer_grading
(
self
,
get
=
None
):
'''
'''
...
...
lms/djangoapps/open_ended_grading/tests.py
View file @
e13de754
...
@@ -23,6 +23,7 @@ from mitxmako.shortcuts import render_to_string
...
@@ -23,6 +23,7 @@ from mitxmako.shortcuts import render_to_string
import
logging
import
logging
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
from
override_settings
import
override_settings
from
override_settings
import
override_settings
from
django.http
import
QueryDict
@override_settings
(
MODULESTORE
=
ct
.
TEST_DATA_XML_MODULESTORE
)
@override_settings
(
MODULESTORE
=
ct
.
TEST_DATA_XML_MODULESTORE
)
...
@@ -100,6 +101,7 @@ class TestStaffGradingService(ct.PageLoader):
...
@@ -100,6 +101,7 @@ class TestStaffGradingService(ct.PageLoader):
'submission_id'
:
'123'
,
'submission_id'
:
'123'
,
'location'
:
self
.
location
,
'location'
:
self
.
location
,
'rubric_scores[]'
:
[
'1'
,
'2'
]}
'rubric_scores[]'
:
[
'1'
,
'2'
]}
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
))
...
@@ -138,11 +140,12 @@ class TestPeerGradingService(ct.PageLoader):
...
@@ -138,11 +140,12 @@ class TestPeerGradingService(ct.PageLoader):
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
)
location
=
"i4x://edX/toy/peergrading/init"
self
.
mock_service
=
peer_grading_service
.
MockPeerGradingService
()
self
.
mock_service
=
peer_grading_service
.
MockPeerGradingService
()
self
.
system
=
ModuleSystem
(
None
,
None
,
None
,
render_to_string
,
None
)
self
.
system
=
ModuleSystem
(
location
,
None
,
None
,
render_to_string
,
None
)
self
.
descriptor
=
peer_grading_module
.
PeerGradingDescriptor
()
self
.
descriptor
=
peer_grading_module
.
PeerGradingDescriptor
(
self
.
system
)
location
=
"i4x://edX/toy/peergrading/init"
self
.
peer_module
=
peer_grading_module
.
PeerGradingModule
(
self
.
system
,
location
,
"<peergrading/>"
,
self
.
descriptor
)
self
.
peer_module
=
peer_grading_module
.
PeerGradingModule
(
self
.
system
,
location
,
"<peergrading/>"
,
self
.
descriptor
)
self
.
peer_module
.
peer_gs
=
self
.
mock_service
self
.
peer_module
.
peer_gs
=
self
.
mock_service
self
.
logout
()
self
.
logout
()
...
@@ -153,7 +156,7 @@ class TestPeerGradingService(ct.PageLoader):
...
@@ -153,7 +156,7 @@ class TestPeerGradingService(ct.PageLoader):
data
=
{
'location'
:
self
.
location
}
data
=
{
'location'
:
self
.
location
}
r
=
self
.
peer_module
.
get_next_submission
(
data
)
r
=
self
.
peer_module
.
get_next_submission
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'success'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
...
@@ -163,41 +166,35 @@ class TestPeerGradingService(ct.PageLoader):
...
@@ -163,41 +166,35 @@ class TestPeerGradingService(ct.PageLoader):
def
test_get_next_submission_missing_location
(
self
):
def
test_get_next_submission_missing_location
(
self
):
data
=
{}
data
=
{}
r
=
self
.
peer_module
.
get_next_submission
(
data
)
r
=
self
.
peer_module
.
get_next_submission
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
d
[
'success'
])
self
.
assertEqual
(
d
[
'error'
],
"Missing required keys: location"
)
self
.
assertEqual
(
d
[
'error'
],
"Missing required keys: location"
)
def
test_save_grade_success
(
self
):
def
test_save_grade_success
(
self
):
data
=
'rubric_scores[]=1|rubric_scores[]=2|location='
+
location
+
'|submission_id=1|submission_key=fake key|score=2|feedback=feedback|submission_flagged=False'
data
=
{
'location'
:
self
.
location
,
qdict
=
QueryDict
(
data
.
replace
(
"|"
,
"&"
))
'submission_id'
:
'1'
,
r
=
self
.
peer_module
.
save_grade
(
qdict
)
'submission_key'
:
'fake key'
,
'score'
:
'2'
,
'feedback'
:
'This is feedback'
,
'rubric_scores[]'
:
[
1
,
2
],
'submission_flagged'
:
False
}
r
=
self
.
peer_module
.
save_grade
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
.
content
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'success'
])
def
test_save_grade_missing_keys
(
self
):
def
test_save_grade_missing_keys
(
self
):
data
=
{}
data
=
{}
r
=
self
.
peer_module
.
save_grade
(
data
)
r
=
self
.
peer_module
.
save_grade
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'error'
]
.
find
(
'Missing required keys:'
)
>
-
1
)
self
.
assertTrue
(
d
[
'error'
]
.
find
(
'Missing required keys:'
)
>
-
1
)
def
test_is_calibrated_success
(
self
):
def
test_is_calibrated_success
(
self
):
data
=
{
'location'
:
self
.
location
}
data
=
{
'location'
:
self
.
location
}
r
=
self
.
peer_module
.
is_student_calibrated
(
data
)
r
=
self
.
peer_module
.
is_student_calibrated
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
'calibrated'
in
d
)
self
.
assertTrue
(
'calibrated'
in
d
)
def
test_is_calibrated_failure
(
self
):
def
test_is_calibrated_failure
(
self
):
data
=
{}
data
=
{}
r
=
self
.
peer_module
.
is_student_calibrated
(
data
)
r
=
self
.
peer_module
.
is_student_calibrated
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
'calibrated'
in
d
)
self
.
assertFalse
(
'calibrated'
in
d
)
...
@@ -205,7 +202,7 @@ class TestPeerGradingService(ct.PageLoader):
...
@@ -205,7 +202,7 @@ class TestPeerGradingService(ct.PageLoader):
data
=
{
'location'
:
self
.
location
}
data
=
{
'location'
:
self
.
location
}
r
=
self
.
peer_module
.
show_calibration_essay
(
data
)
r
=
self
.
peer_module
.
show_calibration_essay
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'success'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'submission_id'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
self
.
assertIsNotNone
(
d
[
'prompt'
])
...
@@ -216,7 +213,7 @@ class TestPeerGradingService(ct.PageLoader):
...
@@ -216,7 +213,7 @@ class TestPeerGradingService(ct.PageLoader):
data
=
{}
data
=
{}
r
=
self
.
peer_module
.
show_calibration_essay
(
data
)
r
=
self
.
peer_module
.
show_calibration_essay
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
d
[
'success'
])
self
.
assertEqual
(
d
[
'error'
],
"Missing required keys: location"
)
self
.
assertEqual
(
d
[
'error'
],
"Missing required keys: location"
)
...
@@ -229,14 +226,14 @@ class TestPeerGradingService(ct.PageLoader):
...
@@ -229,14 +226,14 @@ class TestPeerGradingService(ct.PageLoader):
'feedback'
:
'This is feedback'
,
'feedback'
:
'This is feedback'
,
'rubric_scores[]'
:
[
1
,
2
]}
'rubric_scores[]'
:
[
1
,
2
]}
r
=
self
.
peer_module
.
save_calibration_essay
(
data
)
r
=
self
.
peer_module
.
save_calibration_essay
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'success'
])
self
.
assertTrue
(
'actual_score'
in
d
)
self
.
assertTrue
(
'actual_score'
in
d
)
def
test_save_calibration_essay_missing_keys
(
self
):
def
test_save_calibration_essay_missing_keys
(
self
):
data
=
{}
data
=
{}
r
=
self
.
peer_module
.
save_calibration_essay
(
data
)
r
=
self
.
peer_module
.
save_calibration_essay
(
data
)
d
=
json
.
loads
(
r
.
content
)
d
=
json
.
loads
(
r
)
self
.
assertFalse
(
d
[
'success'
])
self
.
assertFalse
(
d
[
'success'
])
self
.
assertTrue
(
d
[
'error'
]
.
find
(
'Missing required keys:'
)
>
-
1
)
self
.
assertTrue
(
d
[
'error'
]
.
find
(
'Missing required keys:'
)
>
-
1
)
self
.
assertFalse
(
'actual_score'
in
d
)
self
.
assertFalse
(
'actual_score'
in
d
)
...
...
lms/djangoapps/open_ended_grading/views.py
View file @
e13de754
...
@@ -90,6 +90,21 @@ def peer_grading(request, course_id):
...
@@ -90,6 +90,21 @@ def peer_grading(request, course_id):
base_course_url
=
reverse
(
'courses'
)
base_course_url
=
reverse
(
'courses'
)
try
:
try
:
problem_url_parts
=
search
.
path_to_location
(
modulestore
(),
course
.
id
,
pg_location
)
problem_url_parts
=
search
.
path_to_location
(
modulestore
(),
course
.
id
,
pg_location
)
problem_url
=
generate_problem_url
(
problem_url_parts
,
base_course_url
)
return
HttpResponseRedirect
(
problem_url
)
except
:
error_message
=
"Error with initializing peer grading. Centralized module does not exist. Please contact course staff."
log
.
error
(
error_message
+
"Current course is: {0}"
.
format
(
course_id
))
return
HttpResponse
(
error_message
)
def
generate_problem_url
(
problem_url_parts
,
base_course_url
):
"""
From a list of problem url parts generated by search.path_to_location and a base course url, generates a url to a problem
@param problem_url_parts: Output of search.path_to_location
@param base_course_url: Base url of a given course
@return: A path to the problem
"""
problem_url
=
base_course_url
+
"/"
problem_url
=
base_course_url
+
"/"
for
z
in
xrange
(
0
,
len
(
problem_url_parts
)):
for
z
in
xrange
(
0
,
len
(
problem_url_parts
)):
part
=
problem_url_parts
[
z
]
part
=
problem_url_parts
[
z
]
...
@@ -98,11 +113,6 @@ def peer_grading(request, course_id):
...
@@ -98,11 +113,6 @@ def peer_grading(request, course_id):
problem_url
+=
"courseware/"
problem_url
+=
"courseware/"
problem_url
+=
part
+
"/"
problem_url
+=
part
+
"/"
return
HttpResponseRedirect
(
problem_url
)
except
:
error_message
=
"Error with initializing peer grading. Centralized module does not exist. Please contact course staff."
log
.
error
(
error_message
+
"Current course is: {0}"
.
format
(
course_id
))
return
HttpResponse
(
error_message
)
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
def
student_problem_list
(
request
,
course_id
):
def
student_problem_list
(
request
,
course_id
):
...
@@ -130,14 +140,7 @@ def student_problem_list(request, course_id):
...
@@ -130,14 +140,7 @@ def student_problem_list(request, course_id):
for
i
in
xrange
(
0
,
len
(
problem_list
)):
for
i
in
xrange
(
0
,
len
(
problem_list
)):
problem_url_parts
=
search
.
path_to_location
(
modulestore
(),
course
.
id
,
problem_list
[
i
][
'location'
])
problem_url_parts
=
search
.
path_to_location
(
modulestore
(),
course
.
id
,
problem_list
[
i
][
'location'
])
problem_url
=
base_course_url
+
"/"
problem_url
=
generate_problem_url
(
problem_url_parts
,
base_course_url
)
for
z
in
xrange
(
0
,
len
(
problem_url_parts
)):
part
=
problem_url_parts
[
z
]
if
part
is
not
None
:
if
z
==
1
:
problem_url
+=
"courseware/"
problem_url
+=
part
+
"/"
problem_list
[
i
]
.
update
({
'actual_url'
:
problem_url
})
problem_list
[
i
]
.
update
({
'actual_url'
:
problem_url
})
"""
"""
...
...
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