Schoolboy who killed himself did other pupils' homework, court told