Skip to content

Commit

Permalink
Modify _get_sav_options function
Browse files Browse the repository at this point in the history
Modify _get_sav_options function to work with the new string binding
for select one elements
  • Loading branch information
DavisRayM committed Mar 27, 2020
1 parent 4a2c816 commit d52328f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions onadata/libs/utils/export_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,25 +1056,22 @@ def _is_numeric(xpath, element_type, data_dictionary):
# check if it is a choice part of multiple choice
# type is likely empty string, split multi select is binary
element = data_dictionary.get_element(xpath)
if element.type == SELECT_ONE:
# Determine if all select1 choices are numeric in nature.
# If the choices are numeric in nature have the field type
# in spss be numeric
choices = list(all_value_labels[var_name])
if len(choices) == 0:
return False
return is_all_numeric(choices)
if element and element.type == '' and value_select_multiples:
return is_all_numeric([element.name])
parent_xpath = '/'.join(xpath.split('/')[:-1])
parent = data_dictionary.get_element(parent_xpath)
return (parent and parent.type == MULTIPLE_SELECT_TYPE)
elif element_type != 'select1':
return False

if var_name not in all_value_labels:
return False

# Determine if all select1 choices are numeric in nature
# and as such have the field type in spss be numeric
choices = list(all_value_labels[var_name])
if len(choices) == 0:
else:
return False

return is_all_numeric(choices)

value_select_multiples = self.VALUE_SELECT_MULTIPLES
_var_types = {}
value_labels = {}
Expand Down

0 comments on commit d52328f

Please sign in to comment.