Commit aed1ea80 by muhammad-ammar

fix attribute access

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