Merge pull request #20613 from edx/estute/INCR-312

incr-312
This commit is contained in:
Douglas Hall
2019-05-15 14:23:31 -04:00
committed by GitHub
2 changed files with 19 additions and 14 deletions

View File

@@ -1,36 +1,39 @@
"""
Grades related signals.
"""
from __future__ import absolute_import
from contextlib import contextmanager
from logging import getLogger
import six
from courseware.model_data import get_score, set_score
from django.dispatch import receiver
from submissions.models import score_reset, score_set
from xblock.scorable import ScorableXBlockMixin, Score
from courseware.model_data import get_score, set_score
from openedx.core.djangoapps.course_groups.signals.signals import COHORT_MEMBERSHIP_UPDATED
from openedx.core.lib.grade_utils import is_score_higher_or_equal
from student.models import user_by_anonymous_id
from student.signals import ENROLLMENT_TRACK_UPDATED
from track.event_transaction_utils import get_event_transaction_id, get_event_transaction_type
from util.date_utils import to_timestamp
from .signals import (
PROBLEM_RAW_SCORE_CHANGED,
PROBLEM_WEIGHTED_SCORE_CHANGED,
SCORE_PUBLISHED,
SUBSECTION_SCORE_CHANGED,
SUBSECTION_OVERRIDE_CHANGED,
)
from .. import events
from ..constants import ScoreDatabaseTableEnum
from ..course_grade_factory import CourseGradeFactory
from ..scores import weighted_score
from ..tasks import (
RECALCULATE_GRADE_DELAY_SECONDS,
recalculate_subsection_grade_v3,
recalculate_course_and_subsection_grades_for_user
recalculate_course_and_subsection_grades_for_user,
recalculate_subsection_grade_v3
)
from .signals import (
PROBLEM_RAW_SCORE_CHANGED,
PROBLEM_WEIGHTED_SCORE_CHANGED,
SCORE_PUBLISHED,
SUBSECTION_OVERRIDE_CHANGED,
SUBSECTION_SCORE_CHANGED
)
log = getLogger(__name__)
@@ -166,8 +169,8 @@ def score_published_handler(sender, block, user, raw_earned, raw_possible, only_
raw_possible=raw_possible,
weight=getattr(block, 'weight', None),
user_id=user.id,
course_id=unicode(block.location.course_key),
usage_id=unicode(block.location),
course_id=six.text_type(block.location.course_key),
usage_id=six.text_type(block.location),
only_if_higher=only_if_higher,
modified=score_modified_time,
score_db_table=ScoreDatabaseTableEnum.courseware_student_module,
@@ -224,8 +227,8 @@ def enqueue_subsection_update(sender, **kwargs): # pylint: disable=unused-argum
only_if_higher=kwargs.get('only_if_higher'),
expected_modified_time=to_timestamp(kwargs['modified']),
score_deleted=kwargs.get('score_deleted', False),
event_transaction_id=unicode(get_event_transaction_id()),
event_transaction_type=unicode(get_event_transaction_type()),
event_transaction_id=six.text_type(get_event_transaction_id()),
event_transaction_type=six.text_type(get_event_transaction_type()),
score_db_table=kwargs['score_db_table'],
force_update_subsections=kwargs.get('force_update_subsections', False),
),

View File

@@ -1,6 +1,8 @@
"""
Grades related signals.
"""
from __future__ import absolute_import
from django.dispatch import Signal
# Signal that indicates that a user's grade for a course has been updated.