Closed mtwestra closed 7 years ago
@mtwestra we have discussed the idea of doing it on FLOW services - https://github.com/akvo/akvo-flow-services/issues/7
Remapping ids during import is simple in concept but has a few unsolved issues.
Currently there are two cases: A. Copying the entire instance. This should work fine, as all the id's are processed together. B. Copying one Form. This becomes problematic when you want to copy a multiple-form (monitored) survey. You will have to copy each form separately, so they will end up in separate trees of folders+survey, but with the same names.
a possible fix is to introduce a third copying mode: C. Copying a Survey, or more generally a Folder. This solves the multiple-form survey case, but the problem now becomes how to know the id of the survey/folder. They are not displayed in the UI and would have to be dug out of the instance DB console one by one.
Do we want newly copied surveys to start out unpublished?
The id remap currently is done only for single-survey copying, but all forms in the same survey as that which is indicated by the parameter are copied. The copied survey is always created in the root folder.
@stellanl I found three things that did not get copied well into the copied survey on dev2:
It seems JsonObject.optString() does the wrong thing with null values; it returns the string "null" which is not what we want. There are probably more places in the code where this could cause problems. We could check the datastores for "null" strings to get an idea of where. See http://stackoverflow.com/questions/18226288/json-jsonobject-optstring-returns-string-null
There is one improvement still possible; remap id's when copying a whole instance. But that requires a a lot of work to recreate the folder structure.
Code tested with 180+ SNV surveys. 👍 can be considered passing test
We will not release this as a full user functionality for now (no UI changes), but as a support service which 2nd line of support will handle in a controlled way (creating the copying link, cross checking that all questions got moved properly, options and settings and informing the user). There will be a questionnaire added to Flow support to easily guide to user through the copying request.
Secondly we will track what types of requests we receive (motivations of copying a survey across dashboards) to evaluate the need to support 'best practice/standardised surveys'. In January 2017 we will review the findings and decide on next steps.
Implementation passes tests plan 👍
At the moment, when a survey is copied from one instance to another, the original ids of the objects are used in the new instance. This is fine when surveys are copied to an empty instance, but risky when surveys are copied to an existing instance.
Proposed solution: 1) implement a save copy of surveys 2) check if translations are copied as well