To achieve that I need to transform ODK form submission data to a readable document (I think PDF is the best format).
I want this process to be as easy and quick as possible. I’m thinking that the best way to achieve this is using the “edit” view of the submission in the web interface which have a “print“ button, and this gives me a PDF which is not that pretty but is readable (and that is enough for me).
The thing is that I want to do this automatically using the pyODK library. How can I do this? Maybe I could get the printable view in HTML format and not PDF, this could work too.
I want to make a single script that works for all the forms I could possible create.
I was experimenting with other options like mail merge for Word documents, but this require that I create a non-trivial python script for every form we deploy, and that would not allow us to create and deploy forms quickly.
Just curious, is the PDF or HTML going to be sent via email to individuals? Posted online? Saved in an archive? Viewed on a Mobile Device or desktop? Need to be accessed while offline? I ask these questions because I've had similar thoughts and curious what others needs are.
I get what you're saying, couldn't you Google mail merge but write a Google apps script that would populate the document with all the headers from the form? Then you could export a pdf for each row/new submission?
This PDF/HTML is going to be sent via emails to individuals. The idea is that those who read the emails could be able to check and validate the form content; I don’t need them to change anything, at least for now. I think it does not need to be accessed offline.
About the second paragraph. The thing is that I expect that if I deploy ODK in my organization then we would have to create multiple forms over time, and if I use mail merge and scripts, then we would have to create a template and script for each form we deploy, and by the tests I did using this (by your suggestion in other post), that is not easy and fast enough. I don’t know much about google mail merge and google apps scripts, but I expect that to be more or less the same.
Another problem I had is that using pyODK I can access form submissions data but stripped from “visualization” information like labels and hints. So in my python script I needed to manually type that information because pyODK does not have easy methods to access “visual“ information in form definitions. Maybe I could be able to access that info using those HTML verb methods in pyODK, but I don’t know much about that and it adds another layer of complexity about creating scripts for doing mail merge for a given form.
Finally, Other issue is that I want to deploy something that other people are able to manage and maintain without much technical knowledge, because I will not be in this organization much time, I expect. So it would be better for me to be able to write a script that works for every possible form than writing a new script every time a new form is created, and maybe I will not be here when those new forms will be deployed.
I can't say much on the python front, but if I were you, I think it would be possible to just make a google apps script that could reference both the submission data AND the original XLSForm in order to get all the labels and submission data and just spit them out in a google doc alternating the labels and the data submitted. A pretty generic script could do this easily, but it would do every single column in the ODK Central database (ie every single row of your XLSForm).
One of several questions to ask if you have a lot of calculate fields/other fields you don't want to display to the user. Do you want to follow the same rules and ignore those or do you want to display those as blanks? If you want to follow the relevant logic in your form on the PDF, that becomes much more involved for trying to make one script for every kind of form.
Hello. I tried your suggestion with a python script and I was able to create a generic script, I thought it would be harder to get XLSForm definition data and manipulate it in a simple way, but I just needed a simple script with pyODK and pandas.
Maybe I could even send the form data as plain text/HTML in the email, so that I don’t need to include attachments.
I’ll look into google apps scripts soon because maybe that would give me a better integration with emails. I’m using python right now because I wanted to try things and python is what I know.
About your last paragraph, right now my forms do not have complex logic, so that for the sake of simplicity I will show everything and display non-relevant fields as blanks.