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

Feature/kobotoolbox integration #128

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

paulapreuss
Copy link
Collaborator

@paulapreuss paulapreuss commented Aug 29, 2024

The idea for this code is to be able to display a link within the tool that will lead people to a survey that they can fill out. The results from the survey can later be fetched again through the API. If you'd like to test it out, I can give you the login data for the Kobotoolbox account containing the base survey that I used to test this. You will also need the KOBO_API_TOKEN.

Process concept

Setup

0. Create a base survey
The base survey corresponds to the survey that should be duplicated when the user requests it. By using duplicates every survey will have the set of answers unique to the user/project, and not contain the answers for all users. The survey ID can be found in its URL on Kobotoolbox.

Survey deployment

(These steps are currently performed in the __init__ of the KoboToolbox class.

1. Clone the survey
Clone the survey given by the corresponding ID, which is then saved as a draft on the KoboToolbox account. The function will return the new_form_id, which is needed to deploy the form.

2. Assign permissions
By default, only assigned people (which then obviously also need a Kobotoolbox account) can fill out the survey. Anonymous users can fill out the survey by adding the permissions view_asset and add_submissions to AnonymousUser.

3. Deploy the survey
By deploying the form, it will be moved from the drafts to the deployed forms, allowing people to fill it out. The function will return the link to the online survey.

... after this happens, I figured there should be a button to press when the user knows that the survey has been filled out by all necessary people, and then:

Data processing

(These steps are not yet in the code)

4. Retrieve survey data
The answers from the survey can be retrieved back once it has been filled out. I did not implement this yet in my version, but Johann did some of it for WEFESiteAnalyst already https://github.com/rl-institut/WEFESiteAnalyst/tree/data_analysis_ui.

5. Do post-processing

Functions allow to clone a base survey, deploy the survey and change the permissions so that anonymous users can fill out the web form
Comment on lines +206 to +208
# API to connect with KoboToolbox
KOBO_API_URL = "https://kf.kobotoolbox.org/api/v2/"
KOBO_API_TOKEN = os.getenv("KOBO_API_TOKEN")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow it is showing the entire files as changed even though I am only committing bits of code. Not sure why that is. Sorry about that. This is what is actually new.

logger = logging.getLogger(__name__)


class KoboToolbox:
Copy link
Collaborator Author

@paulapreuss paulapreuss Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this file, the changes are just the ones inside this new class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant