The longest is a student who has been with me for 3 years
The longest = The person who I've taught for the longest = 私が一番長い期間(勉強を)教えている生徒
The longestだけを言ったら、次の部分(is a student who has been with me for 3 years)で意味が分かる。
完全に言うと、The person who I've taught for the longest is a student who has been with me for 3 yearsになりますが、ちょっとくだくだしいのでThe longestだけでいいと思います。
ご参考になれば幸いです。