We report on the observation of the magnetic quantum ratchet effect in graphene with a lateral dual-grating top gate (DGG) superlattice. We show that the THz ratchet current exhibits sign-alternating magneto-oscillations due to the Shubnikov-de Haas effect. The amplitude of these oscillations is greatly enhanced as compared to the ratchet effect at zero magnetic field. The direction of the current is determined by the lateral asymmetry which can be controlled by variation of gate potentials in DGG. We also study the dependence of the ratchet current on the orientation of the terahertz electric field (for linear polarization) and on the radiation helicity (for circular polarization). Notably, in the latter case, switching from right- to left-circularly polarized radiation results in an inversion of the photocurrent direction. We demonstrate that most of our observations can be well fitted by the drift-diffusion approximation based on the Boltzmann kinetic equation with the Landau quantization fully encoded in the oscillations of the density of states.