PLAT-1885 Stop using deprecated BlockUsageLocator properties
This commit is contained in:
@@ -170,7 +170,7 @@ def get_d3_problem_grade_distrib(course_id):
|
||||
for child in unit.get_children():
|
||||
|
||||
# Student data is at the problem level
|
||||
if child.location.category == 'problem':
|
||||
if child.location.block_type == 'problem':
|
||||
c_problem += 1
|
||||
stack_data = []
|
||||
|
||||
@@ -327,7 +327,7 @@ def get_d3_section_grade_distrib(course_id, section):
|
||||
c_unit += 1
|
||||
c_problem = 0
|
||||
for child in unit.get_children():
|
||||
if child.location.category == 'problem':
|
||||
if child.location.block_type == 'problem':
|
||||
c_problem += 1
|
||||
problem_set.append(child.location)
|
||||
problem_info[child.location] = {
|
||||
@@ -414,7 +414,7 @@ def get_array_section_has_problem(course_id):
|
||||
for subsection in section.get_children():
|
||||
for unit in subsection.get_children():
|
||||
for child in unit.get_children():
|
||||
if child.location.category == 'problem':
|
||||
if child.location.block_type == 'problem':
|
||||
b_section_has_problem[i] = True
|
||||
break # out of child loop
|
||||
if b_section_has_problem[i]:
|
||||
|
||||
@@ -536,7 +536,7 @@ def get_problems_in_section(section):
|
||||
for subsection in section_descriptor.get_children():
|
||||
for vertical in subsection.get_children():
|
||||
for component in vertical.get_children():
|
||||
if component.location.category == 'problem' and getattr(component, 'has_score', False):
|
||||
if component.location.block_type == 'problem' and getattr(component, 'has_score', False):
|
||||
problem_descriptors[unicode(component.location)] = component
|
||||
|
||||
return problem_descriptors
|
||||
|
||||
@@ -93,7 +93,7 @@ def dump_module(module, destination=None, inherited=False, defaults=False):
|
||||
filtered_metadata = {k: v for k, v in items.iteritems() if k not in FILTER_LIST}
|
||||
|
||||
destination[unicode(module.location)] = {
|
||||
'category': module.location.category,
|
||||
'category': module.location.block_type,
|
||||
'children': [unicode(child) for child in getattr(module, 'children', [])],
|
||||
'metadata': filtered_metadata,
|
||||
}
|
||||
|
||||
@@ -233,8 +233,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
expected_url = reverse('courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.entrance_exam.location.name,
|
||||
'section': self.exam_1.location.name
|
||||
'chapter': self.entrance_exam.location.block_id,
|
||||
'section': self.exam_1.location.block_id
|
||||
})
|
||||
resp = self.client.get(url)
|
||||
self.assertRedirects(resp, expected_url, status_code=302, target_status_code=200)
|
||||
@@ -248,8 +248,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
expected_url = reverse('courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.chapter.location.name,
|
||||
'section': self.welcome.location.name
|
||||
'chapter': self.chapter.location.block_id,
|
||||
'section': self.welcome.location.block_id
|
||||
})
|
||||
resp = self.client.get(url)
|
||||
self.assertRedirects(resp, expected_url, status_code=302, target_status_code=200)
|
||||
@@ -265,8 +265,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
expected_url = reverse('courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.entrance_exam.location.name,
|
||||
'section': self.exam_1.location.name
|
||||
'chapter': self.entrance_exam.location.block_id,
|
||||
'section': self.exam_1.location.block_id
|
||||
})
|
||||
resp = self.client.get(url)
|
||||
self.assertRedirects(resp, expected_url, status_code=302, target_status_code=200)
|
||||
@@ -296,8 +296,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.entrance_exam.location.name,
|
||||
'section': self.exam_1.location.name,
|
||||
'chapter': self.entrance_exam.location.block_id,
|
||||
'section': self.exam_1.location.block_id,
|
||||
}
|
||||
)
|
||||
resp = self.client.get(url)
|
||||
@@ -320,8 +320,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.entrance_exam.location.name,
|
||||
'section': self.exam_1.location.name
|
||||
'chapter': self.entrance_exam.location.block_id,
|
||||
'section': self.exam_1.location.block_id
|
||||
}
|
||||
)
|
||||
resp = self.client.get(url)
|
||||
@@ -346,8 +346,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.chapter.location.name,
|
||||
'section': self.chapter_subsection.location.name
|
||||
'chapter': self.chapter.location.block_id,
|
||||
'section': self.chapter_subsection.location.block_id
|
||||
}
|
||||
)
|
||||
resp = self.client.get(url)
|
||||
@@ -366,8 +366,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.entrance_exam.location.name,
|
||||
'section': self.exam_1.location.name
|
||||
'chapter': self.entrance_exam.location.block_id,
|
||||
'section': self.exam_1.location.block_id
|
||||
}
|
||||
)
|
||||
|
||||
@@ -450,8 +450,8 @@ class EntranceExamTestCases(LoginEnrollmentTestCase, ModuleStoreTestCase, Milest
|
||||
expected_url = reverse('courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.entrance_exam.location.name,
|
||||
'section': self.exam_1.location.name
|
||||
'chapter': self.entrance_exam.location.block_id,
|
||||
'section': self.exam_1.location.block_id
|
||||
})
|
||||
self.assertRedirects(response, expected_url, status_code=302, target_status_code=200)
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ class MasqueradeTestCase(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': self.chapter.location.name,
|
||||
'section': self.sequential.location.name,
|
||||
'chapter': self.chapter.location.block_id,
|
||||
'section': self.sequential.location.block_id,
|
||||
}
|
||||
)
|
||||
return self.client.get(url)
|
||||
|
||||
@@ -225,8 +225,8 @@ class IndexQueryTestCase(ModuleStoreTestCase):
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(course.id),
|
||||
'chapter': unicode(chapter.location.name),
|
||||
'section': unicode(section.location.name),
|
||||
'chapter': unicode(chapter.location.block_id),
|
||||
'section': unicode(section.location.block_id),
|
||||
}
|
||||
)
|
||||
response = self.client.get(url)
|
||||
@@ -345,8 +345,8 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course_key),
|
||||
'chapter': unicode(self.chapter.location.name) if chapter_name is None else chapter_name,
|
||||
'section': unicode(self.section2.location.name) if section_name is None else section_name,
|
||||
'chapter': unicode(self.chapter.location.block_id) if chapter_name is None else chapter_name,
|
||||
'section': unicode(self.section2.location.block_id) if section_name is None else section_name,
|
||||
}
|
||||
)
|
||||
response = self.client.get(url)
|
||||
@@ -365,7 +365,7 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
|
||||
url = reverse(
|
||||
'courseware_chapter',
|
||||
kwargs={'course_id': unicode(self.course.id), 'chapter': unicode(self.chapter.location.name)},
|
||||
kwargs={'course_id': unicode(self.course.id), 'chapter': unicode(self.chapter.location.block_id)},
|
||||
)
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -388,8 +388,8 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course_key),
|
||||
'chapter': unicode(self.chapter.location.name),
|
||||
'section': unicode(self.section.location.name),
|
||||
'chapter': unicode(self.chapter.location.block_id),
|
||||
'section': unicode(self.section.location.block_id),
|
||||
}
|
||||
)
|
||||
# create the url for enroll_staff view
|
||||
@@ -546,8 +546,8 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
'/courses',
|
||||
unicode(self.course.id),
|
||||
'courseware',
|
||||
self.chapter.location.name,
|
||||
self.section.location.name,
|
||||
self.chapter.location.block_id,
|
||||
self.section.location.block_id,
|
||||
'f'
|
||||
])
|
||||
self.assertTrue(self.client.login(username=self.user.username, password=TEST_PASSWORD))
|
||||
@@ -559,8 +559,8 @@ class ViewsTestCase(ModuleStoreTestCase):
|
||||
'/courses',
|
||||
unicode(self.course.id),
|
||||
'courseware',
|
||||
self.chapter.location.name,
|
||||
self.section.location.name,
|
||||
self.chapter.location.block_id,
|
||||
self.section.location.block_id,
|
||||
'1'
|
||||
]
|
||||
self.assertTrue(self.client.login(username=self.user.username, password=TEST_PASSWORD))
|
||||
@@ -2516,8 +2516,8 @@ class TestIndexViewCrawlerStudentStateWrites(SharedModuleStoreTestCase):
|
||||
'courseware_section',
|
||||
kwargs={
|
||||
'course_id': unicode(self.course.id),
|
||||
'chapter': unicode(self.chapter.location.name),
|
||||
'section': unicode(self.section.location.name),
|
||||
'chapter': unicode(self.chapter.location.block_id),
|
||||
'section': unicode(self.section.location.block_id),
|
||||
}
|
||||
)
|
||||
response = self.client.get(url, HTTP_USER_AGENT=user_agent)
|
||||
|
||||
@@ -260,7 +260,7 @@ class TestWordCloud(BaseTestXmodule):
|
||||
'ajax_url': self.item_descriptor.xmodule_runtime.ajax_url,
|
||||
'display_name': self.item_descriptor.display_name,
|
||||
'instructions': self.item_descriptor.instructions,
|
||||
'element_class': self.item_descriptor.location.category,
|
||||
'element_class': self.item_descriptor.location.block_type,
|
||||
'element_id': self.item_descriptor.location.html_id(),
|
||||
'num_inputs': 5, # default value
|
||||
'submitted': False, # default value,
|
||||
|
||||
@@ -279,7 +279,7 @@ class CoursewareIndex(View):
|
||||
"""
|
||||
child = None
|
||||
if url_name:
|
||||
child = parent.get_child_by(lambda m: m.location.name == url_name)
|
||||
child = parent.get_child_by(lambda m: m.location.block_id == url_name)
|
||||
if not child:
|
||||
# User may be trying to access a child that isn't live yet
|
||||
if not self._is_masquerading_as_student():
|
||||
@@ -523,7 +523,7 @@ def save_child_position(seq_module, child_name):
|
||||
child_name: url_name of the child
|
||||
"""
|
||||
for position, child in enumerate(seq_module.get_display_items(), start=1):
|
||||
if child.location.name == child_name:
|
||||
if child.location.block_id == child_name:
|
||||
# Only save if position changed
|
||||
if position != seq_module.position:
|
||||
seq_module.position = position
|
||||
@@ -553,6 +553,6 @@ def save_positions_recursively_up(user, request, field_data_cache, xmodule, cour
|
||||
)
|
||||
|
||||
if parent and hasattr(parent, 'position'):
|
||||
save_child_position(parent, current_module.location.name)
|
||||
save_child_position(parent, current_module.location.block_id)
|
||||
|
||||
current_module = parent
|
||||
|
||||
@@ -256,7 +256,7 @@ class InstructorTaskModuleTestCase(InstructorTaskCourseTestCase):
|
||||
"""Get StudentModule object for test course, given the `username` and the problem's `descriptor`."""
|
||||
return StudentModule.objects.get(course_id=self.course.id,
|
||||
student=User.objects.get(username=username),
|
||||
module_type=descriptor.location.category,
|
||||
module_type=descriptor.location.block_type,
|
||||
module_state_key=descriptor.location,
|
||||
)
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ def find_urls(course_id, block, child_to_parent, request):
|
||||
if block_count > 3:
|
||||
position = 1
|
||||
for block in section.children:
|
||||
if block.name == block_list[3].url_name:
|
||||
if block.block_id == block_list[3].url_name:
|
||||
break
|
||||
position += 1
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ ${block_content}
|
||||
<a class="instructor-info-action" href="#${element_id}_debug" id="${element_id}_trig">${_("Staff Debug Info")}</a>
|
||||
|
||||
% if settings.FEATURES.get('ENABLE_STUDENT_HISTORY_VIEW') and \
|
||||
location.category == 'problem':
|
||||
location.block_type == 'problem':
|
||||
<a class="instructor-info-action" href="#${element_id}_history" id="${element_id}_history_trig">${_("Submission history")}</a>
|
||||
% endif
|
||||
</div>
|
||||
@@ -64,17 +64,17 @@ ${block_content}
|
||||
<div class="staff_actions">
|
||||
<h3>${_('Actions')}</h3>
|
||||
<div>
|
||||
<label for="sd_fu_${location.name | h}">${_('Username')}:</label>
|
||||
<input type="text" tabindex="0" id="sd_fu_${location.name | h}" placeholder="${user.username}"/>
|
||||
<label for="sd_fu_${location.block_id | h}">${_('Username')}:</label>
|
||||
<input type="text" tabindex="0" id="sd_fu_${location.block_id | h}" placeholder="${user.username}"/>
|
||||
</div>
|
||||
% if can_override_problem_score:
|
||||
<div>
|
||||
<label for="sd_fs_${location.name | h}">${_('Score (for override only)')}:</label>
|
||||
<input type="text" tabindex="0" id="sd_fs_${location.name | h}" placeholder="0"/>
|
||||
<label for="sd_fs_${location.name | h}"> / ${max_problem_score}</label>
|
||||
<label for="sd_fs_${location.block_id | h}">${_('Score (for override only)')}:</label>
|
||||
<input type="text" tabindex="0" id="sd_fs_${location.block_id | h}" placeholder="0"/>
|
||||
<label for="sd_fs_${location.block_id | h}"> / ${max_problem_score}</label>
|
||||
</div>
|
||||
% endif
|
||||
<div data-location="${location | h}" data-location-name="${location.name | h}">
|
||||
<div data-location="${location | h}" data-location-name="${location.block_id | h}">
|
||||
[
|
||||
% if can_reset_attempts:
|
||||
<button type="button" class="btn-link staff-debug-reset">${_('Reset Learner\'s Attempts to Zero')}</button>
|
||||
@@ -95,7 +95,7 @@ ${block_content}
|
||||
% endif
|
||||
]
|
||||
</div>
|
||||
<div id="result_${location.name | h}"></div>
|
||||
<div id="result_${location.block_id | h}"></div>
|
||||
</div>
|
||||
|
||||
<div class="staff_info" style="display:block">
|
||||
|
||||
Reference in New Issue
Block a user