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
9436edf8
Commit
9436edf8
authored
Feb 02, 2017
by
Nimisha Asthagiri
Committed by
GitHub
Feb 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14446 from edx/beryl/grades-mongo-query
Fix mongo query count for Grades API
parents
f7aed5cb
7cc08399
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
49 deletions
+51
-49
lms/djangoapps/grades/api/tests/test_views.py
+39
-32
lms/djangoapps/grades/new/course_grade.py
+7
-3
lms/djangoapps/grades/tasks.py
+0
-1
lms/djangoapps/grades/tests/integration/test_events.py
+5
-13
No files found.
lms/djangoapps/grades/api/tests/test_views.py
View file @
9436edf8
...
@@ -16,7 +16,7 @@ from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory, StaffF
...
@@ -16,7 +16,7 @@ from lms.djangoapps.courseware.tests.factories import GlobalStaffFactory, StaffF
from
lms.djangoapps.grades.tests.utils
import
mock_get_score
from
lms.djangoapps.grades.tests.utils
import
mock_get_score
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
,
check_mongo_calls
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
,
TEST_DATA_SPLIT_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
,
TEST_DATA_SPLIT_MODULESTORE
...
@@ -68,34 +68,35 @@ class CurrentGradeViewTest(SharedModuleStoreTestCase, APITestCase):
...
@@ -68,34 +68,35 @@ class CurrentGradeViewTest(SharedModuleStoreTestCase, APITestCase):
super
(
CurrentGradeViewTest
,
cls
)
.
setUpClass
()
super
(
CurrentGradeViewTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
display_name
=
'test course'
,
run
=
"Testing_course"
)
cls
.
course
=
CourseFactory
.
create
(
display_name
=
'test course'
,
run
=
"Testing_course"
)
with
cls
.
store
.
bulk_operations
(
cls
.
course
.
id
):
chapter
=
ItemFactory
.
create
(
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
category
=
'chapter'
,
parent_location
=
cls
.
course
.
location
,
parent_location
=
cls
.
course
.
location
,
display_name
=
"Chapter 1"
,
display_name
=
"Chapter 1"
,
)
)
# create a problem for each type and minimum count needed by the grading policy
# create a problem for each type and minimum count needed by the grading policy
# A section is not considered if the student answers less than "min_count" problems
# A section is not considered if the student answers less than "min_count" problems
for
grading_type
,
min_count
in
((
"Homework"
,
12
),
(
"Lab"
,
12
),
(
"Midterm Exam"
,
1
),
(
"Final Exam"
,
1
)):
for
grading_type
,
min_count
in
((
"Homework"
,
12
),
(
"Lab"
,
12
),
(
"Midterm Exam"
,
1
),
(
"Final Exam"
,
1
)):
for
num
in
xrange
(
min_count
):
for
num
in
xrange
(
min_count
):
section
=
ItemFactory
.
create
(
section
=
ItemFactory
.
create
(
category
=
'sequential'
,
category
=
'sequential'
,
parent_location
=
chapter
.
location
,
parent_location
=
chapter
.
location
,
due
=
datetime
(
2013
,
9
,
18
,
11
,
30
,
00
),
due
=
datetime
(
2013
,
9
,
18
,
11
,
30
,
00
,
tzinfo
=
UTC
),
display_name
=
'Sequential {} {}'
.
format
(
grading_type
,
num
),
display_name
=
'Sequential {} {}'
.
format
(
grading_type
,
num
),
format
=
grading_type
,
format
=
grading_type
,
graded
=
True
,
graded
=
True
,
)
)
vertical
=
ItemFactory
.
create
(
vertical
=
ItemFactory
.
create
(
category
=
'vertical'
,
category
=
'vertical'
,
parent_location
=
section
.
location
,
parent_location
=
section
.
location
,
display_name
=
'Vertical {} {}'
.
format
(
grading_type
,
num
),
display_name
=
'Vertical {} {}'
.
format
(
grading_type
,
num
),
)
)
ItemFactory
.
create
(
ItemFactory
.
create
(
category
=
'problem'
,
category
=
'problem'
,
parent_location
=
vertical
.
location
,
parent_location
=
vertical
.
location
,
display_name
=
'Problem {} {}'
.
format
(
grading_type
,
num
),
display_name
=
'Problem {} {}'
.
format
(
grading_type
,
num
),
)
)
cls
.
course_key
=
cls
.
course
.
id
cls
.
course_key
=
cls
.
course
.
id
...
@@ -141,8 +142,14 @@ class CurrentGradeViewTest(SharedModuleStoreTestCase, APITestCase):
...
@@ -141,8 +142,14 @@ class CurrentGradeViewTest(SharedModuleStoreTestCase, APITestCase):
"""
"""
Test that a user can successfully request her own grade.
Test that a user can successfully request her own grade.
"""
"""
resp
=
self
.
client
.
get
(
self
.
get_url
(
self
.
student
.
username
))
with
check_mongo_calls
(
6
):
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_200_OK
)
resp
=
self
.
client
.
get
(
self
.
get_url
(
self
.
student
.
username
))
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_200_OK
)
# redo with block structure now in the cache
with
check_mongo_calls
(
3
):
resp
=
self
.
client
.
get
(
self
.
get_url
(
self
.
student
.
username
))
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_200_OK
)
def
test_nonexistent_user
(
self
):
def
test_nonexistent_user
(
self
):
"""
"""
...
@@ -383,8 +390,8 @@ class GradingPolicyTestMixin(object):
...
@@ -383,8 +390,8 @@ class GradingPolicyTestMixin(object):
The view should be addressable by course-keys from both module stores.
The view should be addressable by course-keys from both module stores.
"""
"""
course
=
CourseFactory
.
create
(
course
=
CourseFactory
.
create
(
start
=
datetime
(
2014
,
6
,
16
,
14
,
30
),
start
=
datetime
(
2014
,
6
,
16
,
14
,
30
,
tzinfo
=
UTC
),
end
=
datetime
(
2015
,
1
,
16
),
end
=
datetime
(
2015
,
1
,
16
,
tzinfo
=
UTC
),
org
=
"MTD"
,
org
=
"MTD"
,
default_store
=
modulestore_type
,
default_store
=
modulestore_type
,
)
)
...
...
lms/djangoapps/grades/new/course_grade.py
View file @
9436edf8
...
@@ -31,11 +31,15 @@ class CourseGrade(object):
...
@@ -31,11 +31,15 @@ class CourseGrade(object):
def
__init__
(
self
,
student
,
course
,
course_structure
):
def
__init__
(
self
,
student
,
course
,
course_structure
):
self
.
student
=
student
self
.
student
=
student
self
.
course
=
course
self
.
course
=
course
self
.
course_version
=
getattr
(
course
,
'course_version'
,
None
)
self
.
course_edited_timestamp
=
getattr
(
course
,
'subtree_edited_on'
,
None
)
self
.
course_structure
=
course_structure
self
.
_percent
=
None
self
.
_percent
=
None
self
.
_letter_grade
=
None
self
.
_letter_grade
=
None
self
.
course_structure
=
course_structure
if
self
.
course_structure
:
course_block
=
course_structure
[
course
.
location
]
self
.
course_version
=
getattr
(
course_block
,
'course_version'
,
None
)
self
.
course_edited_timestamp
=
getattr
(
course_block
,
'subtree_edited_on'
,
None
)
self
.
_subsection_grade_factory
=
SubsectionGradeFactory
(
self
.
student
,
self
.
course
,
self
.
course_structure
)
self
.
_subsection_grade_factory
=
SubsectionGradeFactory
(
self
.
student
,
self
.
course
,
self
.
course_structure
)
@lazy
@lazy
...
...
lms/djangoapps/grades/tasks.py
View file @
9436edf8
...
@@ -16,7 +16,6 @@ from openedx.core.djangoapps.celery_utils.persist_on_failure import PersistOnFai
...
@@ -16,7 +16,6 @@ from openedx.core.djangoapps.celery_utils.persist_on_failure import PersistOnFai
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.locator
import
CourseLocator
from
opaque_keys.edx.locator
import
CourseLocator
from
submissions
import
api
as
sub_api
from
submissions
import
api
as
sub_api
from
student.models
import
anonymous_id_for_user
from
track.event_transaction_utils
import
(
from
track.event_transaction_utils
import
(
set_event_transaction_type
,
set_event_transaction_type
,
set_event_transaction_id
,
set_event_transaction_id
,
...
...
lms/djangoapps/grades/tests/integration/test_events.py
View file @
9436edf8
...
@@ -30,7 +30,6 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -30,7 +30,6 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
super
(
GradesEventIntegrationTest
,
cls
)
.
setUpClass
()
super
(
GradesEventIntegrationTest
,
cls
)
.
setUpClass
()
cls
.
store
=
modulestore
()
with
cls
.
store
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
with
cls
.
store
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
cls
.
course
=
CourseFactory
.
create
()
cls
.
course
=
CourseFactory
.
create
()
cls
.
chapter
=
ItemFactory
.
create
(
cls
.
chapter
=
ItemFactory
.
create
(
...
@@ -141,7 +140,7 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -141,7 +140,7 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
}
}
)
)
course
=
modulestore
()
.
get_course
(
self
.
course
.
id
,
depth
=
0
)
course
=
self
.
store
.
get_course
(
self
.
course
.
id
,
depth
=
0
)
models_tracker
.
emit
.
assert_called_with
(
models_tracker
.
emit
.
assert_called_with
(
u'edx.grades.course.grade_calculated'
,
u'edx.grades.course.grade_calculated'
,
{
{
...
@@ -156,9 +155,6 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -156,9 +155,6 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
'course_version'
:
unicode
(
course
.
course_version
),
'course_version'
:
unicode
(
course
.
course_version
),
}
}
)
)
enrollment_tracker
.
reset_mock
()
models_tracker
.
reset_mock
()
handlers_tracker
.
reset_mock
()
@patch
(
'lms.djangoapps.instructor_task.tasks_helper.tracker'
)
@patch
(
'lms.djangoapps.instructor_task.tasks_helper.tracker'
)
@patch
(
'lms.djangoapps.grades.signals.handlers.tracker'
)
@patch
(
'lms.djangoapps.grades.signals.handlers.tracker'
)
...
@@ -174,11 +170,10 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -174,11 +170,10 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
choices
=
[
False
,
False
,
False
,
True
],
choices
=
[
False
,
False
,
False
,
True
],
choice_names
=
[
'choice_0'
,
'choice_1'
,
'choice_2'
,
'choice_3'
]
choice_names
=
[
'choice_0'
,
'choice_1'
,
'choice_2'
,
'choice_3'
]
)
)
module_store
=
modulestore
()
with
self
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
self
.
course
.
id
):
with
module_store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
self
.
course
.
id
):
self
.
problem
.
data
=
new_problem_xml
self
.
problem
.
data
=
new_problem_xml
module_
store
.
update_item
(
self
.
problem
,
self
.
instructor
.
id
)
self
.
store
.
update_item
(
self
.
problem
,
self
.
instructor
.
id
)
module_
store
.
publish
(
self
.
problem
.
location
,
self
.
instructor
.
id
)
self
.
store
.
publish
(
self
.
problem
.
location
,
self
.
instructor
.
id
)
submit_rescore_problem_for_student
(
submit_rescore_problem_for_student
(
request
=
get_mock_request
(
self
.
instructor
),
request
=
get_mock_request
(
self
.
instructor
),
...
@@ -221,7 +216,7 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -221,7 +216,7 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
'event_transaction_type'
:
unicode
(
RESCORE_TYPE
),
'event_transaction_type'
:
unicode
(
RESCORE_TYPE
),
}
}
)
)
course
=
modulestore
()
.
get_course
(
self
.
course
.
id
,
depth
=
0
)
course
=
self
.
store
.
get_course
(
self
.
course
.
id
,
depth
=
0
)
models_tracker
.
emit
.
assert_called_with
(
models_tracker
.
emit
.
assert_called_with
(
u'edx.grades.course.grade_calculated'
,
u'edx.grades.course.grade_calculated'
,
{
{
...
@@ -236,6 +231,3 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -236,6 +231,3 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
'course_edited_timestamp'
:
unicode
(
course
.
subtree_edited_on
),
'course_edited_timestamp'
:
unicode
(
course
.
subtree_edited_on
),
}
}
)
)
instructor_task_tracker
.
reset_mock
()
models_tracker
.
reset_mock
()
handlers_tracker
.
reset_mock
()
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