Package: django-survey-and-report
Django surveyA django survey app that can export results as CSV or PDF using your native language.django-survey-and-reporton pypi. Based on and compatible withdjango-survey. You
will be able to migrate your data from an ancient version ofdjango-survey, but it has
been ported to python 3, and you can export results as CSV or PDF using your native
language.Professional support for django-survey-and-report is available as part of theTidelift SubscriptionTable of contentsLanguage availableGetting startedMaking a surveyGenerating a pdf report from the survey's resultBasic exampleSankey's diagramAdvanced exampleImplementing a custom treatmentCreditLanguage availableThe software is developed in english. Other available languages are :Brazilian-Portuguese thanks toRafael CapaciChinese thanks to朱聖黎 (Zhu Sheng Li)French thanks toPierre SassoulasGerman thanks toGeorg ElsasIndonesian thanks toDhana DhiraJapanese thanks toNobukuni SuzueSpanish thanks toJavier OrdóñezRussian thanks toVlad M.Polish thanks toDaniel HornerDutch thanks toJohn GuyverTurkish thanks toHüseyin Emre ArmağanGreek thanks toSotirios ZogosGetting startedAdddjango-survey-and-reportto your requirements and get it with pip.echo'django-survey-and-report'>>requirements.txt
pipinstall-rrequirements.txtAddbootstrapformandsurveyin theINSTALLED_APPSin your settings :INSTALLED_APPS=[# Your own installed apps here]frompathlibimportPathCSV_DIRECTORY=Path("csv")# Define the directory where csv are exportedTEX_DIRECTORY=Path("tex")# Define the directory where tex files and pdf are exportedINSTALLED_APPS+=['bootstrapform','survey']Add a URL entry to your project’s urls.py, for example:fromdjango.confimportsettingsfromdjango.conf.urlsimportincludetry:fromdjango.conf.urlsimporturlexceptImportError:# Django 4.0 replaced url by something else# See https://stackoverflow.com/a/70319607/2519059fromdjango.urlsimportre_pathasurlurlpatterns=[# Your own url pattern here]if'survey'insettings.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/567417EXCEL_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"# Path to the Tex configuration file (default to an internal file that should be sufficient)frompathlibimportPathTEX_CONFIGURATION_FILE=Path("tex","tex.conf")# Default color for exported pdf pie (default to "red!50")SURVEY_DEFAULT_PIE_COLOR="blue!50"To uninstalldjango-survey-and-report, simply comment out or remove the 'survey' line
in yourINSTALLED_APPS.If you want to use the pdf rendering you need to installxelatex. If you're using the
Sankey's diagram generation you will also have to installpython-tk(for python 2.7)
orpython3-tk(for python 3.x).Making a surveyUsing 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.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, in an exported csv or in a pdf
generated with latex.Generating a pdf report from the survey's resultThere is a default configuration for PDF generation, but you might want to changeTEX_CONFIGURATION_FILEfor better results (in particular for language other than
english).You can manage the way the report is created in a yaml file, globally, survey by survey,
or question by question. In order to render pdf you will need to installxelatex. You
will also need python3-tk for sankey's diagram.The results are generated for the server only when needed, but you can force it as a
developer with:pythonmanage.pyexportresult-hFollowing is an example of a configuration file. you can generate one with:pythonmanage.pygeneratetexconf-hBasic examplegeneric:document_option:11pt"Testsurvëy":document_class:reportquestions:"Loremipsumdolorsitamët,<strong>consectetur</strong>adipiscingelit.":chart:type:polartext:pin"Dolorsitamët,consectetur<strong>adipiscing</strong>elit.":chart:type:cloudtext:insideThe pdf is then generated using the very good pgf-pie library.Sankey diagramIf you installed python3-tk, you can also show the relation between two questions using
a sankey diagram :"Loremipsumdolorsitamët,<strong>consectetur</strong>adipiscingelit.":chart:type:sankeyquestion:"Dolorsitamët,consectetur<strong>adipiscing</strong>elit."You get this as a result:Advanced exampleYou can also limit the answers shown by cardinality, filter them, group them together
and choose the color for each answer or group of answers.If you use this configuration for the previous question:"Testsurvëy":"Dolorsitamët,consectetur<strong>adipiscing</strong>elit.":multiple_charts:"SubSubSectionwithradius=3":color:Yës:blue!50No:red!50Whatever:red!50!blue!50radius:3"SubSubSectionwithtext=pin":group_together:Nah:-No-WhateverK.:-Yëscolor:Nah:blue!33!red!66K.:blue!50text:pinchart:radius:1type:cloudtext:insideYou get this as a result:Implementing a custom treatmentIf you want to make your own treatment you can use your own class, for example.Configuration:"Testsurvëy":questions:"Ipsumdolorsitamët,<strong>consectetur</strong>adipiscingelit.":chart:type:survey.tests.exporter.tex.CustomQuestion2TexChildCode insurvey.tests.exporter.tex.CustomQuestion2TexChild:fromsurvey.exporter.tex.question2tex_chartimportQuestion2TexChartclassCustomQuestion2TexChild(Question2TexChart):defget_results(self):self.type="polar"return"""        2/There were no answer at all,3/But we have a custom treatment to show some,2/You can make minor changes too !"""Result:For a full example of a configuration file look atexample_conf.yamlin doc, you can
also generate your configuration file withpython manage.py generatetexconf -h, it
will create the default skeleton for every survey and question.To guide you during the python development, you can read:The default reporter for PieChart inQuestion2TexChart:https://github.com/Pierre-Sassoulas/django-survey/blob/master/survey/exporter/tex/question2tex_chart.py#L13The Sankey reporter inQuestion3TexSankey:https://github.com/Pierre-Sassoulas/django-survey/blob/master/survey/exporter/tex/question2tex_sankey.py#L15The Raw reporter inQuestion2TexRax:https://github.com/Pierre-Sassoulas/django-survey/blob/master/survey/exporter/tex/question2tex_raw.py.Do not hesitate to make a pull request with your new exporter if it can be of interest
for others I'll integrate it.CreditsBased onjessykate's django-survey, and
contribution by jibaku, joshualoving, and ijasperyang in forks of jessykate's project.We useanazalea's pySankeyfor sankey's diagram
during reporting.