Study hard so you don't fail.

Literal

Fail-not-so-as-to hard-ly-[adverbial-に] study.

一生懸命に adds an explicit に to mark the adverbial, where bare 一生懸命 would also work as an adverb. Both are grammatical — the に version is slightly more emphatic/formal. 一生懸命 is a special case that floats freely between adjective-like and adverb-like usage. 落第する ('fail an exam / fail a grade') is the formal academic verb.