In a previous paper we studied nonhomogeneous systems of hydrodynamic type,
related to commuting quadratic Hamiltonians with electromagnetic term, giv
ing just a few specific examples. We now consider the problem of characteri
sing the full class of systems arising in our framework, which is equivalen
t to classifying all quadratic Hamiltonians with electromagnetic term, havi
ng a quadratic first integral. We give a complete solution for diagonal sys
tems with 2 degrees of freedom, subject to only one differential constraint
.