Chemical modelling of glycolaldehyde and ethylene glycol in star-forming regions