I actually had two chemistry teachers in high school who fit this description. The first was a drunk that they hired off the street (seriously, the administration not believe us until we found an empty whiskey bottle in the back cupboard). They replaced her the second quarter with a flighty woman who didn't understand the material and regularly lost our assignments and tests; some time after they fired her I saw an article in the variety section of the local paper showing her in her home, back to the camera, with her hands on her hips staring at the massive pile of junk in her house—it was an article about ADHD adult packrats. For the final quarter they put us in a real chemistry teacher's class, where none of us were at all prepared having learning nothing for the first 2/3rds of the year, and they had to just give us the credit for the year.
The point of this anecdote is that there were plenty of smart, motivated students in this class, but the teachers made it impossible to learn, so the performance of everyone was equalized to the lowest common denominator. The only people who learned anything were the ones willing to read the book for its own sake without any guarantee of proper labs or tests. The next year I got into the physics class of a teacher who was widely regarded as the best in the school. We learned a lot in that class, but even there you had problem kids who refused to make any effort, despite the fact that the teacher clearly cared about the students; they saw him as someone to be taken advantage of.
So you see, neither factor stands alone. You need decent teachers, and you need kids to show up.