Skip to content

A django survey app, based on and compatible with 'django-survey' (ie: you can migrate your old django-survey app and its data), but ported to python 3 and allowing export and report as CSV. Not Available on PyPi as "django-survey-and-report"

License

Notifications You must be signed in to change notification settings

Bodyhealer/django-survey

 
 

Repository files navigation

Django survey

This is django survey app without tex, pdf report.

A django survey app, based on and compatible with "django-survey". You will be able to migrate your data from an ancient version of django-survey, but it has been ported to python 3 and you can export results as CSV using your native language.

If you want the latest version still compatible with python 2.7 you need a version < 1.3.0.

Build Status Coverage Status PyPI version Code style: black PRs Welcome

Table of contents

Language available

The software is developed in english. Other available languages are :

Getting started

Add django-survey-and-report to your requirements and get it with pip.

echo 'django-survey-and-report' > requirements.txt
pip install -r requirements.txt

Add bootstrapform and survey in the INSTALLED_APPS in your settings :

INSTALLED_APPS = [
	# Your own installed apps here
]

from pathlib import Path

CSV_DIRECTORY = Path("csv") # Define the directory where csv are exported

INSTALLED_APPS += [
	'bootstrapform',
	'survey'
]

Add an URL entry to your project’s urls.py, for example:

from django.conf import settings
from django.conf.urls import include, url

urlpatterns = [
    # Your own url pattern here
]

if 'survey' in settings.INSTALLED_APPS:
    urlpatterns += [
        url(r'^survey/', include('survey.urls'))
    ]

Note: you can use whatever you wish as the URL prefix.

You can also change some options:

# Permit to open the csv in excel without problem with separator
# Using this trick : https://superuser.com/a/686415/567417
EXCEL_COMPATIBLE_CSV = True

# The separator for questions (Default to ",")
CHOICES_SEPARATOR = "|"

# What is shown in export when the user do not answer (Default to "Left blank")
USER_DID_NOT_ANSWER = "NAA"

To uninstall django-survey-and-report, simply comment out or remove the 'survey' line in your INSTALLED_APPS.

Making a survey

Using the admin interface you can create surveys, add questions, give questions categories, and mark them as required or not. You can define choices for answers using comma separated words.

Creating of a question

The front-end survey view then automatically populates based on the questions that have been defined and published in the admin interface. We use bootstrap3 to render them.

Answering a survey

Submitted responses can be viewed via the admin backend, in an exported csv or in a pdf generated with latex.

Contributing as a developer

Development environment

This is the typical command you should do to get started:

python -m venv venv/ # Create virtualenv
source venv/bin/activate # Activate virtualenv
pip install -e ".[dev]" # Install dev requirements
pre-commit install # Install pre-commit hook framework
python manage.py migrate # Create database
python manage.py loaddata survey/tests/testdump.json # Load test data
python manage.py createsuperuser
python manage.py runserver # Launch server

Please note that pre-commit will permit to fix a lot of linting error automatically and is not required but highly recommended.

Committing code

Launching tests

python manage.py test survey

Adding test data

If you want to dump a test database after adding data to it, this is the command to have a minimal diff :

python manage.py dumpdata --format json -e contenttypes -e admin -e auth.Permission
-e sessions.session -e sites.site --natural-foreign --indent 1
-o survey/tests/testdump.json

Launching coverage

coverage run --source=survey --omit=survey/migrations/* ./manage.py test
coverage html
xdg-open htmlcov/index.html

Applying Lint

We're using pre-commit, it should take care of linting during commit.

Translating the project

Django survey's is available in multiple language. Your contribution would be very appreciated if you know a language that is not yet available.

As a developer

If your language do not exists add it in the LANGUAGE variable in the settings, like here. Do not forget to credit yourself like in the header seen here

Then you can translate with :

python manage.py makemessages
# python manage.py createsuperuser ? (You need to login for rosetta)
python manage.py runserver
# Access http://localhost:8000/admin to login
# Then go to http://localhost:8000/rosetta to translate
python manage.py makemessages --no-obsolete --no-wrap
git add survey/locale/
...

If your language is not yet available in rosetta, this stack overflow question should work even for language not handled by django.

As a translator

If you're not a developer, open an issue on github and ask for a .po file in your language. I will generate it for you, so you can edit it with an online editor. I will then create the .po and commit them, so you can edit them with your github account or integrate it myself if you do not have one. You will be credited here.

Credits

Based on jessykate's django-survey, and contribution by jibaku, joshualoving, and ijasperyang in forks of jessykate's project.

We use anazalea's pySankey for sankey's diagram during reporting.

About

A django survey app, based on and compatible with 'django-survey' (ie: you can migrate your old django-survey app and its data), but ported to python 3 and allowing export and report as CSV. Not Available on PyPi as "django-survey-and-report"

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 95.7%
  • HTML 4.2%
  • JavaScript 0.1%