コード例 #1
0
def _fire_score_changed_for_block(course_id, student, block, module_state_key):
    """
    Fires a PROBLEM_SCORE_CHANGED event for the given module. The earned points are
    always zero. We must retrieve the possible points from the XModule, as
    noted below.
    """
    if block and block.has_score:
        max_score = block.max_score()
        if max_score is None:
            return
        else:
            points_earned, points_possible = weighted_score(
                0, max_score, getattr(block, 'weight', None))
    else:
        points_earned, points_possible = 0, 0

    PROBLEM_SCORE_CHANGED.send(
        sender=None,
        points_possible=points_possible,
        points_earned=points_earned,
        user_id=student.id,
        course_id=unicode(course_id),
        usage_id=unicode(module_state_key),
        score_deleted=True,
    )
コード例 #2
0
ファイル: test_tasks.py プロジェクト: CUCWD/edx-platform
 def test_problem_score_changed_queues_task(self):
     """
     Ensures that the PROBLEM_SCORE_CHANGED signal enqueues the correct task.
     """
     self.set_up_course()
     send_args = self.problem_score_changed_kwargs
     with self.mock_get_score() and patch(
         "lms.djangoapps.grades.tasks.recalculate_subsection_grade.apply_async", return_value=None
     ) as mock_task_apply:
         PROBLEM_SCORE_CHANGED.send(sender=None, **send_args)
         mock_task_apply.assert_called_once_with(kwargs=self.recalculate_subsection_grade_kwargs)
コード例 #3
0
ファイル: test_tasks.py プロジェクト: pjki100/edx-platform
 def test_problem_score_changed_queues_task(self):
     """
     Ensures that the PROBLEM_SCORE_CHANGED signal enqueues the correct task.
     """
     self.set_up_course()
     send_args = self.problem_score_changed_kwargs
     with self.mock_get_score() and patch(
             'lms.djangoapps.grades.tasks.recalculate_subsection_grade.apply_async',
             return_value=None) as mock_task_apply:
         PROBLEM_SCORE_CHANGED.send(sender=None, **send_args)
         mock_task_apply.assert_called_once_with(
             kwargs=self.recalculate_subsection_grade_kwargs)
コード例 #4
0
ファイル: enrollment.py プロジェクト: yewtzeee/edx-platform
def _fire_score_changed_for_block(course_id, student, block, module_state_key):
    """
    Fires a PROBLEM_SCORE_CHANGED event for the given module. The earned points are
    always zero. We must retrieve the possible points from the XModule, as
    noted below.
    """
    if block and block.has_score:
        cache = FieldDataCache.cache_for_descriptor_descendents(
            course_id=course_id,
            user=student,
            descriptor=block,
            depth=0
        )
        # For implementation reasons, we need to pull the max_score from the XModule,
        # even though the data is not user-specific.  Here we bind the data to the
        # current user.
        request = crum.get_current_request()
        module = get_module_for_descriptor(
            user=student,
            request=request,
            descriptor=block,
            field_data_cache=cache,
            course_key=course_id
        )
        max_score = module.max_score()
        if max_score is None:
            return
        else:
            points_earned, points_possible = weighted_score(0, max_score, getattr(module, 'weight', None))
    else:
        points_earned, points_possible = 0, 0
    PROBLEM_SCORE_CHANGED.send(
        sender=None,
        points_possible=points_possible,
        points_earned=points_earned,
        user_id=student.id,
        course_id=unicode(course_id),
        usage_id=unicode(module_state_key)
    )
コード例 #5
0
ファイル: enrollment.py プロジェクト: CUCWD/edx-platform
def _fire_score_changed_for_block(course_id, student, block, module_state_key):
    """
    Fires a PROBLEM_SCORE_CHANGED event for the given module. The earned points are
    always zero. We must retrieve the possible points from the XModule, as
    noted below.
    """
    if block and block.has_score:
        max_score = block.max_score()
        if max_score is None:
            return
        else:
            points_earned, points_possible = weighted_score(0, max_score, getattr(block, 'weight', None))
    else:
        points_earned, points_possible = 0, 0

    PROBLEM_SCORE_CHANGED.send(
        sender=None,
        points_possible=points_possible,
        points_earned=points_earned,
        user_id=student.id,
        course_id=unicode(course_id),
        usage_id=unicode(module_state_key),
        score_deleted=True,
    )