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
750f30b2
Commit
750f30b2
authored
Jul 31, 2017
by
Tyler Hallada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass event transaction id & type to recalculate
parent
735824e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
lms/djangoapps/grades/services.py
+10
-0
lms/djangoapps/grades/signals/handlers.py
+14
-0
No files found.
lms/djangoapps/grades/services.py
View file @
750f30b2
...
@@ -3,10 +3,12 @@ from datetime import datetime
...
@@ -3,10 +3,12 @@ from datetime import datetime
import
pytz
import
pytz
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
track.event_transaction_utils
import
create_new_event_transaction_id
,
set_event_transaction_type
from
util.date_utils
import
to_timestamp
from
util.date_utils
import
to_timestamp
from
.constants
import
ScoreDatabaseTableEnum
from
.constants
import
ScoreDatabaseTableEnum
from
.models
import
PersistentSubsectionGrade
,
PersistentSubsectionGradeOverride
from
.models
import
PersistentSubsectionGrade
,
PersistentSubsectionGradeOverride
from
.signals.handlers
import
SUBSECTION_RESCORE_EVENT_TYPE
def
_get_key
(
key_or_id
,
key_cls
):
def
_get_key
(
key_or_id
,
key_cls
):
...
@@ -87,6 +89,8 @@ class GradesService(object):
...
@@ -87,6 +89,8 @@ class GradesService(object):
# Recalculation will call PersistentSubsectionGrade.update_or_create_grade which will use the above override
# Recalculation will call PersistentSubsectionGrade.update_or_create_grade which will use the above override
# to update the grade before writing to the table.
# to update the grade before writing to the table.
event_transaction_id
=
create_new_event_transaction_id
()
set_event_transaction_type
(
SUBSECTION_RESCORE_EVENT_TYPE
)
recalculate_subsection_grade_v3
.
apply_async
(
recalculate_subsection_grade_v3
.
apply_async
(
kwargs
=
dict
(
kwargs
=
dict
(
user_id
=
user_id
,
user_id
=
user_id
,
...
@@ -94,6 +98,8 @@ class GradesService(object):
...
@@ -94,6 +98,8 @@ class GradesService(object):
usage_id
=
unicode
(
usage_key
),
usage_id
=
unicode
(
usage_key
),
only_if_higher
=
False
,
only_if_higher
=
False
,
expected_modified
=
to_timestamp
(
override
.
modified
),
expected_modified
=
to_timestamp
(
override
.
modified
),
event_transaction_id
=
unicode
(
event_transaction_id
),
event_transaction_type
=
SUBSECTION_RESCORE_EVENT_TYPE
,
score_db_table
=
ScoreDatabaseTableEnum
.
overrides
score_db_table
=
ScoreDatabaseTableEnum
.
overrides
)
)
)
)
...
@@ -115,6 +121,8 @@ class GradesService(object):
...
@@ -115,6 +121,8 @@ class GradesService(object):
if
override
is
not
None
:
if
override
is
not
None
:
override
.
delete
()
override
.
delete
()
event_transaction_id
=
create_new_event_transaction_id
()
set_event_transaction_type
(
SUBSECTION_RESCORE_EVENT_TYPE
)
recalculate_subsection_grade_v3
.
apply_async
(
recalculate_subsection_grade_v3
.
apply_async
(
kwargs
=
dict
(
kwargs
=
dict
(
user_id
=
user_id
,
user_id
=
user_id
,
...
@@ -124,6 +132,8 @@ class GradesService(object):
...
@@ -124,6 +132,8 @@ class GradesService(object):
# Not used when score_deleted=True:
# Not used when score_deleted=True:
expected_modified
=
to_timestamp
(
datetime
.
now
()
.
replace
(
tzinfo
=
pytz
.
UTC
)),
expected_modified
=
to_timestamp
(
datetime
.
now
()
.
replace
(
tzinfo
=
pytz
.
UTC
)),
score_deleted
=
True
,
score_deleted
=
True
,
event_transaction_id
=
unicode
(
event_transaction_id
),
event_transaction_type
=
SUBSECTION_RESCORE_EVENT_TYPE
,
score_db_table
=
ScoreDatabaseTableEnum
.
overrides
score_db_table
=
ScoreDatabaseTableEnum
.
overrides
)
)
)
)
lms/djangoapps/grades/signals/handlers.py
View file @
750f30b2
...
@@ -38,6 +38,7 @@ log = getLogger(__name__)
...
@@ -38,6 +38,7 @@ log = getLogger(__name__)
# define values to be used in grading events
# define values to be used in grading events
GRADES_RESCORE_EVENT_TYPE
=
'edx.grades.problem.rescored'
GRADES_RESCORE_EVENT_TYPE
=
'edx.grades.problem.rescored'
PROBLEM_SUBMITTED_EVENT_TYPE
=
'edx.grades.problem.submitted'
PROBLEM_SUBMITTED_EVENT_TYPE
=
'edx.grades.problem.submitted'
SUBSECTION_RESCORE_EVENT_TYPE
=
'edx.grades.subsection.rescored'
@receiver
(
score_set
)
@receiver
(
score_set
)
...
@@ -292,3 +293,16 @@ def _emit_event(kwargs):
...
@@ -292,3 +293,16 @@ def _emit_event(kwargs):
'event_transaction_type'
:
unicode
(
root_type
),
'event_transaction_type'
:
unicode
(
root_type
),
}
}
)
)
if
root_type
in
[
SUBSECTION_RESCORE_EVENT_TYPE
]:
tracker
.
emit
(
unicode
(
SUBSECTION_RESCORE_EVENT_TYPE
),
{
'course_id'
:
unicode
(
kwargs
[
'course_id'
]),
'user_id'
:
unicode
(
kwargs
[
'user_id'
]),
'problem_id'
:
unicode
(
kwargs
[
'usage_id'
]),
'only_if_higher'
:
kwargs
.
get
(
'only_if_higher'
),
'event_transaction_id'
:
unicode
(
get_event_transaction_id
()),
'event_transaction_type'
:
unicode
(
root_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