fix attribute access

This commit is contained in:
muhammad-ammar
2016-10-07 12:14:32 +05:00
parent 256223d07b
commit aed1ea8028
2 changed files with 10 additions and 4 deletions

View File

@@ -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

View File

@@ -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',