There is no cap on how many times you can retake the exam. You can go as many times as you want.
In regards to classes, I took School Of PE online courses. It helped to pass the NCEES exam (structural) at the first attempt, but it looks that I failed for the second time the surveying or seismic...