Both of the ones you have selected are good units, you will always encounter problems in this situation. Zoom as Tascam also make some nice units but much of what I have read about them is in relation to recording things like live concerts.
When you watch those great videos of lectures chances are the speaker is wearing a mic (or at least standing in front of one) connected to the camera. Your best results will come from sitting in the front of the class and getting as close to the source as you can. If you can only sit in the back (or are far away from the source even in the front row) a small shot gun mic pointed at the source will help keep background noise out. You will always be subject to people banging on the table etc. (unless you can prop it up on a stand or something).
The internal mics in these devices tend to be for personal dictation and thus work best when the person is 2-4 feet from them. In that case you may find your self cranking the gain on them which will end in distortion. My advice is to try and find a place that has these units placed out for test. Any audio store (like Guitar Center) or your local shop is generally willing to allow you to run tests on the devices. Try a recording at a solid 30 ft. and see how it comes out.