Puzzles are only collected when a student successfully completes a level. When a student runs out of JiJis, they are taken back to the beginning of the level without collecting puzzles.
No matter how many times a student plays through a level, they will only collect its puzzles once. This means a student playing games in their History won't collect any puzzles.