QRealTime: A QGIS plug-in for ODK

Great, then I will try out the Kobo-toolbox as link between QGIS and ODK.

Cheers,
Ruben

Hi @shiva_Reddy, thanks for all your hard work with QRealTime - it's been a life saver to be able to migrate off QGis v2 and still use ODK collect.

I have been using the latest dev release 3.12 and working with KoboToolbox and it is working great.

One small thing I have noticed is that if you try to import while the layer is in edit mode you get this error message. Would be nice to get a friendly message instead :slight_smile: I have some non-tech users who would be freeked by this!

An error has occurred while executing Python code: 

AssertionError 
Traceback (most recent call last):
  File "/home/colin/.local/share/QGIS/QGIS3/profiles/default/python/plugins/QRealTime/QRealTime.py", line 278, in importData
    service.importData(layer,selectedForm,True)
  File "/home/colin/.local/share/QGIS/QGIS3/profiles/default/python/plugins/QRealTime/QRealTime_dialog.py", line 736, in importData
    self.collectData(layer,selectedForm,importData,self.layer_name,self.version,self.geoField)
  File "/home/colin/.local/share/QGIS/QGIS3/profiles/default/python/plugins/QRealTime/QRealTime_dialog.py", line 427, in collectData
    self.updateLayer(layer,remoteTable,geoField)
  File "/home/colin/.local/share/QGIS/QGIS3/profiles/default/python/plugins/QRealTime/QRealTime_dialog.py", line 502, in updateLayer
    with edit(layer):
  File "/usr/lib/python3/dist-packages/qgis/core/additions/edit.py", line 38, in __enter__
    assert self.layer.startEditing()
AssertionError

Python version: 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0] 
QGIS version: 3.6.3-Noosa Noosa, 0c5774c 

Python Path:
/usr/share/qgis/python
/home/colin/.local/share/QGIS/QGIS3/profiles/default/python
/home/colin/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/home/colin/.local/lib/python3.6/site-packages
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
/home/colin/.local/share/QGIS/QGIS3/profiles/default/python
/home/colin/.local/share/QGIS/QGIS3/profiles/default/python/plugins/QRealTime
/home/colin/proj/qgis-test/relations

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

thanks, Colin

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

added to Github as bug

@shiva_Reddy, the guy I am working for, Martin Jakes, wanted me to pass on his thanks for your work with this plug in. We are using QGis, Kobo and KoboCollect to survey his community woodland for Ash die back, part of his management plan. He operates as a non-profit opening the woodland to the local community and schools so the opensource software is key to this.

Once again thank you and to the wider ODK and QGis team for all your hard work and dedication.

Soon to have a new website (jun 20) featuring QGis based map :smiley:

thanks, Colin and Martin

2 Likes

Hi all! @ianmahoney, @samlevy, and I are a part of UW Impact++, a volunteer student-run organization at the University of Washington. For the past few months, we have been working on adding support for ODK Central to the QRealTime plugin. The changes are now live in an experimental version of the plugin! To use the experimental version, open QGIS and navigate to: Plugins -> Manage and Install Plugins -> Settings -> Show also experimental Plugins. Then navigate to Plugins -> Manage and Install Plugins -> Installed -> QRealTime -> Upgrade to experimental plugin.

Here is a link to the GitHub with the ODK central branch which has an updated README with instructions how to use the plugin for ODK Central. If you run into issues please add them as in issue in the GitHub or as a comment on this thread.

6 Likes

I have been trying to use QRealTime with ODK Central. I have found have found that if I have a form with a geoshape type field in it QRealTime will not import any records. Have I done something wrong?

I have also incidentally found that if form_id is not the same as the form name QRealTime crashes.

Congratulations for your work. I've been testing your plugin, but in the last update, I got an error. And when I import the form from Kobotoolbox, it only brings some fields with data and Null appears in the others. Can you give me any solution regarding this? Thank you,