QRealTime: A QGIS plug-in for ODK

Hi @shiva_Reddy - a bit more testing and another little bug I think. When "making online" a layer for a second time, an image field can get created with incorrect type.

This can be corrected manually by exporting the form to XLS in Kobo, updating the field types and then creating a new form/project from the XLS. I think this will only work if there is no data associated with the form.

To reproduce:

  • create a point layer and add an attribute.
  • "make online" this layer.
  • check that the layer is ok and fields are created correctly on Kobo (non-NGO version)
  • delete the form from Kobo
  • go back to the layer in QGis 3
  • add extra fields - a text field (text2), an integer field (int2), a decimal field (decimal2), another text field (image2) and another text field (text3) and save.
  • in the Properties|Attributes form, set the type of image2 to Attachment, untick "Display resource path" and set "integrated doc viewer|type" to "web view" and save.
  • "make online" the layer again
  • go to Kobo forms and edit the form.
  • you will see image2 has type "text" and text3 has type "image"

This appears to be something to do with the ODKUUID field which is added to the layer the first time it is "made online". Image field seem to get processed out of line.

Also related, if you set ODKUUID field on the layer to be hidden, in the example layer above, the text2 field (after ODKUUID) will be hidden from the Kobo form.

From the QGis log, this is output for QRT.

2020-05-26T15:01:04     INFO    not writing fieldsNone
2020-05-26T15:01:04     INFO    'type'None
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelExternalResource
2020-05-26T15:01:04     INFO    got an image type fieldNone
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelTextEdit
2020-05-26T15:01:04     INFO    getFieldModelExternalResource
2020-05-26T15:01:04     INFO    got an image type fieldNone
2020-05-26T15:01:04     INFO    fieldDict[{'type': 'geopoint', 'required': True, 'label': 'Point Location'}, {'name': 'id', 'label': 'id', 'type': 'integer'}, {'name': 'text1', 'label': 'text1', 'type': 'text'}, {'name': 'int1', 'label': 'int1', 'type': 'integer'}, {'name': 'decimal1', 'label': 'decimal1', 'type': 'decimal'}, {'name': 'image1', 'label': 'image1', 'type': 'image'}, {'name': 'text2', 'label': 'text2', 'type': 'text'}, {'name': 'int2', 'label': 'int2', 'type': 'integer'}, {'name': 'decimal2', 'label': 'decimal2', 'type': 'decimal'}, {'name': 'image2', 'label': 'image2', 'type': 'text'}, {'name': 'text3', 'label': 'text3', 'type': 'image'}]
2020-05-26T15:01:04     INFO    Payload= {'uid': 'test-qrt-to-kobo-export', 'name': 'test-qrt-to-kobo-export', 'asset_type': 'survey', 'content': '{"survey": [{"type": "geopoint", "required": true, "label": "Point Location"}, {"name": "id", "label": "id", "type": "integer"}, {"name": "text1", "label": "text1", "type": "text"}, {"name": "int1", "label": "int1", "type": "integer"}, {"name": "decimal1", "label": "decimal1", "type": "decimal"}, {"name": "image1", "label": "image1", "type": "image"}, {"name": "text2", "label": "text2", "type": "text"}, {"name": "int2", "label": "int2", "type": "integer"}, {"name": "decimal2", "label": "decimal2", "type": "decimal"}, {"name": "image2", "label": "image2", "type": "text"}, {"name": "text3", "label": "text3", "type": "image"}], "choices": []}'}
2020-05-26T15:01:09     INFO    KoboToobox{"url":"https://kf.kobotoolbox.org/api/v2/assets/a6JYenVp9a3ysS8dmKEhYq/permission-assignments/p2nKdnGskPi3ts4ssMByHZ/","user":"https://kf.kobotoolbox.org/api/v2/users/AnonymousUser/","permission":"https://kf.kobotoolbox.org/api/v2/permissions/view_submissions/","label":"View submissions"}

I can see that the fieldDict line is has incorrect field types:

{'type': 'geopoint', 'required': True, 'label': 'Point Location'}, 
{'name': 'id', 'label': 'id', 'type': 'integer'}, 
....
{'name': 'text2', 'label': 'text2', 'type': 'text'}, 
{'name': 'int2', 'label': 'int2', 'type': 'integer'},
 {'name': 'decimal2', 'label': 'decimal2', 'type': 'decimal'},
 **{'name': 'image2', 'label': 'image2', 'type': 'text'},**
** {'name': 'text3', 'label': 'text3', 'type': 'image'}**

The system config is as follows:
Linux Ubuntu 18.04
QGIS version: 3.6.3-Noosa
QRealTime 3.12 (upgraded from 3.8.1)

I have logged this on Github too

thanks again for all your work on this.

Colin