Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pyxform/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pyxform.errors import ErrorCode, PyXFormError
from pyxform.external_instance import ExternalInstance
from pyxform.question import (
GeoQuestion,
InputQuestion,
MultipleChoiceQuestion,
Option,
Expand All @@ -39,6 +40,11 @@
"select1": MultipleChoiceQuestion,
"trigger": TriggerQuestion,
"upload": UploadQuestion,
"__by_type__": {
"geopoint": GeoQuestion,
"geoshape": GeoQuestion,
"geotrace": GeoQuestion,
},
}
SECTION_CLASSES = {
const.GROUP: GroupedSection,
Expand Down Expand Up @@ -157,7 +163,9 @@ def _create_question_from_dict(

if question_class:
if choices:
d_choices = d.get(const.CHOICES, d.get(const.CHILDREN))
d_choices = choices.get(
d.get(const.ITEMSET), d.get(const.CHOICES, d.get(const.CHILDREN))
)
if d_choices:
return question_class(
question_type_dictionary=question_type_dictionary,
Expand All @@ -166,7 +174,7 @@ def _create_question_from_dict(
for k, v in d.items()
if k not in {const.CHOICES, const.CHILDREN}
},
choices=choices.get(d[const.ITEMSET], d_choices),
choices=d_choices,
)

return question_class(question_type_dictionary=question_type_dictionary, **d)
Expand Down Expand Up @@ -196,6 +204,10 @@ def _get_question_class(question_type_str, question_type_dictionary):
and find what class it maps to going through
type_dictionary -> QUESTION_CLASSES
"""
by_type = QUESTION_CLASSES["__by_type__"].get(question_type_str, None)
if by_type is not None:
return by_type

control_tag = ""
question_type = question_type_dictionary.get(question_type_str)
if question_type:
Expand Down
2 changes: 2 additions & 0 deletions pyxform/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ class ParametersAudit(StrEnum):
class ParametersGeo(StrEnum):
ALLOW_MOCK_ACCURACY = "allow-mock-accuracy"
INCREMENTAL = "incremental"
REFERENCE_GEO = "reference-geo"
Comment thread
lognaturel marked this conversation as resolved.
Outdated


class ParametersGeoPoint(StrEnum):
ALLOW_MOCK_ACCURACY = "allow-mock-accuracy"
CAPTURE_ACCURACY = "capture-accuracy"
REFERENCE_GEO = "reference-geo"
WARNING_ACCURACY = "warning-accuracy"


Expand Down
9 changes: 9 additions & 0 deletions pyxform/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ class ErrorCode(Enum):
"The following are invalid parameter key(s): '{rejected}'."
),
)
SURVEY_006: Detail = Detail(
name="Survey sheet - invalid geo parameter 'reference-geo'",
msg=(
"[row : {row}] On the 'survey' sheet, the 'parameters' value is invalid. "
"For geo questions, the 'reference-geo' parameter must be either: "
"a choices list_name, an entities list_name, a reference variable containing "
"the name of a repeat, or the name of an attached CSV file."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"an attached CSV file" -> "an attached file" (could be XML or geojson)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the error message along these lines in 7b1799b

),
)


class PyXFormError(Exception):
Expand Down
Loading
Loading