Revert "Unrevert "Fix Gating to use grades API, instead of its own calculations""

This reverts commit 7aacae9a4f.
This commit is contained in:
Eric Fischer
2016-11-01 14:31:52 -04:00
parent caeac6921a
commit a54c4ea4f9
10 changed files with 475 additions and 242 deletions

View File

@@ -1,7 +1,7 @@
"""
Tests for ProctoredExamTransformer.
"""
from mock import patch
from mock import patch, Mock
from nose.plugins.attrib import attr
import ddt
@@ -133,16 +133,18 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
(
'H',
'A',
'B',
('course', 'A', 'B', 'C',)
),
(
'H',
'ProctoredExam',
'D',
('course', 'A', 'B', 'C'),
),
)
@ddt.unpack
def test_gated(self, gated_block_ref, gating_block_ref, expected_blocks_before_completion):
def test_gated(self, gated_block_ref, gating_block_ref, gating_block_child, expected_blocks_before_completion):
"""
First, checks that a student cannot see the gated block when it is gated by the gating block and no
attempt has been made to complete the gating block.
@@ -162,14 +164,17 @@ class MilestonesTransformerTestCase(CourseStructureTestCase, MilestonesTestCaseM
# clear the request cache to simulate a new request
self.clear_caches()
# this call triggers reevaluation of prerequisites fulfilled by the gating block
lms_gating_api.evaluate_prerequisite(
self.course,
self.user,
self.blocks[gating_block_ref].location,
100.0,
)
with self.assertNumQueries(3):
# mock the api that the lms gating api calls to get the score for each block to always return 1 (ie 100%)
with patch('gating.api.get_module_score', Mock(return_value=1)):
# this call triggers reevaluation of prerequisites fulfilled by the parent of the
# block passed in, so we pass in a child of the gating block
lms_gating_api.evaluate_prerequisite(
self.course,
self.blocks[gating_block_child],
self.user.id,
)
with self.assertNumQueries(2):
self.get_blocks_and_check_against_expected(self.user, self.ALL_BLOCKS_EXCEPT_SPECIAL)
def test_staff_access(self):