def test_is_gate_fulfilled(self, min_score, min_completion, learner_score, learner_completion, is_gate_fulfilled): """ Test if prereq section has any unfulfilled milestones """ student = UserFactory(is_staff=False) gating_api.add_prerequisite(self.course.id, self.seq1.location) gating_api.set_required_content(self.course.id, self.seq2.location, self.seq1.location, min_score, min_completion) milestone = milestones_api.add_milestone(self.generic_milestone) milestones_api.add_course_content_milestone(self.course.id, self.seq1.location, 'fulfills', milestone) self.assertFalse( gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id)) # complete the prerequisite to unlock the gated content # this call triggers reevaluation of prerequisites fulfilled by the gating block. with patch.object( gating_api, 'get_subsection_completion_percentage') as mock_grade: mock_grade.return_value = learner_completion lms_gating_api.evaluate_prerequisite( self.course, Mock(location=self.seq1.location, percent_graded=learner_score / 100.0), student, ) self.assertEqual( gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id), is_gate_fulfilled)
def test_is_gate_fulfilled(self, min_score, min_completion, learner_score, learner_completion, is_gate_fulfilled): """ Test if prereq section has any unfulfilled milestones """ student = UserFactory(is_staff=False) gating_api.add_prerequisite(self.course.id, self.seq1.location) gating_api.set_required_content( self.course.id, self.seq2.location, self.seq1.location, min_score, min_completion ) milestone = milestones_api.add_milestone(self.generic_milestone) milestones_api.add_course_content_milestone(self.course.id, self.seq1.location, 'fulfills', milestone) self.assertFalse(gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id)) # complete the prerequisite to unlock the gated content # this call triggers reevaluation of prerequisites fulfilled by the gating block. with patch.object(gating_api, 'get_subsection_completion_percentage') as mock_grade: mock_grade.return_value = learner_completion lms_gating_api.evaluate_prerequisite( self.course, Mock(location=self.seq1.location, percent_graded=learner_score / 100.0), student, ) self.assertEqual( gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id), is_gate_fulfilled )