Quality control and learning in productive systems