Error exporting survey
ebdavison opened this issue · comments
Trying to export a survey and getting error with USER_DID_NOT_ANSWER
:
$ ../manage.py exportresult --survey-id 4 --pdf
No configuration file given, using default values.
Traceback (most recent call last):
File "../manage.py", line 21, in <module>
main()
File "../manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/management/commands/exportresult.py", line 78, in handle
exporter.generate_file()
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/exporter/survey2x.py", line 91, in generate_file
f.write(self.survey_to_x())
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/exporter/tex/survey2tex.py", line 121, in survey_to_x
ltxf.text += self.treat_question(question, self.survey)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/exporter/tex/survey2tex.py", line 65, in treat_question
question_synthesis += q2tex.tex()
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/exporter/tex/question2tex_chart.py", line 130, in tex
results = self.get_results()
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/exporter/tex/question2tex_chart.py", line 73, in get_results
ans = Question2Tex.get_clean_answer(answer)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/survey/exporter/tex/question2tex.py", line 144, in get_clean_answer
answer = _(settings.USER_DID_NOT_ANSWER)
File "/home/otcomm/otcomm/otcommenv/lib/python3.6/site-packages/django/conf/__init__.py", line 80, in __getattr__
val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'USER_DID_NOT_ANSWER'
Ho, I get why you had #70 then, you need to have a value for "USER_DID_NOT_ANSWER" in your settings and if you don't then the value = None and you get #70 which is not handled because I always had a value myself. I think it won't fix your data after the fact, you must replace the None yourself with the value you chose in the database.
In your settings.py :
USER_DID_NOT_ANSWER = "USER_DID_NOT_ANSWER" # Or something else that is unique
This should be done in survey and you should not have to add it yourself. Same than #41
Thank you for the reply; that makes sense. There have been a few stumbling blocks to getting this going and several items missing from settings.py
were not documented. I found several, including ROOT
and CHOICES_SEPERATOR
in various issues ... Documenting these in one place would be very helpful.
That being said, I will add this and see how it goes. Several of the items actually were initially empty so I changed them to a space (a single ' ') thinking it would solve the "empty" issue but the code is looking for a field with a minimum length of 3 characters. Not sure the logic there but something like "No" would also cause this error condition.
Indeed this fixes the issue but feels like a workaround. I will go with it for now.
@ebdavison in order to fix your data replace "None"
by null
in your json and use python3 manage.py loaddata
on this correction using the latest version (1.3.14).
I opened #74 in order to not have an enhancement with the title of the original bug.