If you only work hard when you find the class interesting, or you like the teacher, or the subject is something you can use (or all of the above), how brightly do you shine when you get what you claim to enjoy?
The best strategy is to find a way to do the work you’re capable of doing. But if you insist on limiting your efforts to ideal scenarios, turn those ideal scenarios into remarkable work.