Package: django-scientific-survey
Django scientific surveyA django survey app for conducting scientific surveys, based on "django-survey-and-report" by Pierre Sassoulas. The package supports integrationonlywith Django between versions 2.2 and up to and including 3.2.16. Supporting Django 4 is on the agenda, but not a top priority as of right now.The following changes were made to the original app to accommodate scientific use cases:Introduced answer groups for the use cases when a datapoint should be evaluated using multiple different aspects. For instance, for a given text, you might want to evaluate its naturalness on the scale from 1 to 5, its fluency on the scale from 1 to 10 and its coherence on the scale from 1 to 4.Added the possibility to use numerical rating scales by prodiving prefix and suffix for an answer group. See example of how this looks below.Added a field called "extra" to the Question model to carry out some extra question-specific information. This information will be invisible to the end user and will be simply transfered to the exported survey results for easier analysis later. For instance, this can hold the information about the model that has generated the text.Added the possibility of using external redirect on finishing the survey, which is useful for integrating with crowdsourcing platforms frequently used for human evaluation, such asProlific.Changed import and export format from CSV to JSON and added the answer groups and the "extra" field to this format.Added the possibility to randomize the order of questions for each survey participant.Added the possibility to import surveys from a JSON file.[New in v0.1.2] Added the possibility to add ranges (sliders) as question types, distinguishing between integer ranges (range_int) and float ranges (range_float). It is possible to specify min, max and step for the range by re-using the already existingchoicesfield.[New in v0.2.0] Categories can be treated as independent sub-surveys! This is useful if one wants to create a number of batches all of which are aimed at answering the same research question, but the experimental design requires each participant to see their own batch of questions. Additionally, one can control a number of responses per batch (1 by default).[New in v0.3.0] Added the possibility to specify and save template layouts for questions. Changed JSON to YAML when importing surveys to enable multiline layouts.Recognizing that these changes are not necessarily useful for the users of the original "django-survey-and-report" app (and that the code became more different from the original than expected initially), it was decided to create a separate package "django-scientific-survey" to acommodate these changes.Table of contentsLanguage availableGetting startedMaking a surveyManually through admin UIImporting configuration from a JSON fileContributing as a developerDevelopment environmentCommitting codeLaunching testsAdding test dataLaunching coverageApplying LintTranslating the projectAs a developerAs a translatorCreditLanguage availableThe software is developed in English.Full translation is available for these languages (in alphabetical order):Russian thanks toVlad M.andDmytro KalpakchiUkrainian thanks toDmytro KalpakchiPartial translation (due to the contributions to the original "django-survey-and-report") are available for these languages (in alphabetical order):Brazilian-Portuguese thanks toRafael CapaciChinese thanks to朱聖黎 (Zhu Sheng Li)French thanks toPierre SassoulasGerman thanks toGeorg ElsasIndonesian thanks toDhana DhiraJapanese thanks toNobukuni SuzuePolish thanks toDaniel HornerSpanish thanks toJavier OrdóñezGetting startedAdddjango-scientific-surveyto your requirements and get it with pip.echo'django-scientific-survey'>requirements.txt
pipinstall-rrequirements.txtAddbootstrapformandsurveyin theINSTALLED_APPSin your settings :INSTALLED_APPS=[# Your own installed apps here]...INSTALLED_APPS+=['bootstrapform','scientific_survey']Add an URL entry to your project’s urls.py, for example:fromdjango.confimportsettingsfromdjango.conf.urlsimportinclude,urlurlpatterns=[# Your own url pattern here]if'scientific_survey'insettings.INSTALLED_APPS:urlpatterns+=[url(r'^survey/',include('scientific_survey.urls'))]Note: you can use whatever you wish as the URL prefix.You can also change some other options:# 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 uninstalldjango-scientific-survey, simply comment out or remove thescientific_surveyline in yourINSTALLED_APPS.Making a surveyManually through admin interfaceUsing the admin interface you can create surveys, add questions, give questions categories, define multiple answer groups per question, mark them as required or not, etc.For instance, if you want the respondents to read a text and define its sentiment, you might want to ask "How would you define a sentiment of a text you just read?". This question can be created via the admin interface as shown below.Now if you wanted to give participants 3 options: "Positive", "Neutral" and "Negative", you could do that via the admin interface as well by adding an answer group, as shown below.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.Submitted responses can be viewed via the admin backend and exported in the JSON format.By importing configuration from a JSON fileYou can also create a survey by importing it from a JSON file, which is very handy for large surveys containing hundreds of questions. You can do this via the admin interface using "Import from JSON" button in the "Surveys" menu.The format of the import file is self-explanatory and some examples of such files can be foundhere.Contributing as a developerDevelopment environmentThis is the typical command you should do to get started:python-mvenvvenv/# Create virtualenvsourcevenv/bin/activate# Activate virtualenvpipinstall-e".[dev]"# Install dev requirementspre-commitinstall# Install pre-commit hook frameworkpythonmanage.pymigrate# Create databasepythonmanage.pyloaddatasurvey/tests/testdump.json# Load test datapythonmanage.pycreatesuperuser
pythonmanage.pyrunserver# Launch serverPlease note thatpre-commitwill permit to fix a lot of linting error
automatically and is not required but highly recommended.Committing codeLaunching testsNOTE:Test overhaul is in progresspythonmanage.pytestsurveyAdding test dataIf you want to dump a test database after adding data to it, this is
the command to have a minimal diff :pythonmanage.pydumpdata--formatjson-econtenttypes-eadmin-eauth.Permission
-esessions.session-esites.site--natural-foreign--indent1-osurvey/tests/testdump.jsonLaunching coveragecoveragerun--source=survey--omit=survey/migrations/*./manage.pytestcoveragehtml
xdg-openhtmlcov/index.htmlApplying LintWe're usingpre-commit, it should take care of linting during commit.Translating the projectDjango-scientific-survey is available in multiple languages. Your contribution would be very appreciated if you know a language that is not yet available.As a developerIf your language do not exists add it in theLANGUAGEvariable in the settings, likehere.
Do not forget to credit yourself like in the header seenhereIn order to add translation files you first need to run for your own locale (change-lflag to the locale of your choice, e.g. 'ru', 'es', 'fr', etc.).pythonmanage.pymakemessages--no-obsolete--no-wrap--ignorevenv-lukThen run the server, as usual (python manage.py runserver) and accesshttp://localhost:8000/adminto login.
Then go tohttp://localhost:8000/rosettato translateAfterwards addd your translations to GitHub and create a pull request for them to be merged.gitaddsurvey/locale/If your language is not yet available in rosetta,according to this stack overflow questionshould work even for languages not handled by django.As a translatorIf 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 creditedhere.CreditsBased ondjango-survey-and-report by Pierre Sassoulas, which is, in turn is based onjessykate's django-survey, and contributions by jibaku, joshualoving, and ijasperyang in forks of jessykate's project.