signals.py 1.19 KB
Newer Older
1 2 3 4
"""
Signal handlers for the gating djangoapp
"""
from django.dispatch import receiver
5 6

from gating import api as gating_api
7
from lms.djangoapps.grades.signals.signals import SUBSECTION_SCORE_CHANGED
8
from openedx.core.djangoapps.signals.signals import COURSE_GRADE_CHANGED
9 10


11 12
@receiver(SUBSECTION_SCORE_CHANGED)
def evaluate_subsection_gated_milestones(**kwargs):
13
    """
14 15 16
    Receives the SUBSECTION_SCORE_CHANGED signal and triggers the
    evaluation of any milestone relationships which are attached
    to the subsection.
17 18

    Arguments:
19
        kwargs (dict): Contains user, course, course_structure, subsection_grade
20 21 22
    Returns:
        None
    """
23 24
    subsection_grade = kwargs['subsection_grade']
    gating_api.evaluate_prerequisite(kwargs['course'], subsection_grade, kwargs.get('user'))
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39


@receiver(COURSE_GRADE_CHANGED)
def evaluate_course_gated_milestones(**kwargs):
    """
    Receives the COURSE_GRADE_CHANGED signal and triggers the
    evaluation of any milestone relationships which are attached
    to the course grade.

    Arguments:
        kwargs (dict): Contains user, course_grade
    Returns:
        None
    """
    gating_api.evaluate_entrance_exam(kwargs['course_grade'], kwargs.get('user'))