Commit aed1ea80 by muhammad-ammar

fix attribute access

parent 256223d0
......@@ -1354,17 +1354,16 @@ class CapaMixin(CapaFields):
if is_correct is None:
is_correct = ''
response_data = getattr(answer_input, 'response_data', {})
input_metadata[input_id] = {
'question': answer_input.response_data.get('label', ''),
'question': response_data.get('label', ''),
'answer': user_visible_answer,
'response_type': getattr(getattr(answer_response, 'xml', None), 'tag', ''),
'input_type': getattr(answer_input, 'tag', ''),
'correct': is_correct,
'variant': variant,
'group_label': response_data.get('group_label', ''),
}
# Add group_label in event data only if the responsetype contains multiple inputtypes
if answer_input.response_data.get('group_label'):
input_metadata[input_id]['group_label'] = answer_input.response_data.get('group_label')
return input_metadata
......
......@@ -2539,6 +2539,7 @@ class TestProblemCheckTracking(unittest.TestCase):
'response_type': 'optionresponse',
'input_type': 'optioninput',
'correct': True,
'group_label': '',
'variant': '',
},
factory.answer_key(3): {
......@@ -2547,6 +2548,7 @@ class TestProblemCheckTracking(unittest.TestCase):
'response_type': 'multiplechoiceresponse',
'input_type': 'choicegroup',
'correct': False,
'group_label': '',
'variant': '',
},
factory.answer_key(4): {
......@@ -2555,6 +2557,7 @@ class TestProblemCheckTracking(unittest.TestCase):
'response_type': 'choiceresponse',
'input_type': 'checkboxgroup',
'correct': False,
'group_label': '',
'variant': '',
},
})
......@@ -2595,6 +2598,7 @@ class TestProblemCheckTracking(unittest.TestCase):
'response_type': 'numericalresponse',
'input_type': 'textline',
'correct': True,
'group_label': '',
'variant': '',
}
})
......@@ -2726,6 +2730,7 @@ class TestProblemCheckTracking(unittest.TestCase):
'response_type': 'numericalresponse',
'input_type': 'textline',
'correct': True,
'group_label': '',
'variant': module.seed,
}
})
......@@ -2758,11 +2763,13 @@ class TestProblemCheckTracking(unittest.TestCase):
'response_type': 'coderesponse',
'input_type': 'filesubmission',
'correct': False,
'group_label': '',
'variant': '',
},
factory.answer_key(3): {
'answer': 'None',
'correct': True,
'group_label': '',
'question': '',
'response_type': 'customresponse',
'input_type': 'textline',
......
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