Merge pull request #25709 from edx/asheehan-edx/ENT-3648-assessment-level-signals

Adding signals and receivers for assessment level reporting
This commit is contained in:
Alexander J Sheehan
2020-12-10 09:29:54 -08:00
committed by GitHub
8 changed files with 123 additions and 9 deletions

View File

@@ -6,9 +6,11 @@ SubsectionGrade Factory Class
from collections import OrderedDict
from logging import getLogger
from django.conf import settings
from lazy import lazy
from submissions import api as submissions_api
from openedx.core.djangoapps.signals.signals import COURSE_ASSESSMENT_GRADE_CHANGED
from lms.djangoapps.courseware.model_data import ScoresClient
from lms.djangoapps.grades.config import assume_zero_if_absent, should_persist_grades
from lms.djangoapps.grades.models import PersistentSubsectionGrade
@@ -104,6 +106,14 @@ class SubsectionGradeFactory(object):
)
self._update_saved_subsection_grade(subsection.location, grade_model)
if settings.FEATURES.get('ENABLE_COURSE_ASSESSMENT_GRADE_CHANGE_SIGNAL'):
COURSE_ASSESSMENT_GRADE_CHANGED.send_robust(
sender=self,
user=self.student,
subsection_id=calculated_grade.location,
subsection_grade=calculated_grade.graded_total.earned
)
return calculated_grade
@lazy

View File

@@ -49,14 +49,19 @@ class TestSubsectionGradeFactory(ProblemSubmissionTestMixin, GradeTestBase):
self.assertIsInstance(grade, ZeroSubsectionGrade)
self.assert_grade(grade, 0.0, 1.0)
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_ASSESSMENT_GRADE_CHANGE_SIGNAL': True})
def test_update(self):
"""
Assuming the underlying score reporting methods work,
test that the score is calculated properly.
"""
with mock_get_score(1, 2):
grade = self.subsection_grade_factory.update(self.sequence)
with patch(
'openedx.core.djangoapps.signals.signals.COURSE_ASSESSMENT_GRADE_CHANGED.send_robust'
) as mock_update_grades_signal:
grade = self.subsection_grade_factory.update(self.sequence)
self.assert_grade(grade, 1, 2)
assert mock_update_grades_signal.called
def test_write_only_if_engaged(self):
"""