Characterization of the mod 3 cohomology of E~7