Comment 1 for bug 484485

Revision history for this message
Douglas Cerna (replaceafill) wrote :

jelkner's instance for some unexplained reason, has sections with no courses associated. I'll try to find out how this happened.

When the student logins and then hit the "Gradebook" tab, some methods like getSections, getCurrentSection and handleTermChange in schooltool/gradebook/browser/gradebook.py try to convert the section.courses relationship to a list and then access the [0] element to get the course title:

>>> list(section.courses)[0].title

I learned from Ignas that since sections theorically could have several courses associated, you should do something like:

>>> ", ".join([course.title for course in section.courses])

I don't know if it's the solution but it avoids the IndexError. If there is no courses associated, you get nothing as the course title and I can live with that. I'm sending a patch here. The fix for the handleTermChange method should be revised though (that's the only part I'd call a 'hack').