Python "list index out of range" bug when trying to generate grade report

When I go to Instructor → Data Download → Generate report of problem responses, and select a problem with a pulldown type question, I get
“Error: There was an error generating your report.”

In the logs it shows:

lms-worker_1     | 2022-04-15 16:25:04,751 WARNING 163 [edx.celery.task] [user None] [ip None] tasks_base.py:96 - Task (059465c9-ac4a-46e1-bf7a-ecc90890873b) failed
lms-worker_1     | Traceback (most recent call last):
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
lms-worker_1     |     R = retval = fun(*args, **kwargs)
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
lms-worker_1     |     return self.run(*args, **kwargs)
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 179, in new_function
lms-worker_1     |     return wrapped_function(*args, **kwargs)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks.py", line 180, in calculate_problem_responses_csv
lms-worker_1     |     return run_main_task(entry_id, task_fn, action_name)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/runner.py", line 120, in run_main_task
lms-worker_1     |     task_progress = task_fcn(entry_id, course_id, task_input, action_name)
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/grades.py", line 995, in generate
lms-worker_1     |     student_data, student_data_keys = cls._build_student_data(
lms-worker_1     |   File "/openedx/edx-platform/lms/djangoapps/instructor_task/tasks_helper/grades.py", line 922, in _build_student_data
lms-worker_1     |     for username, state in block.generate_report_data(user_state_iterator, max_count):
lms-worker_1     |   File "/openedx/edx-platform/common/lib/xmodule/xmodule/capa_module.py", line 481, in generate_report_data
lms-worker_1     |     correct_answer_text = lcp.find_correct_answer_text(answer_id)
lms-worker_1     |   File "/openedx/edx-platform/common/lib/capa/capa/capa_problem.py", line 554, in find_correct_answer_text
lms-worker_1     |     return xml_element.xpath('@correct')[0]
lms-worker_1     | IndexError: list index out of range
lms-worker_1     | 2022-04-15 16:25:04,757 ERROR 163 [celery.app.trace] [user None] [ip None] trace.py:255 - Task lms.djangoapps.instructor_task.tasks.calculate_problem_responses_csv.v2[059465c9-ac4a-46e1-bf7a-ecc90890873b] raised unexpected: IndexError('list index out of range')
lms-worker_1     | Traceback (most recent call last):
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 412, in trace_task
lms-worker_1     |     R = retval = fun(*args, **kwargs)
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/celery/app/trace.py", line 704, in __protected_call__
lms-worker_1     |     return self.run(*args, **kwargs)
lms-worker_1     |   File "/openedx/venv/lib/python3.8/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 179, in new_function
lms-worker_1     |     return wrapped_function(*args, **kwargs)

Is this a known error? Any workaround?

Update: After a little testing, I found that it seems like if this only occurs if there’s a dropdown problem type for which there is no correct answer specified. In my case I’m trying to get students to enter in how long it took them to complete a section, so there’s no correct answer. So I worked around this by just setting a “correct” answer, and then the problem report generation works again. Leaving this here for future googlers…

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.