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
52069197
Commit
52069197
authored
Oct 22, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correct task_type for other rescore-if-higher admin commands.
parent
c01df600
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
23 deletions
+33
-23
lms/djangoapps/instructor_task/api.py
+2
-2
lms/djangoapps/instructor_task/tests/test_api.py
+31
-21
No files found.
lms/djangoapps/instructor_task/api.py
View file @
52069197
...
...
@@ -134,7 +134,7 @@ def submit_rescore_problem_for_all_students(request, usage_key, only_if_higher=F
check_arguments_for_rescoring
(
usage_key
)
# check to see if task is already running, and reserve it otherwise
task_type
=
'rescore_problem'
task_type
=
'rescore_problem
_if_higher'
if
only_if_higher
else
'rescore_problem
'
task_class
=
rescore_problem
task_input
,
task_key
=
encode_problem_and_student_input
(
usage_key
)
task_input
.
update
({
'only_if_higher'
:
only_if_higher
})
...
...
@@ -160,7 +160,7 @@ def submit_rescore_entrance_exam_for_student(request, usage_key, student=None, o
check_entrance_exam_problems_for_rescoring
(
usage_key
)
# check to see if task is already running, and reserve it otherwise
task_type
=
'rescore_problem'
task_type
=
'rescore_problem
_if_higher'
if
only_if_higher
else
'rescore_problem
'
task_class
=
rescore_problem
task_input
,
task_key
=
encode_entrance_exam_and_student_input
(
usage_key
,
student
)
task_input
.
update
({
'only_if_higher'
:
only_if_higher
})
...
...
lms/djangoapps/instructor_task/tests/test_api.py
View file @
52069197
"""
Test for LMS instructor background task queue management
"""
import
ddt
from
mock
import
patch
,
Mock
,
MagicMock
from
nose.plugins.attrib
import
attr
from
bulk_email.models
import
CourseEmail
,
SEND_TO_MYSELF
,
SEND_TO_STAFF
,
SEND_TO_LEARNERS
...
...
@@ -12,8 +13,11 @@ from lms.djangoapps.instructor_task.api import (
get_instructor_task_history
,
submit_rescore_problem_for_all_students
,
submit_rescore_problem_for_student
,
submit_rescore_entrance_exam_for_student
,
submit_reset_problem_attempts_for_all_students
,
submit_reset_problem_attempts_in_entrance_exam
,
submit_delete_problem_state_for_all_students
,
submit_delete_entrance_exam_state_for_student
,
submit_bulk_course_email
,
submit_calculate_problem_responses_csv
,
submit_calculate_students_features_csv
,
...
...
@@ -84,6 +88,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
@attr
(
shard
=
3
)
@ddt.ddt
class
InstructorTaskModuleSubmitTest
(
InstructorTaskModuleTestCase
):
"""Tests API methods that involve the submission of module-based background tasks."""
...
...
@@ -140,15 +145,35 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
def
test_submit_delete_all_with_long_url
(
self
):
self
.
_test_submit_with_long_url
(
submit_delete_problem_state_for_all_students
)
def
_test_submit_task
(
self
,
task_function
,
student
=
None
):
@ddt.data
(
(
submit_rescore_problem_for_all_students
,
'rescore_problem'
),
(
submit_rescore_problem_for_all_students
,
'rescore_problem_if_higher'
,
{
'only_if_higher'
:
True
}),
(
submit_rescore_problem_for_student
,
'rescore_problem'
,
{
'student'
:
True
}),
(
submit_rescore_problem_for_student
,
'rescore_problem_if_higher'
,
{
'student'
:
True
,
'only_if_higher'
:
True
}),
(
submit_reset_problem_attempts_for_all_students
,
'reset_problem_attempts'
),
(
submit_delete_problem_state_for_all_students
,
'delete_problem_state'
),
(
submit_rescore_entrance_exam_for_student
,
'rescore_problem'
,
{
'student'
:
True
}),
(
submit_rescore_entrance_exam_for_student
,
'rescore_problem_if_higher'
,
{
'student'
:
True
,
'only_if_higher'
:
True
},
),
(
submit_reset_problem_attempts_in_entrance_exam
,
'reset_problem_attempts'
,
{
'student'
:
True
}),
(
submit_delete_entrance_exam_state_for_student
,
'delete_problem_state'
,
{
'student'
:
True
}),
)
@ddt.unpack
def
test_submit_task
(
self
,
task_function
,
expected_task_type
,
params
=
None
):
if
params
is
None
:
params
=
{}
if
params
.
get
(
'student'
):
params
[
'student'
]
=
self
.
student
# tests submit, and then tests a second identical submission.
problem_url_name
=
'H1P1'
self
.
define_option_problem
(
problem_url_name
)
location
=
InstructorTaskModuleTestCase
.
problem_location
(
problem_url_name
)
if
student
is
not
None
:
instructor_task
=
task_function
(
self
.
create_task_request
(
self
.
instructor
),
location
,
student
)
else
:
instructor_task
=
task_function
(
self
.
create_task_request
(
self
.
instructor
),
location
)
instructor_task
=
task_function
(
self
.
create_task_request
(
self
.
instructor
),
location
,
**
params
)
self
.
assertEquals
(
instructor_task
.
task_type
,
expected_task_type
)
# test resubmitting, by updating the existing record:
instructor_task
=
InstructorTask
.
objects
.
get
(
id
=
instructor_task
.
id
)
...
...
@@ -156,22 +181,7 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
instructor_task
.
save
()
with
self
.
assertRaises
(
AlreadyRunningError
):
if
student
is
not
None
:
task_function
(
self
.
create_task_request
(
self
.
instructor
),
location
,
student
)
else
:
task_function
(
self
.
create_task_request
(
self
.
instructor
),
location
)
def
test_submit_rescore_all
(
self
):
self
.
_test_submit_task
(
submit_rescore_problem_for_all_students
)
def
test_submit_rescore_student
(
self
):
self
.
_test_submit_task
(
submit_rescore_problem_for_student
,
self
.
student
)
def
test_submit_reset_all
(
self
):
self
.
_test_submit_task
(
submit_reset_problem_attempts_for_all_students
)
def
test_submit_delete_all
(
self
):
self
.
_test_submit_task
(
submit_delete_problem_state_for_all_students
)
task_function
(
self
.
create_task_request
(
self
.
instructor
),
location
,
**
params
)
@attr
(
shard
=
3
)
...
...
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