For the purpose of meeting the cross country requirements a student pilot flies to a destination more than 50 nm from the departure point. On the way back he stops at an airport half way between the two. Can he log the whole trip if his second legs were not greater than 50 nm?
I assume you're talking about the "normal" >50 NM cross country and not the special "long" one in 109(a)(5)(ii).
On that assumption, the answer is yes.
Even if he stopped there along the way outbound also.
Look at the definitions in 61.1. The one that talks about a landing >50 NM from the original point of departure does not specify a leg length at all. It uses the words
==============================
That
includes a point of landing that was at least a straight-line distance of more than 50 nautical miles from the original point of departure
==============================
That means that all the flight need to qualify is a landing >50 NM from where the flight started. You can airport hop and land at an airport every 10 NM and, so long as at least one of them was >50 NM from "home" the whole flight counts.
For comparison, look at the long cross country in 109(a)(5)(ii). You'll see that when the FAA wants a minimum leg length, it doesn't have any trouble telling you.