Download the PHP package stats4sd/laravel-kobo-link without Composer
On this page you can find all versions of the php package stats4sd/laravel-kobo-link. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stats4sd/laravel-kobo-link
More information about stats4sd/laravel-kobo-link
Files in stats4sd/laravel-kobo-link
Package laravel-kobo-link
Short Description Manage KoboToolBox from your Laravel Project
License MIT
Homepage https://github.com/stats4sd/laravel-kobo-link
Informations about the package laravel-kobo-link
Manage KoboToolBox from your Laravel Project
This package turns your Laravel / Laravel Backpack platform into a management system for data collected through KoboToolBox. It is designed to support research or survey data collection, and provides features beyond the scope of what KoboToolBox or other ODK Services can provide on their own.
Who is it for?
Platforms built with this package can help with the following scenarios:
- Multiple teams need to use the same set of ODK forms provided by a central team, but need to retain ownership of their data (i.e. the data of all teams cannot simply be pooled together and made accessible to everyone)
- The data collection is complex, where data from some forms needs to be processed and then shared back to other forms as customised CSV files.
- Including the possibility that each team requires different data to be made available in their ODK forms.
IMPORTANT NOTE
This is not an off-the-shelf data management solution! It requires you to build your own Laravel platform and pull in this package via composer. It does not handle the processing of the data collected through your ODK forms, but it provides hooks to enable you to write your own processing scripts to run automatically when ODK submissions are pulled in from KoboToolBox. You can provide your own database structures / data models to organise the processed data however you see fit.
Installation
You can install the package via composer:
You can publish and run the migrations with:
Setup Required Configuration Variables
In order to link up to a KoBoToolbox server, you must provide the following environment variables:
The two endpoint variables should be the full url to the server you are using. For example:
The platform requires a 'primary' user account on the KoboToolbox server to manage deployments of ODK forms. This account will own every form published by the platform. We highly recommend creating an account specifically for the Laravel platform. If the platform uses an account also used by others, there is a chance that your database will become out of sync with the forms present on KoBoToolbox, and the form management functions may stop working correctly.
Setup Data Models
This packages assumes that the following models exist in the platform:
\App\Models\User
The package provides the following models:
Feature / Purpose | Model | Database Table | Comments |
---|---|---|---|
Team Management | Team | teams | If the platform will be used by a single group who share data (e.g. one research project, or a single survey), you can simply create 1 team. |
Team Management | Invite | invites | This package includes a system of inviting users to specific teams. This feature will hopefully be seperated into a separate package in the future, as it is not a core part of the ODK / KoboToolbox system. |
ODK Form Management | Xlsform | xlsforms | This stores every ODK form present in the platform. Forms can be either deployed to every team, or to a single team, based on needs. This allows most teams to use a 'common' form, but gives you the option to add a custom version of a form for a specific team if required. |
ODK Form Management | TeamXlsform | team_xlsform | The link table for ODK forms and teams. This table will contain 1 record for every unique form that gets deployed to KoboToolbox. |
Submission Processing | Submission | submissions | Every submission that is pulled from KoboToolbox is stored in this table. The main contents is stored as a JSON field, so the table structure is the same regardless of the form's structure. You can then write the processing scripts to 'unpack' this JSON into whatever formats you require. |
Submission Processing | Datamap | datamaps | Datamaps handle the link to the actual processing scripts. Each ODK form can be linked to 1 or more data maps, and submissions will be processed using all linked data maps. |
TODO: add section explaining how the data maps work, and include real examples.
Publishing The config
If you add the required ENV variables to your application, there should be no need to publish the config file.
However, you may wish to do so anyway. To publish the file, use:
Add the Front-end
This package assumes you are using Laravel Backpack as your admin panel. As such, it comes with a set of CrudControllers for managing your XLS forms and submissions. It also assumes that you are able to build your own front-end to allow team members to access their data, manage forms etc.
You can add links to these crud panels into your sidebar file located at resourcs\views\vendor\backpack\base\inc\sidebar_content.blade.php:
TODO: Add example team UI for team members to manage their own forms, submissions and team members/invites.
Writing Data Processing Scripts
The Datamap model includes a process(Submission $submission)
method. This hooks into a Datamap Service class, which is designed to be overwritten by you. Each platform will require a different set of data processing scripts tailored to the data being collected, so we have tried to make it easy to include these scripts in your platform. Here is the short version:
- Create a "DatamapService" class, and add the fully qualified path to this class into your .env file. E.g.:
DATA_PROCESSING_CLASS="\App\Services\DatamapService::class"
- Write the methods you want to use to process a submisison. The method should accept a single Submission parameter, and can then do anything you want to 'process' the submission. e.g.:
TODO: include real examples :)
- Now, you should create a Datamap entry with an ID of the method name. For the example above, you would add the following record to the
datamaps
table:INSERT INTO datamaps SET id = "testForm", title = "Test Form Processing";
It is vital to match the datamap ID to the method name, as this is how the datamap chooses which method to run during processing.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Dave Mills
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-kobo-link with dependencies
ext-json Version *
backpack/crud Version ^4.1
intervention/image Version ^2.5
maatwebsite/excel Version ^3.1
spatie/laravel-package-tools Version ^1.4.3