Merge pull request #18159 from edx/aj/LEARNER-5123_2
Correctly passing course key in the JSON object to async
This commit is contained in:
@@ -4,17 +4,18 @@ Grades related signals.
|
||||
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 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 submissions.models import score_reset, score_set
|
||||
from track.event_transaction_utils import get_event_transaction_id, get_event_transaction_type
|
||||
from util.date_utils import to_timestamp
|
||||
from xblock.scorable import ScorableXBlockMixin, Score
|
||||
|
||||
from .signals import (
|
||||
PROBLEM_RAW_SCORE_CHANGED,
|
||||
PROBLEM_WEIGHTED_SCORE_CHANGED,
|
||||
@@ -22,9 +23,9 @@ from .signals import (
|
||||
SUBSECTION_SCORE_CHANGED,
|
||||
SUBSECTION_OVERRIDE_CHANGED,
|
||||
)
|
||||
from .. import events
|
||||
from ..constants import ScoreDatabaseTableEnum
|
||||
from ..course_grade_factory import CourseGradeFactory
|
||||
from .. import events
|
||||
from ..scores import weighted_score
|
||||
from ..tasks import (
|
||||
RECALCULATE_GRADE_DELAY_SECONDS,
|
||||
@@ -247,7 +248,7 @@ def recalculate_course_and_subsection_grades(sender, user, course_key, **kwargs)
|
||||
"""
|
||||
recalculate_course_and_subsection_grades_for_user.apply_async(
|
||||
kwargs=dict(
|
||||
user=user,
|
||||
course_key=course_key
|
||||
user_id=user.id,
|
||||
course_key=six.text_type(course_key)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -127,13 +127,15 @@ def recalculate_course_and_subsection_grades_for_user(self, **kwargs): # pylint
|
||||
Recalculates the course grade and all subsection grades
|
||||
for the given ``user`` and ``course_key`` keyword arguments.
|
||||
"""
|
||||
user = kwargs.get('user')
|
||||
course_key = kwargs.get('course_key')
|
||||
user_id = kwargs.get('user_id')
|
||||
course_key_str = kwargs.get('course_key')
|
||||
|
||||
if not user or course_key:
|
||||
if not user_id or course_key_str:
|
||||
message = 'recalculate_course_and_subsection_grades_for_user missing "user" or "course_key" kwargs from {}'
|
||||
log.error(message.format(kwargs))
|
||||
|
||||
user = User.objects.get(id=user_id)
|
||||
course_key = CourseKey.from_string(course_key_str)
|
||||
previous_course_grade = CourseGradeFactory().read(user, course_key=course_key)
|
||||
if previous_course_grade and previous_course_grade.attempted:
|
||||
CourseGradeFactory().update(
|
||||
|
||||
Reference in New Issue
Block a user