I'm glad they got caught. That will 'teach them a lesson'! [=they will learn that they should not do that again]
We 'learned our lesson' the hard way. [=we learned from an unpleasant experience]
They studied the 'lessons' [='teachings'] of the great philosophers.
(..) rules will be put into effect immediately: ''All students will return to their house common rooms by every evening. All students will be escorted to each lesson by a teacher. No exceptions. '' l should tell you this: Unless the culprit behind these attacks is caught. . . (..)2002 Harry Potter and the Chamber of Secrets