diff --git a/common/lib/xmodule/xmodule/capa_base.py b/common/lib/xmodule/xmodule/capa_base.py index afbabe2858..17f39fdd00 100644 --- a/common/lib/xmodule/xmodule/capa_base.py +++ b/common/lib/xmodule/xmodule/capa_base.py @@ -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 diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index 2eec8e5760..c467d92286 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -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',