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
74a66664
Commit
74a66664
authored
Dec 21, 2016
by
sanfordstudent
Committed by
GitHub
Dec 21, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14151 from edx/sstudent/TNL-6178
context manager for course id in context
parents
fc79fae5
ac9b8fba
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
8 deletions
+32
-8
lms/djangoapps/grades/models.py
+11
-2
lms/djangoapps/grades/tests/integration/test_events.py
+16
-6
lms/djangoapps/instructor_task/tasks_helper.py
+5
-0
No files found.
lms/djangoapps/grades/models.py
View file @
74a66664
...
@@ -20,6 +20,7 @@ from django.db import models
...
@@ -20,6 +20,7 @@ from django.db import models
from
django.utils.timezone
import
now
from
django.utils.timezone
import
now
from
eventtracking
import
tracker
from
eventtracking
import
tracker
from
model_utils.models
import
TimeStampedModel
from
model_utils.models
import
TimeStampedModel
from
track
import
contexts
from
track.event_transaction_utils
import
get_event_transaction_id
,
get_event_transaction_type
from
track.event_transaction_utils
import
get_event_transaction_id
,
get_event_transaction_type
from
coursewarehistoryextended.fields
import
UnsignedBigIntAutoField
from
coursewarehistoryextended.fields
import
UnsignedBigIntAutoField
...
@@ -433,8 +434,12 @@ class PersistentSubsectionGrade(TimeStampedModel):
...
@@ -433,8 +434,12 @@ class PersistentSubsectionGrade(TimeStampedModel):
Emits an edx.grades.subsection.grade_calculated event
Emits an edx.grades.subsection.grade_calculated event
with data from the passed grade.
with data from the passed grade.
"""
"""
# TODO: remove this context manager after completion of AN-6134
event_name
=
u'edx.grades.subsection.grade_calculated'
context
=
contexts
.
course_context_from_course_id
(
grade
.
course_id
)
with
tracker
.
get_tracker
()
.
context
(
event_name
,
context
):
tracker
.
emit
(
tracker
.
emit
(
u'edx.grades.subsection.grade_calculated'
,
event_name
,
{
{
'user_id'
:
unicode
(
grade
.
user_id
),
'user_id'
:
unicode
(
grade
.
user_id
),
'course_id'
:
unicode
(
grade
.
course_id
),
'course_id'
:
unicode
(
grade
.
course_id
),
...
@@ -543,8 +548,12 @@ class PersistentCourseGrade(TimeStampedModel):
...
@@ -543,8 +548,12 @@ class PersistentCourseGrade(TimeStampedModel):
Emits an edx.grades.course.grade_calculated event
Emits an edx.grades.course.grade_calculated event
with data from the passed grade.
with data from the passed grade.
"""
"""
# TODO: remove this context manager after completion of AN-6134
event_name
=
u'edx.grades.course.grade_calculated'
context
=
contexts
.
course_context_from_course_id
(
grade
.
course_id
)
with
tracker
.
get_tracker
()
.
context
(
event_name
,
context
):
tracker
.
emit
(
tracker
.
emit
(
u'edx.grades.course.grade_calculated'
,
event_name
,
{
{
'user_id'
:
unicode
(
grade
.
user_id
),
'user_id'
:
unicode
(
grade
.
user_id
),
'course_id'
:
unicode
(
grade
.
course_id
),
'course_id'
:
unicode
(
grade
.
course_id
),
...
...
lms/djangoapps/grades/tests/integration/test_events.py
View file @
74a66664
...
@@ -80,8 +80,8 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -80,8 +80,8 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
self
.
submit_question_answer
(
'p1'
,
{
'2_1'
:
'choice_choice_2'
})
self
.
submit_question_answer
(
'p1'
,
{
'2_1'
:
'choice_choice_2'
})
# check logging to make sure id's are tracked correctly across events
# check logging to make sure id's are tracked correctly across events
event_transaction_id
=
handlers_tracker
.
method
_calls
[
0
][
1
][
1
][
'event_transaction_id'
]
event_transaction_id
=
handlers_tracker
.
emit
.
mock
_calls
[
0
][
1
][
1
][
'event_transaction_id'
]
for
call
in
models_tracker
.
method
_calls
:
for
call
in
models_tracker
.
emit
.
mock
_calls
:
self
.
assertEqual
(
event_transaction_id
,
call
[
1
][
1
][
'event_transaction_id'
])
self
.
assertEqual
(
event_transaction_id
,
call
[
1
][
1
][
'event_transaction_id'
])
self
.
assertEqual
(
unicode
(
SUBMITTED_TYPE
),
call
[
1
][
1
][
'event_transaction_type'
])
self
.
assertEqual
(
unicode
(
SUBMITTED_TYPE
),
call
[
1
][
1
][
'event_transaction_type'
])
...
@@ -123,7 +123,7 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -123,7 +123,7 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
event_transaction_id
=
enrollment_tracker
.
method_calls
[
0
][
1
][
1
][
'event_transaction_id'
]
event_transaction_id
=
enrollment_tracker
.
method_calls
[
0
][
1
][
1
][
'event_transaction_id'
]
# make sure the id is propagated throughout the event flow
# make sure the id is propagated throughout the event flow
for
call
in
models_tracker
.
method
_calls
:
for
call
in
models_tracker
.
emit
.
mock
_calls
:
self
.
assertEqual
(
event_transaction_id
,
call
[
1
][
1
][
'event_transaction_id'
])
self
.
assertEqual
(
event_transaction_id
,
call
[
1
][
1
][
'event_transaction_id'
])
self
.
assertEqual
(
unicode
(
STATE_DELETED_TYPE
),
call
[
1
][
1
][
'event_transaction_type'
])
self
.
assertEqual
(
unicode
(
STATE_DELETED_TYPE
),
call
[
1
][
1
][
'event_transaction_type'
])
...
@@ -188,13 +188,23 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
...
@@ -188,13 +188,23 @@ class GradesEventIntegrationTest(ProblemSubmissionTestMixin, SharedModuleStoreTe
)
)
# check logging to make sure id's are tracked correctly across
# check logging to make sure id's are tracked correctly across
# events
# events
event_transaction_id
=
instructor_task_tracker
.
method_calls
[
0
][
1
][
1
][
'event_transaction_id'
]
event_transaction_id
=
instructor_task_tracker
.
emit
.
mock_calls
[
0
][
1
][
1
][
'event_transaction_id'
]
self
.
assertEqual
(
instructor_task_tracker
.
get_tracker
()
.
context
.
call_args
[
0
],
(
'edx.grades.problem.rescored'
,
{
'course_id'
:
unicode
(
self
.
course
.
id
),
'org_id'
:
unicode
(
self
.
course
.
org
)})
)
# make sure the id is propagated throughout the event flow
# make sure the id is propagated throughout the event flow
for
call
in
models_tracker
.
method
_calls
:
for
call
in
models_tracker
.
emit
.
mock
_calls
:
self
.
assertEqual
(
event_transaction_id
,
call
[
1
][
1
][
'event_transaction_id'
])
self
.
assertEqual
(
event_transaction_id
,
call
[
1
][
1
][
'event_transaction_id'
])
self
.
assertEqual
(
unicode
(
RESCORE_TYPE
),
call
[
1
][
1
][
'event_transaction_type'
])
self
.
assertEqual
(
unicode
(
RESCORE_TYPE
),
call
[
1
][
1
][
'event_transaction_type'
])
# make sure the models calls have re-added the course id to the context
for
args
in
models_tracker
.
get_tracker
()
.
context
.
call_args_list
:
self
.
assertEqual
(
args
[
0
][
1
],
{
'course_id'
:
unicode
(
self
.
course
.
id
),
'org_id'
:
unicode
(
self
.
course
.
org
)}
)
handlers_tracker
.
assert_not_called
()
handlers_tracker
.
assert_not_called
()
instructor_task_tracker
.
emit
.
assert_called_with
(
instructor_task_tracker
.
emit
.
assert_called_with
(
...
...
lms/djangoapps/instructor_task/tasks_helper.py
View file @
74a66664
...
@@ -28,6 +28,7 @@ from lms.djangoapps.instructor.paidcourse_enrollment_report import PaidCourseEnr
...
@@ -28,6 +28,7 @@ from lms.djangoapps.instructor.paidcourse_enrollment_report import PaidCourseEnr
from
lms.djangoapps.teams.models
import
CourseTeamMembership
from
lms.djangoapps.teams.models
import
CourseTeamMembership
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
from
lms.djangoapps.verify_student.models
import
SoftwareSecurePhotoVerification
from
pytz
import
UTC
from
pytz
import
UTC
from
track
import
contexts
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
from
xmodule.split_test_module
import
get_split_user_partitions
from
xmodule.split_test_module
import
get_split_user_partitions
...
@@ -573,6 +574,10 @@ def rescore_problem_module_state(xmodule_instance_args, module_descriptor, stude
...
@@ -573,6 +574,10 @@ def rescore_problem_module_state(xmodule_instance_args, module_descriptor, stude
result
[
'new_raw_possible'
],
result
[
'new_raw_possible'
],
module_descriptor
.
weight
,
module_descriptor
.
weight
,
)
)
# TODO: remove this context manager after completion of AN-6134
context
=
contexts
.
course_context_from_course_id
(
course_id
)
with
tracker
.
get_tracker
()
.
context
(
GRADES_RESCORE_EVENT_TYPE
,
context
):
tracker
.
emit
(
tracker
.
emit
(
unicode
(
GRADES_RESCORE_EVENT_TYPE
),
unicode
(
GRADES_RESCORE_EVENT_TYPE
),
{
{
...
...
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