When I was in undergrad, I found it nearly impossible to study in academic buildings or the school library. There were just too many distractions/temptations. And I couldn't work in my dorm room, even though I often had a single room, because the dorms were loud and again, there was temptation. I often opted to study at local coffeeshops or public libraries. I would try and purposefully go to places where I couldn't get an internet connection unless using the web was imperative for what I was doing. Luckily, I only lived about 75 minutes from my family's place, so I often would spend weekends at home with my family when I really needed to buckle down on a take-home exam or a big project, as nothing beat a quiet room and a never-ending supply of mother's tea
Other times I would just go nocturnal, getting my best work done between 3 and 8 in the morning, when the only other people in the academic buildings at those times were people sharing my strategy. This can suck depending on your daily schedule, but missing a class or two was justified by 5 hours of uniterrupted work the nights before.
In grad school it was sweet, since I shared an office with someone who was never there
In all honesty, if you REALLY feel like you cannot concentrate, and it's worse than the typical college-induced "socialized ADD," then you could talk with your/a doctor about this and see if you have clinical ADD/ADHD. There are plenty of people who can and do benefit from ADD/ADHD medication and/or theropy and are helped by doing so in a *responsible* fashion.
As for actual motivations to find the optimal way to get your work done, well for me I was always extra-motivated knowing that I was bankrolling my own education, and if I didn't pass, I'd be screwing myself financially very badly. Also, during the times that I was in relationships, my partner and I would always want to do well in order to impress each other and such. Maybe find a girl you like, and convince yourself that she'd be attracted to a smart and sucessful version of you? On a more light-hearted note, make an agreement with a buddy that if you don't get above a certain grade on a test or project, then you receive some form of punishment
