The weighted average of the numbers of primitive solutions of a quadratic Diophantine equation in four variables connects with the mass of the special orthogonal group of a ternary quadratic form relative to a certain open subgroup, through the mass formula of Shimura. With the determination of suitable group indices, the computation of such a mass can be reduced to that of the mass of the genus of maximal lattices with respect to the ternary form. We determine those indices under several assumptions and provide the numerical examples of the weighted averages for a few positive-definite quaternary quadratic forms.