Commit aa092fa3 by Will Daly

Fix a bug that caused example-based assessments to stop being displayed in the authoring GUI.

parent 49d9213f
......@@ -293,22 +293,29 @@ class StudioMixin(object):
"""
order = copy.deepcopy(self.editor_assessments_order)
used_assessments = [asmnt['name'] for asmnt in self.valid_assessments]
default_editor_order = copy.deepcopy(DEFAULT_EDITOR_ASSESSMENTS_ORDER)
# Backwards compatibility:
# If the problem already contains example-based assessment
# then allow the editor to display example-based assessments.
if 'example-based-assessment' in used_assessments:
default_editor_order.insert(0, 'example-based-assessment')
# Backwards compatibility:
# If the editor assessments order doesn't match the problem order,
# fall back to the problem order.
# This handles the migration of problems created pre-authoring,
# which will have the default editor order.
used_assessments = [asmnt['name'] for asmnt in self.valid_assessments]
problem_order_indices = [
order.index(asmnt_name) for asmnt_name in used_assessments
if asmnt_name in order
]
if problem_order_indices != sorted(problem_order_indices):
unused_assessments = list(set(DEFAULT_EDITOR_ASSESSMENTS_ORDER) - set(used_assessments))
unused_assessments = list(set(default_editor_order) - set(used_assessments))
return sorted(unused_assessments) + used_assessments
# Forwards compatibility:
# Include any additional assessments that may have been added since the problem was created.
else:
return order + list(set(DEFAULT_EDITOR_ASSESSMENTS_ORDER) - set(order))
return order + list(set(default_editor_order) - set(order))
......@@ -117,7 +117,7 @@ class StudioViewTest(XBlockHandlerTestCase):
@scenario('data/example_based_only.xml')
def test_render_studio_with_ai(self, xblock):
frag = self.runtime.render(xblock, 'studio_view')
self.assertTrue(frag.body_html().find('openassessment-edit'))
self.assertTrue('ai_assessment_settings_editor' in frag.body_html())
@file_data('data/update_xblock.json')
@scenario('data/basic_scenario.xml')
......
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