The second factor is to be taught of right things - the first principles, fundamental ideas with no nonsense examples. This is why classic MIT or Berkeley Scheme courses based on SIP were wastly supervisor than modern "pragmatic" Python or Java crap. Brian Harvey's CS61A is a gold standard.
Schedules and grades are of second importance. The proof is all these self-educated people who picked up knowledge without attending any high school. Moreover, in many cases a municipal primary school, being much like an overcrowded prison-like facility for kids from impoverished families, did more damage than good by imposing wrong habits and impressions of what education is about.
Learning is a continuous and natural process for us and other higher animals. Removal of obstacles, distractions and idiots and exposure to right principles and ideas will do much more than all the micro optimizations combined. "Good schools", like MIT or Yale proved it many times.
There is also Pirsig's book.