Пример #1
0
    def test_get_subsection_grade_percentage_with_override(self):
        user = self.request.user
        subsection_key = self.sequence.location

        with mock_get_score(3, 3):
            # this update() call creates a persistent grade
            self.subsection_grade_factory.update(self.sequence)

            # there should only be one persistent grade
            persistent_grade = PersistentSubsectionGrade.objects.first()

            PersistentSubsectionGradeOverride.update_or_create_override(
                UserFactory(),  # it doesn't matter to us who created the override
                persistent_grade,
                earned_graded_override=0,
                earned_all_override=0,
                possible_graded_override=3,
                feature=PersistentSubsectionGradeOverrideHistory.GRADEBOOK,
            )

            # it's important that we stay in the mock_get_score() context here,
            # since get_subsection_grade_percentage() creates its own SubsectionGradeFactory,
            # which will in turn make calls to get_score().
            grade_percentage = gating_api.get_subsection_grade_percentage(subsection_key, user)
            assert 0 == grade_percentage
Пример #2
0
    def test_get_subsection_grade_percentage_with_override(self):
        user = self.request.user
        subsection_key = self.sequence.location

        with mock_get_score(3, 3):
            # this update() call creates a persistent grade
            self.subsection_grade_factory.update(self.sequence)

            # there should only be one persistent grade
            persistent_grade = PersistentSubsectionGrade.objects.first()

            PersistentSubsectionGradeOverride.update_or_create_override(
                UserFactory(
                ),  # it doesn't matter to us who created the override
                persistent_grade,
                earned_graded_override=0,
                earned_all_override=0,
                possible_graded_override=3,
                feature=GradeOverrideFeatureEnum.gradebook,
            )

            # it's important that we stay in the mock_get_score() context here,
            # since get_subsection_grade_percentage() creates its own SubsectionGradeFactory,
            # which will in turn make calls to get_score().
            grade_percentage = gating_api.get_subsection_grade_percentage(
                subsection_key, user)
            assert 0 == grade_percentage
Пример #3
0
    def test_get_subsection_grade_percentage(self):
        user = self.request.user
        subsection_key = self.sequence.location

        with mock_get_score(3, 3):
            # this update() call creates a persistent grade
            self.subsection_grade_factory.update(self.sequence)

            # it's important that we stay in the mock_get_score() context here,
            # since get_subsection_grade_percentage() creates its own SubsectionGradeFactory,
            # which will in turn make calls to get_score().
            grade_percentage = gating_api.get_subsection_grade_percentage(subsection_key, user)
            assert 100.0 == grade_percentage