Crowdsourcing Web Application
Laravel 8 Web Application for Crowdsourcing Projects and Questionnaires
Features
- Administration panel to set up of questionnaires & projects
- Questionnaires with and without login: Questionnaires can be responded anonymously or eponymoysly
- The questionnaires can be automatically translated via google translations (to facilitate the manual translations)
- The citizen responses are automatically translated via google translations (and at the results you can see both the original and the translated)
- Setting targets for goals (number of responses needed for the questionnaire) to be reached
- Gamifications elements: The platform motivates users to respond to questionnaires or invite others to respond
- Mailchimp integration: All the email of registered users are collected to a mailchimp list
- Google Analytics integration (with anonymized settings turned on) with custom events: We track anonymously people who do actions in the website
- Voting mechanism for provided answers: Users can vote the best answers, Platform moderators can highlight the most interesting answers and reject/demote the not interesting ones
- Extract the results2021_12_20_115932_add_social_image_to_projects_table: You can download the answers to excel
- View statistics
- Login function with fb, g+, linkedin, twitter, windows
- Platform is available in many languages (and new translations can be added with relative low cost)
- GDPR compliant
Benefits of Open Source applications
Offering the code under open source licenses includes many benefits. Of those, the ones related to our project, are:
- There is no dependency on the developer of the solution (SciFY), but other collaborators can be used after the end of the project. The code remains always freely available.
- Stakeholders can add features, change it, improve it, adjust to their needs.
- New contributions are added to the existing solution so that everyone benefit
Organizations using the Crowdsourcing platform
Installation Instructions:
First time install (setup database and install dependencies)
- Make sure php 7.4 (or newer) is installed.
Install graphics library
sudo apt-get install php-gd
-
After cloning the project, create an .env file (should be a copy of .env.example), containing the information about your database name and credentials. Then run
php artisan migrate
to create the DB schema andphp artisan db:seed --class=DatabaseSeederRunOnEmptyDB
in order to insert the starter data to the DB -
Generate app key
php artisan key:generate
- Install laravel/back-end dependencies
composer install
composer dump-autoload
- Front-end dependencies
It is very easy to install multiple versions of NodeJS and npm, by using Node Version Manager (nvm).
If you are using nvm
, run this command in order to sync to the correct NodeJS version for the project:
nvm use
Then, install and compile the front-end dependencies:
npm install
npm run dev # (if in development mode)
npm run prod # (if in production mode)
npm run watch # (if in development mode and you want to have live changes)
- Set up the Database (only if in new installation)
Run the Laravel migrations:
php artisan migrate
Run the Database seeder:
php artisan db:seed
- Create symbolic link for uploaded images By default images are stored at app/storage/public. Run
php artisan storage:link
in order to link this folder with the public directory
Database Considerations
If you are running MySQL version 8.0 and above, there is a certain bug regarding memory overflow when trying to sort results in tables that have columns of JSON data type.
A workaround to fix this is to tweak the memory buffer size for sorting. In order to do so, please follow:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
And append the following options:
[mysqld]
sort_buffer_size = 10485760
innodb_sort_buffer_size = 10485760
After you save the file, restart the MySQL service:
sudo service mysql restart
Apache configuration:
% sudo touch /etc/apache2/sites-available/crowdsourcing.conf
% sudo nano /etc/apache2/sites-available/crowdsourcing.conf
<VirtualHost *:80>
ServerName dev.crowdsourcing
ServerAlias dev.crowdsourcing
DocumentRoot "/home/path/to/project/public"
<Directory "/home/path/to/project/public">
Require all granted
AllowOverride all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make the symbolic link:
cd /etc/apache2/sites-enabled && sudo ln -s ../sites-available/crowdsourcing.conf
Enable mod_rewrite, mod_ssl and restart apache:
sudo a2enmod rewrite && sudo a2enmod ssl && sudo service apache2 restart
Fix permissions for storage directory:
sudo chown -R user:www-data storage
chmod 775 storage
cd storage/
find . -type f -exec chmod 664 {} \;
find . -type d -exec chmod 775 {} \;
The above steps can also be done in a better way, by using the companion script:
chmod +x set-file-permissions.sh
sudo ./set-file-permissions.sh www-data USER .
Change hosts file so dev.crowdsourcing
points to localhost
sudo nano /etc/hosts
127.0.0.1 dev.crowdsourcing
Social Login - Sign Up with Socialite
This app uses Socialite Laravel Plugin to handle social login.
In order to get it working in your development environment, you need to make sure that you have API keys and secrets for Facebook and Twitter (guides here and here), and that you can access https://dev.crowdsourcing/ (notice the https) on your machine.
A guide for enabling https on your local machine can be found here.
Basically, you need to run
openssl req -new -sha256 -newkey rsa:2048 -nodes \
-keyout dev.crowdsourcing.key -x509 -days 365 \
-out dev.crowdsourcing.crt
And then reference the 2 files generated in the crowdsourcing.conf file of the application. Make sure you change the port to 443 as shown below:
sudo touch /etc/apache2/sites-available/crowdsourcing.conf
sudo nano /etc/apache2/sites-available/crowdsourcing.conf
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile "/etc/apache2/sites-available/dev.crowdsourcing.crt"
SSLCertificateKeyFile "/etc/apache2/sites-available/dev.crowdsourcing.key"
ServerName dev.crowdsourcing
ServerAlias dev.crowdsourcing
DocumentRoot "/home/path/to/project/public"
<Directory "/home/path/to/project/public">
Require all granted
AllowOverride all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Also, make sure to restart Apache, by running
sudo service apache2 restart
SEO - Generate Sitemap
This application uses Spatie - Laravel Sitemap plugin, in order to create
the public/sitemap.xml
file (which is excluded from git), that will be crawled by the search engines.
In order to run the generator for the current application installation, run the embedded Laravel command:
php artisan sitemap:generate
Related HTML Template
This project uses the free AdminLTE template.
It also makes use of Bootstrap 4
PHP code style - Laravel Pint
This application uses Laravel Pint in order to perform code-style.
In order to run the styler, run :
./vendor/bin/pint --test -v # the --test will not do any changes, it will just output the changes needed
./vendor/bin/pint -v # this command will actually perform the code style changes
Installation-specific resources
The application can be tweaked and personalized for each installation.
In the .env
file you can set the INSTALLATION_RESOURCES_DIR
variable accordingly. This variable must take a value
that represents a directory name in the resourcess/views/home/partials
directory. For example, see
the resourcess/views/home/partials/together
directory. This directory must contain the partial blade files for the
installation.
Run Tests
You may use a separate MySQL database, for testing purposes.
Generally, the fields for testing should be defined in a .env.testing
file, which should start as a copy of
the .env.testing.example
file.
Then, run the migrate
and seed
commands for the testing Database:
cp .env.testing.example .env.testing
php artisan migrate --env=testing
php artisan db:seed --env=testing --class=DatabaseSeeder
How to debug
- Install and configure Xdebug on your machine
- At Chrome install Xdebug helper
- At PhpStorm/IntelliJ click the "Start listening for PHP debug connections"