Quadrupolar transitions and medium-range-order effects in metal K-edge x-ray absorption spectra of 3d transition-metal compounds