Recent experiments (Guan et al., Phys. Rev. Lett., vol. 116, issue 6, 2016a, p. 066102; Guan et al., Phys. Rev. E, vol. 94, issue 4, 2016b, p. 042802) showed many interesting phenomena on dynamic contact angle hysteresis while there is still a lack of complete theoretical interpretation. In this work, we study the time averaging of the apparent advancing and receding contact angles on surfaces with periodic chemical patterns. We first derive a new Cox-type boundary condition for the apparent dynamic contact angle on homogeneous surfaces using the Onsager variational principle. Based on this condition, we propose a reduced model for some typical moving contact line problems on chemically inhomogeneous surfaces in two dimensions. Multiscale expansion and averaging techniques are employed to approximate the model for asymptotically small chemical patterns. We obtain a quantitative formula for the averaged dynamic contact angles. It describes explicitly how the advancing and receding contact angles depend on the velocity and the chemical inhomogeneity of the substrate. The formula is a coarse-graining version of the Cox-type boundary condition on inhomogeneous surfaces. Numerical simulations are presented to validate the analytical results. The numerical results also show that the formula characterizes well the complicated behaviour of dynamic contact angle hysteresis observed in the experiments.