Excel Analyzer doesn't work for xlsforms without choices sheet

Hi. Bug Report! Create a new form a single question of type Photo. Publish it, (do or don’t submit anything,) generate an XLS export then try to export as Excel Analyzer. On kc.kobotoolbox.org, you’ll get a 502 Bad Gateway error. On our own deployment, we get a 500 error with this explanation: (paths removed by me; line numbers may not be exact)

Traceback (most recent call last):

File “//lib/python2.7/site-packages/django/core/handlers/base.py”, line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)

File “//kobocat/onadata/apps/logger/views.py”, line 533, in download_excel_analyser
analyser_io= generate_analyser(xlsform_io, data_file_xlsx)

File “//kobocat/onadata/libs/utils/analyser_export.py”, line 203, in generate_analyser
insert_xlsform_worksheets(analyser_shared_strings, survey_worksheet_file_path, choices_worksheet_file_path, survey_file_xls)

File “//kobocat/onadata/libs/utils/analyser_export.py”, line 146, in insert_xlsform_worksheets
choices_sheet_path= ‘xl/worksheets/sheet’ + worksheet_indices[‘choices’] + ‘.xml’

KeyError: ‘choices’

Which basically points out the fact that there aren’t multiple-choice or other kinds of questions to generate a ‘choices’ sheet.

The error can be avoided by checking if ‘choices’ exists in sheets before blindly trying to copy it to excel analyzer sheets, however I don’t know how excel analyzer works; does lacking a ‘choices’ sheet break it? Please review this issue.

Cheers; Hossein.

Hi, Hossein; thanks for the report. I’ve created a issue for this (https://github.com/kobotoolbox/kobocat/issues/78) so we can track it. No estimate on when it’ll be fixed, though since I’m focusing on getting our system into Docker for the time being.

···

On Tuesday, August 18, 2015 at 7:44:35 AM UTC-4, Chroma wrote:

Hi. Bug Report! Create a new form a single question of type Photo. Publish it, (do or don’t submit anything,) generate an XLS export then try to export as Excel Analyzer. On kc.kobotoolbox.org, you’ll get a 502 Bad Gateway error. On our own deployment, we get a 500 error with this explanation: (paths removed by me; line numbers may not be exact)

Traceback (most recent call last):

File “//lib/python2.7/site-packages/django/core/handlers/base.py”, line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)

File “//kobocat/onadata/apps/logger/views.py”, line 533, in download_excel_analyser
analyser_io= generate_analyser(xlsform_io, data_file_xlsx)

File “//kobocat/onadata/libs/utils/analyser_export.py”, line 203, in generate_analyser
insert_xlsform_worksheets(analyser_shared_strings, survey_worksheet_file_path, choices_worksheet_file_path, survey_file_xls)

File “//kobocat/onadata/libs/utils/analyser_export.py”, line 146, in insert_xlsform_worksheets
choices_sheet_path= ‘xl/worksheets/sheet’ + worksheet_indices[‘choices’] + ‘.xml’

KeyError: ‘choices’

Which basically points out the fact that there aren’t multiple-choice or other kinds of questions to generate a ‘choices’ sheet.

The error can be avoided by checking if ‘choices’ exists in sheets before blindly trying to copy it to excel analyzer sheets, however I don’t know how excel analyzer works; does lacking a ‘choices’ sheet break it? Please review this issue.

Cheers; Hossein.