refactor: rename descriptor -> block within lms/djangoapps/lti_provider
Co-authored-by: Agrendalath <piotr@surowiec.it>
This commit is contained in:
committed by
Agrendalath
parent
5cc6acae18
commit
4276e7daf3
@@ -97,7 +97,7 @@ def generate_replace_result_xml(result_sourcedid, score):
|
||||
return etree.tostring(xml, xml_declaration=True, encoding='UTF-8')
|
||||
|
||||
|
||||
def get_assignments_for_problem(problem_descriptor, user_id, course_key):
|
||||
def get_assignments_for_problem(problem_block, user_id, course_key):
|
||||
"""
|
||||
Trace the parent hierarchy from a given problem to find all blocks that
|
||||
correspond to graded assignment launches for this user. A problem may
|
||||
@@ -107,13 +107,13 @@ def get_assignments_for_problem(problem_descriptor, user_id, course_key):
|
||||
problem and as a problem in a vertical, for example).
|
||||
|
||||
Returns a list of GradedAssignment objects that are associated with the
|
||||
given descriptor for the current user.
|
||||
given block for the current user.
|
||||
"""
|
||||
locations = []
|
||||
current_descriptor = problem_descriptor
|
||||
while current_descriptor:
|
||||
locations.append(current_descriptor.location)
|
||||
current_descriptor = current_descriptor.get_parent()
|
||||
current_block = problem_block
|
||||
while current_block:
|
||||
locations.append(current_block.location)
|
||||
current_block = current_block.get_parent()
|
||||
assignments = GradedAssignment.objects.filter(
|
||||
user=user_id, course_key=course_key, usage_key__in=locations
|
||||
)
|
||||
|
||||
@@ -22,13 +22,13 @@ def increment_assignment_versions(course_key, usage_key, user_id):
|
||||
Update the version numbers for all assignments that are affected by a score
|
||||
change event. Returns a list of all affected assignments.
|
||||
"""
|
||||
problem_descriptor = modulestore().get_item(usage_key)
|
||||
problem_block = modulestore().get_item(usage_key)
|
||||
# Get all assignments involving the current problem for which the campus LMS
|
||||
# is expecting a grade. There may be many possible graded assignments, if
|
||||
# a problem has been added several times to a course at different
|
||||
# granularities (such as the unit or the vertical).
|
||||
assignments = outcomes.get_assignments_for_problem(
|
||||
problem_descriptor, user_id, course_key
|
||||
problem_block, user_id, course_key
|
||||
)
|
||||
for assignment in assignments:
|
||||
assignment.version_number += 1
|
||||
|
||||
@@ -97,8 +97,8 @@ class SendCompositeOutcomeTest(BaseOutcomeTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.descriptor = MagicMock()
|
||||
self.descriptor.location = BlockUsageLocator(
|
||||
self.block = MagicMock()
|
||||
self.block.location = BlockUsageLocator(
|
||||
course_key=self.course_key,
|
||||
block_type='problem',
|
||||
block_id='problem',
|
||||
@@ -108,7 +108,7 @@ class SendCompositeOutcomeTest(BaseOutcomeTest):
|
||||
'lms.djangoapps.lti_provider.tasks.CourseGradeFactory.read', self.course_grade
|
||||
)
|
||||
self.module_store = MagicMock()
|
||||
self.module_store.get_item = MagicMock(return_value=self.descriptor)
|
||||
self.module_store.get_item = MagicMock(return_value=self.block)
|
||||
self.check_result_mock = self.setup_patch(
|
||||
'lms.djangoapps.lti_provider.tasks.modulestore',
|
||||
self.module_store
|
||||
|
||||
Reference in New Issue
Block a user