Children who lived in overcrowded or damp homes missed three weeks more school than other pupils over the course of their education, a study has found..