course_materials: fix 500 error when no sections (fix #2486)

I got this 500 when looking at the MSandE111 course when they had disabled all sections of the course.  I couldn't reproduce locally, but looking at the code there is an obvious code path where you can have a unset variable, so I figured it was OK to fix.

@natehardison, care to code review?