A structured model of the dynamics of student learning in developing countries, with applications to policy