Commit ac3373ca by Adam Palay

fix issue where orphaned openassessment blocks cause 500 errors on the…

fix issue where orphaned openassessment blocks cause 500 errors on the instructor dashboard (TNL-6797)
parent 79a9984b
......@@ -336,14 +336,27 @@ class TestInstructorDashboard(ModuleStoreTestCase, LoginEnrollmentTestCase, XssT
response = self.client.get(self.url)
self.assertNotIn(ora_section, response.content)
course = ItemFactory.create(
ItemFactory.create(parent_location=self.course.location, category="openassessment")
response = self.client.get(self.url)
self.assertIn(ora_section, response.content)
def test_open_response_assessment_page_orphan(self):
"""
Tests that the open responses tab loads if the course contains an
orphaned openassessment block
"""
# create non-orphaned openassessment block
ItemFactory.create(
parent_location=self.course.location,
category="course",
display_name="Test course",
category="openassessment",
)
# create orphan
self.store.create_item(
self.user.id, self.course.id, 'openassessment', "orphan"
)
ItemFactory.create(parent_location=course.location, category="openassessment")
response = self.client.get(self.url)
self.assertIn(ora_section, response.content)
# assert we don't get a 500 error
self.assertEqual(200, response.status_code)
@ddt.ddt
......
......@@ -192,7 +192,13 @@ def instructor_dashboard_2(request, course_id):
if certs_enabled and access['admin']:
sections.append(_section_certificates(course))
openassessment_blocks = modulestore().get_items(course_key, qualifiers={'category': 'openassessment'})
openassessment_blocks = modulestore().get_items(
course_key, qualifiers={'category': 'openassessment'}
)
# filter out orphaned openassessment blocks
openassessment_blocks = [
block for block in openassessment_blocks if block.parent is not None
]
if len(openassessment_blocks) > 0:
sections.append(_section_open_response_assessment(request, course, openassessment_blocks, access))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment