Skip to content

Commit

Permalink
Merge pull request #410 from yanokwa/issue-168
Browse files Browse the repository at this point in the history
Output a string bind type for selects
  • Loading branch information
yanokwa authored Jan 27, 2020
2 parents 41f2ff2 + 2193bbf commit 8fb7934
Show file tree
Hide file tree
Showing 25 changed files with 206 additions and 200 deletions.
2 changes: 1 addition & 1 deletion pyxform/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def validate(self):
choice.validate()

def xml_control(self):
assert self.bind["type"] in ["select", "select1", "odk:rank"]
assert self.bind["type"] in ["string", "odk:rank"]
survey = self.get_root()
control_dict = self.control.copy()
# Resolve field references in attributes
Expand Down
20 changes: 10 additions & 10 deletions pyxform/question_type_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def generate_new_dict():
},
"add select multiple prompt using": {
"control": {"tag": "select"},
"bind": {"type": "select"},
"bind": {"type": "string"},
},
"add note prompt": {
"control": {"tag": "input"},
Expand All @@ -59,7 +59,7 @@ def generate_new_dict():
"text": {"control": {"tag": "input"}, "bind": {"type": "string"}},
"select all that apply from": {
"control": {"tag": "select"},
"bind": {"type": "select"},
"bind": {"type": "string"},
},
"simserial": {
"bind": {
Expand Down Expand Up @@ -128,13 +128,13 @@ def generate_new_dict():
}
},
"q location": {"control": {"tag": "input"}, "bind": {"type": "geopoint"}},
"select one": {"control": {"tag": "select1"}, "bind": {"type": "select1"}},
"select one": {"control": {"tag": "select1"}, "bind": {"type": "string"}},
"select one external": {"control": {"tag": "input"}, "bind": {"type": "string"}},
"add image prompt": {
"control": {"tag": "upload", "mediatype": "image/*"},
"bind": {"type": "binary"},
},
"select all that apply": {"control": {"tag": "select"}, "bind": {"type": "select"}},
"select all that apply": {"control": {"tag": "select"}, "bind": {"type": "string"}},
"get end time": {
"bind": {
"jr:preload": "timestamp",
Expand All @@ -150,7 +150,7 @@ def generate_new_dict():
"geopoint": {"control": {"tag": "input"}, "bind": {"type": "geopoint"}},
"geoshape": {"control": {"tag": "input"}, "bind": {"type": "geoshape"}},
"geotrace": {"control": {"tag": "input"}, "bind": {"type": "geotrace"}},
"select multiple from": {"control": {"tag": "select"}, "bind": {"type": "select"}},
"select multiple from": {"control": {"tag": "select"}, "bind": {"type": "string"}},
"end time": {
"bind": {
"jr:preload": "timestamp",
Expand All @@ -173,8 +173,8 @@ def generate_new_dict():
}
},
"q barcode": {"control": {"tag": "input"}, "bind": {"type": "barcode"}},
"q select": {"control": {"tag": "select"}, "bind": {"type": "select"}},
"select one using": {"control": {"tag": "select1"}, "bind": {"type": "select1"}},
"q select": {"control": {"tag": "select"}, "bind": {"type": "string"}},
"select one using": {"control": {"tag": "select1"}, "bind": {"type": "string"}},
"rank": {"control": {"tag": "odk:rank"}, "bind": {"type": "odk:rank"}},
"image": {
"control": {"tag": "upload", "mediatype": "image/*"},
Expand Down Expand Up @@ -234,7 +234,7 @@ def generate_new_dict():
},
"int": {"control": {"tag": "input"}, "bind": {"type": "int"}},
"add barcode prompt": {"control": {"tag": "input"}, "bind": {"type": "barcode"}},
"select multiple using": {"control": {"tag": "select"}, "bind": {"type": "select"}},
"select multiple using": {"control": {"tag": "select"}, "bind": {"type": "string"}},
"q decimal": {"control": {"tag": "input"}, "bind": {"type": "decimal"}},
"end": {
"bind": {
Expand Down Expand Up @@ -272,7 +272,7 @@ def generate_new_dict():
"add integer prompt": {"control": {"tag": "input"}, "bind": {"type": "int"}},
"q dateTime": {"control": {"tag": "input"}, "bind": {"type": "dateTime"}},
"date": {"control": {"tag": "input"}, "bind": {"type": "date"}},
"q select1": {"control": {"tag": "select1"}, "bind": {"type": "select1"}},
"q select1": {"control": {"tag": "select1"}, "bind": {"type": "string"}},
"start time": {
"bind": {
"jr:preload": "timestamp",
Expand All @@ -293,7 +293,7 @@ def generate_new_dict():
},
"add select one prompt using": {
"control": {"tag": "select1"},
"bind": {"type": "select1"},
"bind": {"type": "string"},
},
"hidden": {"bind": {"type": "string"}},
"uri:subscriberid": {
Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests/example_xls/instance_xmlns_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</meta>
</instance_xmlns_test>
</instance>
<bind nodeset="/instance_xmlns_test/yes_or_no" type="select1"/>
<bind nodeset="/instance_xmlns_test/yes_or_no" type="string"/>
<bind jr:preload="uid" nodeset="/instance_xmlns_test/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
Expand Down
20 changes: 10 additions & 10 deletions pyxform/tests/example_xls/spec_test_expected_output.xml
Original file line number Diff line number Diff line change
Expand Up @@ -624,25 +624,25 @@
</meta>
</xlsform_spec_test>
</instance>
<bind nodeset="/xlsform_spec_test/skip_to_end" type="select1"/>
<bind nodeset="/xlsform_spec_test/skip_to_end" type="string"/>
<bind nodeset="/xlsform_spec_test/everything" relevant="not(selected(/xlsform_spec_test/skip_to_end, 'yes'))"/>
<bind nodeset="/xlsform_spec_test/everything/some_text" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/number_label" readonly="true()" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/text_image_audio_video_test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/display_image_test" readonly="true()" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/autocomplete_test" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/autocomplete_chars_test" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/autocomplete_test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/autocomplete_chars_test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/a_integer" type="int"/>
<bind constraint=". &lt;= /xlsform_spec_test/everything/a_integer" nodeset="/xlsform_spec_test/everything/a_decimal" type="decimal"/>
<bind nodeset="/xlsform_spec_test/everything/num_repeat_times" relevant="false()" type="int"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/group_test/required_text" required="true()" type="string"/>
<bind constraint="not(selected(., 'yes') and selected (., 'no'))" jr:constraintMsg="you can't select yes and no" nodeset="/xlsform_spec_test/everything/repeat_test/group_test/select_multiple_test" required="false()" type="select"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/labeled_select_group/label-test" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/labeled_select_group/list-nolabel-test" required="true()" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/name/reserved_name_for_field_list_labels_23" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/name/table_list_question" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/compact-test" type="select1"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/compact-2-test" type="select1"/>
<bind constraint="not(selected(., 'yes') and selected (., 'no'))" jr:constraintMsg="you can't select yes and no" nodeset="/xlsform_spec_test/everything/repeat_test/group_test/select_multiple_test" required="false()" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/labeled_select_group/label-test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/labeled_select_group/list-nolabel-test" required="true()" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/name/reserved_name_for_field_list_labels_23" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/name/table_list_question" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/compact-test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/repeat_test/compact-2-test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/acknowledge_test" type="string"/>
<bind nodeset="/xlsform_spec_test/everything/date_test" type="date"/>
<bind nodeset="/xlsform_spec_test/everything/time_test" type="time"/>
Expand Down
38 changes: 19 additions & 19 deletions pyxform/tests/example_xls/widgets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
<bind constraint=". &gt; 10.51 and . &lt; 18.39" jr:constraintMsg="number must be between 10.51 and 18.39" nodeset="/widgets/my_decimal" type="decimal"/>
<bind constraint=". &gt;= today()" jr:constraintMsg="only future dates allowed" nodeset="/widgets/my_date" type="date"/>
<bind nodeset="/widgets/my_time" type="time"/>
<bind constraint="not(selected(., 'c') and selected(., 'd'))" jr:constraintMsg="option c and d cannot be selected together" nodeset="/widgets/my_select" type="select"/>
<bind nodeset="/widgets/my_select1" type="select1"/>
<bind constraint="not(selected(., 'c') and selected(., 'd'))" jr:constraintMsg="option c and d cannot be selected together" nodeset="/widgets/my_select" type="string"/>
<bind nodeset="/widgets/my_select1" type="string"/>
<bind nodeset="/widgets/my_output" readonly="true()" type="string"/>
<bind nodeset="/widgets/my_geopoint" type="geopoint"/>
<bind nodeset="/widgets/my_barcode" type="barcode"/>
Expand All @@ -126,25 +126,25 @@
<bind nodeset="/widgets/numberAsString" type="string"/>
<bind nodeset="/widgets/locationMap" type="geopoint"/>
<bind nodeset="/widgets/dateTime" type="dateTime"/>
<bind nodeset="/widgets/spinner" type="select1"/>
<bind nodeset="/widgets/spinner_all" type="select"/>
<bind nodeset="/widgets/selectadvance" type="select1"/>
<bind nodeset="/widgets/grid_test" type="select1"/>
<bind nodeset="/widgets/grid_test_audio" type="select1"/>
<bind nodeset="/widgets/table_list_test/table_list_test_label" type="select1"/>
<bind nodeset="/widgets/table_list_test/table_list_1" type="select1"/>
<bind nodeset="/widgets/table_list_test/table_list_2" type="select1"/>
<bind nodeset="/widgets/spinner" type="string"/>
<bind nodeset="/widgets/spinner_all" type="string"/>
<bind nodeset="/widgets/selectadvance" type="string"/>
<bind nodeset="/widgets/grid_test" type="string"/>
<bind nodeset="/widgets/grid_test_audio" type="string"/>
<bind nodeset="/widgets/table_list_test/table_list_test_label" type="string"/>
<bind nodeset="/widgets/table_list_test/table_list_1" type="string"/>
<bind nodeset="/widgets/table_list_test/table_list_2" type="string"/>
<bind nodeset="/widgets/table_list_test2/generated_table_list_label_29" readonly="true()" type="string"/>
<bind nodeset="/widgets/table_list_test2/reserved_name_for_field_list_labels_30" type="select1"/>
<bind nodeset="/widgets/table_list_test2/table_list_3" type="select1"/>
<bind nodeset="/widgets/table_list_test2/table_list_4" type="select1"/>
<bind nodeset="/widgets/happy_sad_table_2/happy_sad_second_method" type="select"/>
<bind nodeset="/widgets/happy_sad_table_2/happy_sad_brian2" type="select"/>
<bind nodeset="/widgets/happy_sad_table_2/happy_sad_michael2" type="select"/>
<bind nodeset="/widgets/table_list_test2/reserved_name_for_field_list_labels_30" type="string"/>
<bind nodeset="/widgets/table_list_test2/table_list_3" type="string"/>
<bind nodeset="/widgets/table_list_test2/table_list_4" type="string"/>
<bind nodeset="/widgets/happy_sad_table_2/happy_sad_second_method" type="string"/>
<bind nodeset="/widgets/happy_sad_table_2/happy_sad_brian2" type="string"/>
<bind nodeset="/widgets/happy_sad_table_2/happy_sad_michael2" type="string"/>
<bind nodeset="/widgets/happy_sad_table/generated_table_list_label_38" readonly="true()" type="string"/>
<bind nodeset="/widgets/happy_sad_table/reserved_name_for_field_list_labels_39" type="select"/>
<bind nodeset="/widgets/happy_sad_table/happy_sad_brian" type="select"/>
<bind nodeset="/widgets/happy_sad_table/happy_sad_michael" type="select"/>
<bind nodeset="/widgets/happy_sad_table/reserved_name_for_field_list_labels_39" type="string"/>
<bind nodeset="/widgets/happy_sad_table/happy_sad_brian" type="string"/>
<bind nodeset="/widgets/happy_sad_table/happy_sad_michael" type="string"/>
<bind jr:preload="uid" nodeset="/widgets/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
Expand Down
4 changes: 2 additions & 2 deletions pyxform/tests/fixtures/strings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ test_answers_can_be_imported_from_xml = <?xml version='1.0' ?><data id="build_Wa
test_question_type_string_control = <input ref="/test/enumerator_name"><label ref="jr:itext('/test/enumerator_name:label')"/></input>
test_question_type_string_binding = <bind nodeset="/test/enumerator_name" type="string"/>
test_select_one_question_multilingual_control = <select1 ref="/test/qname"><label ref="jr:itext('/test/qname:label')"/><item><label ref="jr:itext('/test/qname/a:label')"/><value>a</value></item><item><label ref="jr:itext('/test/qname/b:label')"/><value>b</value></item></select1>
test_select_one_question_multilingual_binding = <bind nodeset="/test/qname" type="select1"/>
test_select_one_question_multilingual_binding = <bind nodeset="/test/qname" type="string"/>
test_simple_integer_question_type_multilingual_control = <input ref="/test/integer_q"><label ref="jr:itext('/test/integer_q:label')"/></input>
test_simple_integer_question_type_multilingual_binding = <bind nodeset="/test/integer_q" type="int"/>
test_simple_date_question_type_multilingual_control = <input ref="/test/date_q"><label ref="jr:itext('/test/date_q:label')"/></input>
test_simple_date_question_type_multilingual_binding = <bind nodeset="/test/date_q" type="date"/>
test_simple_phone_number_question_type_multilingual_control = <input ref="/test/phone_number_q"><label ref="jr:itext('/test/phone_number_q:label')"/><hint>Enter numbers only.</hint></input>
test_simple_phone_number_question_type_multilingual_binding = <bind constraint="regex(., '^\d*$')" nodeset="/test/phone_number_q" type="string"/>
test_simple_select_all_question_multilingual_control = <select ref="/test/select_all_q"><label ref="jr:itext('/test/select_all_q:label')"/><item><label ref="jr:itext('/test/select_all_q/f:label')"/><value>f</value></item><item><label ref="jr:itext('/test/select_all_q/g:label')"/><value>g</value></item><item><label ref="jr:itext('/test/select_all_q/h:label')"/><value>h</value></item></select>
test_simple_select_all_question_multilingual_binding = <bind nodeset="/test/select_all_q" type="select"/>
test_simple_select_all_question_multilingual_binding = <bind nodeset="/test/select_all_q" type="string"/>
test_simple_decimal_question_multilingual_control = <input ref="/test/decimal_q"><label ref="jr:itext('/test/decimal_q:label')"/></input>
test_simple_decimal_question_multilingual_binding = <bind nodeset="/test/decimal_q" type="decimal"/>

Expand Down
20 changes: 10 additions & 10 deletions pyxform/tests/test_expected_output/attribute_columns_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@
</meta>
</attribute_columns_test>
</instance>
<bind nodeset="/attribute_columns_test/skip_to_end" saveIncomplete="true()" type="select1"/>
<bind nodeset="/attribute_columns_test/skip_to_end" saveIncomplete="true()" type="string"/>
<bind nodeset="/attribute_columns_test/everything" relevant="not(selected( /attribute_columns_test/skip_to_end , 'yes'))"/>
<bind nodeset="/attribute_columns_test/everything/my_name" type="string"/>
<bind bindAttribute="test" nodeset="/attribute_columns_test/everything/invalid_variable" readonly="true()" type="string"/>
Expand All @@ -684,20 +684,20 @@
<bind nodeset="/attribute_columns_test/everything/number_label" readonly="true()" type="string"/>
<bind nodeset="/attribute_columns_test/everything/text_image_audio_video_test" type="string"/>
<bind nodeset="/attribute_columns_test/everything/display_image_test" readonly="true()" type="string"/>
<bind nodeset="/attribute_columns_test/everything/autocomplete_test" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/autocomplete_chars_test" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/autocomplete_test" type="string"/>
<bind nodeset="/attribute_columns_test/everything/autocomplete_chars_test" type="string"/>
<bind nodeset="/attribute_columns_test/everything/a_integer" type="int"/>
<bind constraint=". &lt;= /attribute_columns_test/everything/a_integer " nodeset="/attribute_columns_test/everything/a_decimal" type="decimal"/>
<bind calculate="2" nodeset="/attribute_columns_test/everything/repeat_test_count" readonly="true()" type="string"/>
<bind bindAttribute="test" nodeset="/attribute_columns_test/everything/repeat_test"/>
<bind jr:requiredMsg="Custom required message." nodeset="/attribute_columns_test/everything/repeat_test/group_test/required_text" required="true()" type="string"/>
<bind constraint="not(selected(., 'yes') and selected (., 'no'))" jr:constraintMsg="jr:itext('/attribute_columns_test/everything/repeat_test/group_test/select_multiple_test:jr:constraintMsg')" nodeset="/attribute_columns_test/everything/repeat_test/group_test/select_multiple_test" required="false()" type="select"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/labeled_select_group/label-test" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/labeled_select_group/list-nolabel-test" required="true()" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/name/reserved_name_for_field_list_labels_25" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/name/table_list_question" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/compact-test" type="select1"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/compact-2-test" type="select1"/>
<bind constraint="not(selected(., 'yes') and selected (., 'no'))" jr:constraintMsg="jr:itext('/attribute_columns_test/everything/repeat_test/group_test/select_multiple_test:jr:constraintMsg')" nodeset="/attribute_columns_test/everything/repeat_test/group_test/select_multiple_test" required="false()" type="string"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/labeled_select_group/label-test" type="string"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/labeled_select_group/list-nolabel-test" required="true()" type="string"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/name/reserved_name_for_field_list_labels_25" type="string"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/name/table_list_question" type="string"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/compact-test" type="string"/>
<bind nodeset="/attribute_columns_test/everything/repeat_test/compact-2-test" type="string"/>
<bind bindAttribute="test" nodeset="/attribute_columns_test/everything/acknowledge_test" type="string"/>
<bind bindAttribute="test" nodeset="/attribute_columns_test/everything/date_test" type="date"/>
<bind bindAttribute="test" nodeset="/attribute_columns_test/everything/time_test" type="time"/>
Expand Down
Loading

0 comments on commit 8fb7934

Please sign in to comment.