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
086f544a
Commit
086f544a
authored
Sep 26, 2013
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix, and add more, tests
parent
07e76b3b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
13 deletions
+44
-13
lms/djangoapps/instructor/tests/test_api.py
+33
-8
lms/djangoapps/instructor/views/api.py
+11
-5
No files found.
lms/djangoapps/instructor/tests/test_api.py
View file @
086f544a
...
...
@@ -512,7 +512,7 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
def
test_get_student_progress_url
(
self
):
""" Test that progress_url is in the successful response. """
url
=
reverse
(
'get_student_progress_url'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
url
+=
"?
student_email
={}"
.
format
(
url
+=
"?
unique_student_identifier
={}"
.
format
(
quote
(
self
.
students
[
0
]
.
email
.
encode
(
"utf-8"
))
)
print
url
...
...
@@ -522,6 +522,19 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
res_json
=
json
.
loads
(
response
.
content
)
self
.
assertIn
(
'progress_url'
,
res_json
)
def
test_get_student_progress_url_from_uname
(
self
):
""" Test that progress_url is in the successful response. """
url
=
reverse
(
'get_student_progress_url'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
url
+=
"?unique_student_identifier={}"
.
format
(
quote
(
self
.
students
[
0
]
.
username
.
encode
(
"utf-8"
))
)
print
url
response
=
self
.
client
.
get
(
url
)
print
response
self
.
assertEqual
(
response
.
status_code
,
200
)
res_json
=
json
.
loads
(
response
.
content
)
self
.
assertIn
(
'progress_url'
,
res_json
)
def
test_get_student_progress_url_noparams
(
self
):
""" Test that the endpoint 404's without the required query params. """
url
=
reverse
(
'get_student_progress_url'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
...
...
@@ -579,7 +592,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
url
=
reverse
(
'reset_student_attempts'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_to_reset'
:
self
.
problem_urlname
,
'
student_email
'
:
self
.
student
.
email
,
'
unique_student_identifier
'
:
self
.
student
.
email
,
})
print
response
.
content
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -608,7 +621,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
url
=
reverse
(
'reset_student_attempts'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_to_reset'
:
'robot-not-a-real-module'
,
'
student_email
'
:
self
.
student
.
email
,
'
unique_student_identifier
'
:
self
.
student
.
email
,
})
print
response
.
content
self
.
assertEqual
(
response
.
status_code
,
400
)
...
...
@@ -618,7 +631,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
url
=
reverse
(
'reset_student_attempts'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_to_reset'
:
self
.
problem_urlname
,
'
student_email
'
:
self
.
student
.
email
,
'
unique_student_identifier
'
:
self
.
student
.
email
,
'delete_module'
:
True
,
})
print
response
.
content
...
...
@@ -634,11 +647,11 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
)
def
test_reset_student_attempts_nonsense
(
self
):
""" Test failure with both
student_email
and all_students. """
""" Test failure with both
unique_student_identifier
and all_students. """
url
=
reverse
(
'reset_student_attempts'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_to_reset'
:
self
.
problem_urlname
,
'
student_email
'
:
self
.
student
.
email
,
'
unique_student_identifier
'
:
self
.
student
.
email
,
'all_students'
:
True
,
})
print
response
.
content
...
...
@@ -650,7 +663,19 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
url
=
reverse
(
'rescore_problem'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_to_reset'
:
self
.
problem_urlname
,
'student_email'
:
self
.
student
.
email
,
'unique_student_identifier'
:
self
.
student
.
email
,
})
print
response
.
content
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
act
.
called
)
@patch.object
(
instructor_task
.
api
,
'submit_rescore_problem_for_student'
)
def
test_rescore_problem_single_from_uname
(
self
,
act
):
""" Test rescoring of a single student. """
url
=
reverse
(
'rescore_problem'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_to_reset'
:
self
.
problem_urlname
,
'unique_student_identifier'
:
self
.
student
.
username
,
})
print
response
.
content
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -747,7 +772,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase):
url
=
reverse
(
'list_instructor_tasks'
,
kwargs
=
{
'course_id'
:
self
.
course
.
id
})
response
=
self
.
client
.
get
(
url
,
{
'problem_urlname'
:
self
.
problem_urlname
,
'
student_email
'
:
self
.
student
.
email
,
'
unique_student_identifier
'
:
self
.
student
.
email
,
})
print
response
.
content
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
lms/djangoapps/instructor/views/api.py
View file @
086f544a
...
...
@@ -509,7 +509,10 @@ def reset_student_attempts(request, course_id):
)
problem_to_reset
=
strip_if_string
(
request
.
GET
.
get
(
'problem_to_reset'
))
student
=
get_student_from_identifier
(
request
.
GET
.
get
(
'unique_student_identifier'
))
student_identifier
=
request
.
GET
.
get
(
'unique_student_identifier'
,
None
)
student
=
None
if
student_identifier
is
not
None
:
student
=
get_student_from_identifier
(
student_identifier
)
all_students
=
request
.
GET
.
get
(
'all_students'
,
False
)
in
[
'true'
,
'True'
,
True
]
delete_module
=
request
.
GET
.
get
(
'delete_module'
,
False
)
in
[
'true'
,
'True'
,
True
]
...
...
@@ -538,9 +541,11 @@ def reset_student_attempts(request, course_id):
enrollment
.
reset_student_attempts
(
course_id
,
student
,
module_state_key
,
delete_module
=
delete_module
)
except
StudentModule
.
DoesNotExist
:
return
HttpResponseBadRequest
(
"Module does not exist."
)
response_payload
[
'student'
]
=
student_identifier
elif
all_students
:
instructor_task
.
api
.
submit_reset_problem_attempts_for_all_students
(
request
,
course_id
,
module_state_key
)
response_payload
[
'task'
]
=
'created'
response_payload
[
'student'
]
=
'All Students'
else
:
return
HttpResponseBadRequest
()
...
...
@@ -565,9 +570,10 @@ def rescore_problem(request, course_id):
all_students and unique_student_identifier cannot both be present.
"""
problem_to_reset
=
strip_if_string
(
request
.
GET
.
get
(
'problem_to_reset'
))
student
=
request
.
GET
.
get
(
'unique_student_identifier'
,
None
)
if
student
is
not
None
:
student
=
get_student_from_identifier
(
student
)
student_identifier
=
request
.
GET
.
get
(
'unique_student_identifier'
,
None
)
student
=
None
if
student_identifier
is
not
None
:
student
=
get_student_from_identifier
(
student_identifier
)
all_students
=
request
.
GET
.
get
(
'all_students'
)
in
[
'true'
,
'True'
,
True
]
...
...
@@ -585,7 +591,7 @@ def rescore_problem(request, course_id):
response_payload
[
'problem_to_reset'
]
=
problem_to_reset
if
student
:
response_payload
[
'student'
]
=
student
response_payload
[
'student'
]
=
student
_identifier
instructor_task
.
api
.
submit_rescore_problem_for_student
(
request
,
course_id
,
module_state_key
,
student
)
response_payload
[
'task'
]
=
'created'
elif
all_students
:
...
...
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