Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new geometries / entities from API call to ODK from FMTM (instead of via XLSForm) #2146

Open
spwoodcock opened this issue Feb 4, 2025 · 4 comments
Labels
backend Related to backend code dependency:osm-fieldwork Requires updates in osm-fieldwork effort:low Likely a few hours enhancement New feature or request priority:high Should be addressed as a priority

Comments

@spwoodcock
Copy link
Member

spwoodcock commented Feb 4, 2025

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

  • When the user draws a geometry and confirms, we make an API call to create a new Entity in ODK.
  • The entity id is returned, then passed via intent to ODK Collect / Web Forms.
  • The entity / geometry is selected automatically when the user fills out the form.

Describe alternatives you've considered

  • We currently have XLSForm logic to create the entity on form submit.
  • The problem is we need a new_feature field in the XLSForm to trigger this.

Additional context

  • In the short term this will cause issues with an offline workflow.
  • Previously the user could fall back to using ODK Collect only in the worst case - simply creating a new geom or selecting an existing geom from the form.
  • Now we rely on API calls from FMTM to handle the entities, so need to work on the fully offline workflow milestone.
  • It's a temporary step backwards to make our lives easier, as XLSForm logic based entity creation is more complex and less maintainable.
  • We will need a mechanism to store entities and submissions offline, then:
    • Sync created entities to server when back online.
    • Store the entity IDs on the users device, allowing them to link to a submission (how can we do this? can we pass in the entity id during entity creation?)
    • Sync submissions to server, only once the entities have been created successfully on the server (linking the submission to the created entity id).

Important note

Relies on hotosm/osm-fieldwork#338 being complete and merged first.

@spwoodcock spwoodcock added the enhancement New feature or request label Feb 4, 2025
@spwoodcock spwoodcock added priority:high Should be addressed as a priority backend Related to backend code dependency:osm-fieldwork Requires updates in osm-fieldwork effort:medium Likely a day or two labels Feb 4, 2025
@spwoodcock spwoodcock added effort:low Likely a few hours and removed effort:medium Likely a day or two labels Feb 4, 2025
@Sujanadh
Copy link
Collaborator

Sujanadh commented Feb 5, 2025

We can use logic to create an entity from the XLS form. So we add a new hidden choice field "new_geometry" or "new_feature" just to record "yes" or "no" (No as default value only change from odk intent url) in order to track the newly created geometry, whether it is from ODK Collect or via FMTM. During offline mode or fully relying on ODK Collect only, we check whether geometry is selected or not. If geometry is not selected and new_feature is still "No," then we can allow the user to draw in ODK Collect (by default Polygon) and update new_geometry value using trigger probably?

@spwoodcock
Copy link
Member Author

spwoodcock commented Feb 5, 2025

Hmm could possibly work. I'm not sure if the logic will clash, so needs to be tested. Ideally we want the question to select an existing geom to be mandatory, but its difficult to do that of we also account for the new geom field.

As part of the flow you describe, we would have the new_feature field and possibly an is_new_feature field

@NSUWAL123
Copy link
Contributor

Tried this approach: create an entity in ODK of a newly created feature ---> create a geom record ---> then pass entity uuid to ODK intent URL as a param on PR #2156.
However, there were 2 problems so the work on the PR is incomplete as I was unsure if we will follow this approach.

  1. After calling the entity creation & geometry record post API, the entity uuid is passed as a param to the intent URL. The problem is the feature is not preselected (which we want). The current behavior is we need to refresh the form to sync the newly created feature. So, whenever the user is redirected to the ODK after entity creation they need to go back to refresh the form and then manually select the feature in the ODK.
  2. On the response of /statuses API, the submission_ids field contains 'None'.
    Image

CC: @spwoodcock @Sujanadh

@spwoodcock
Copy link
Member Author

Thanks for the good write up @NSUWAL123!

This is quite a dilemma that needs more thought 🤔

We will probably be fine for Web Forms, but this will affect ODK Collect, as I'm not sure there is a way to trigger an entity list update in the background prior to selecting the entity.

With the way ODK Collect works I'm not sure there is a way around this issue I can think of immediately. Open to ideas & hopefully can get some more clarity when I get some time to dig into it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Related to backend code dependency:osm-fieldwork Requires updates in osm-fieldwork effort:low Likely a few hours enhancement New feature or request priority:high Should be addressed as a priority
Projects
None yet
Development

No branches or pull requests

3 participants