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
2d1ebb73
Commit
2d1ebb73
authored
Jun 18, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test when querying for a non-existent task
parent
77032067
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
24 deletions
+34
-24
lms/djangoapps/instructor_task/api_helper.py
+7
-7
lms/djangoapps/instructor_task/tests/test_views.py
+8
-0
lms/djangoapps/instructor_task/views.py
+19
-17
No files found.
lms/djangoapps/instructor_task/api_helper.py
View file @
2d1ebb73
...
@@ -189,13 +189,13 @@ def get_status_from_instructor_task(instructor_task):
...
@@ -189,13 +189,13 @@ def get_status_from_instructor_task(instructor_task):
"""
"""
status
=
{}
status
=
{}
if
instructor_task
.
task_output
is
not
None
:
if
instructor_task
is
not
None
:
status
[
'task_progress'
]
=
json
.
loads
(
instructor_task
.
task_output
)
# status basic information matching what's stored in InstructorTask:
status
[
'task_id'
]
=
instructor_task
.
task_id
# status basic information matching what's stored in InstructorTask:
status
[
'task_state'
]
=
instructor_task
.
task_state
status
[
'task_id'
]
=
instructor_task
.
task_id
status
[
'in_progress'
]
=
instructor_task
.
task_state
not
in
READY_STATES
status
[
'task_state'
]
=
instructor_task
.
task_state
if
instructor_task
.
task_output
is
not
None
:
status
[
'in_progress'
]
=
instructor_task
.
task_state
not
in
READY_STATES
status
[
'task_progress'
]
=
json
.
loads
(
instructor_task
.
task_output
)
return
status
return
status
...
...
lms/djangoapps/instructor_task/tests/test_views.py
View file @
2d1ebb73
...
@@ -36,6 +36,14 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
...
@@ -36,6 +36,14 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
output
=
json
.
loads
(
response
.
content
)
output
=
json
.
loads
(
response
.
content
)
self
.
assertEquals
(
output
[
'task_id'
],
task_id
)
self
.
assertEquals
(
output
[
'task_id'
],
task_id
)
def
test_missing_instructor_task_status
(
self
):
task_id
=
"missing_id"
request
=
Mock
()
request
.
REQUEST
=
{
'task_id'
:
task_id
}
response
=
instructor_task_status
(
request
)
output
=
json
.
loads
(
response
.
content
)
self
.
assertEquals
(
output
,
{})
def
test_instructor_task_status_list
(
self
):
def
test_instructor_task_status_list
(
self
):
# Fetch status for existing tasks by arg list, as if called from ajax.
# Fetch status for existing tasks by arg list, as if called from ajax.
# Note that ajax does something funny with the marshalling of
# Note that ajax does something funny with the marshalling of
...
...
lms/djangoapps/instructor_task/views.py
View file @
2d1ebb73
...
@@ -17,6 +17,23 @@ log = logging.getLogger(__name__)
...
@@ -17,6 +17,23 @@ log = logging.getLogger(__name__)
STATES_WITH_STATUS
=
[
state
for
state
in
READY_STATES
]
+
[
PROGRESS
]
STATES_WITH_STATUS
=
[
state
for
state
in
READY_STATES
]
+
[
PROGRESS
]
def
_get_instructor_task_status
(
task_id
):
"""
Returns status for a specific task.
Written as an internal method here (rather than as a helper)
so that get_task_completion_info() can be called without
causing a circular dependency (since it's also called directly).
"""
instructor_task
=
get_updated_instructor_task
(
task_id
)
status
=
get_status_from_instructor_task
(
instructor_task
)
if
instructor_task
is
not
None
and
instructor_task
.
task_state
in
STATES_WITH_STATUS
:
succeeded
,
message
=
get_task_completion_info
(
instructor_task
)
status
[
'message'
]
=
message
status
[
'succeeded'
]
=
succeeded
return
status
def
instructor_task_status
(
request
):
def
instructor_task_status
(
request
):
"""
"""
View method that returns the status of a course-related task or tasks.
View method that returns the status of a course-related task or tasks.
...
@@ -57,30 +74,15 @@ def instructor_task_status(request):
...
@@ -57,30 +74,15 @@ def instructor_task_status(request):
'traceback': optional, returned if task failed and produced a traceback.
'traceback': optional, returned if task failed and produced a traceback.
"""
"""
def
get_instructor_task_status
(
task_id
):
"""
Returns status for a specific task.
Written as an internal method here (rather than as a helper)
so that get_task_completion_info() can be called without
causing a circular dependency (since it's also called directly).
"""
instructor_task
=
get_updated_instructor_task
(
task_id
)
status
=
get_status_from_instructor_task
(
instructor_task
)
if
instructor_task
.
task_state
in
STATES_WITH_STATUS
:
succeeded
,
message
=
get_task_completion_info
(
instructor_task
)
status
[
'message'
]
=
message
status
[
'succeeded'
]
=
succeeded
return
status
output
=
{}
output
=
{}
if
'task_id'
in
request
.
REQUEST
:
if
'task_id'
in
request
.
REQUEST
:
task_id
=
request
.
REQUEST
[
'task_id'
]
task_id
=
request
.
REQUEST
[
'task_id'
]
output
=
get_instructor_task_status
(
task_id
)
output
=
_
get_instructor_task_status
(
task_id
)
elif
'task_ids[]'
in
request
.
REQUEST
:
elif
'task_ids[]'
in
request
.
REQUEST
:
tasks
=
request
.
REQUEST
.
getlist
(
'task_ids[]'
)
tasks
=
request
.
REQUEST
.
getlist
(
'task_ids[]'
)
for
task_id
in
tasks
:
for
task_id
in
tasks
:
task_output
=
get_instructor_task_status
(
task_id
)
task_output
=
_
get_instructor_task_status
(
task_id
)
if
task_output
is
not
None
:
if
task_output
is
not
None
:
output
[
task_id
]
=
task_output
output
[
task_id
]
=
task_output
...
...
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