If you don't loan money to friends, this sounds like the worst loan conditions ever, don't do it. It's like loaning money to friends but worse. "A commitment to learning how to code" is a pretty subjective loan repayment/forgiveness condition, now you're in the position of judging whether he _really_ demonstrated that commitment. This is even _more_ complicated to your friendship than a straight loan.
Who knows if he really has motivation to learn to code at all, or is just doing it to get your money. Without his own internal motivation, learning is not gonna work. But even if he has internal motivation, this is still like loaning money to friends but worse.