Конечно этот ответ помогает мне

I had the highest mark - У меня высший балл here you need to add in what you have that highest mark.

e.g. У меня высший балл по физике.

I ranked first in the class - What do you mean? A class as in a lesson or as in a group of students? Anyway,
for the group of students - Я был лучшим в классе.
for the lesson - Я был лучшим по предмету. Where предмет represents a class name such as physics Я был лучшим по физике.

I ranked first in the university - Я был лучшим в университете. Or I assume you use that phrase after you graduated from the University so I suggest using this one, which sounds more formal thus more appropriate for such a phrase:
Я был лучшим выпускником университета or Я лучший выпускник университета.

I ranked first in the contest - Я занял первое место в конкурсе. You do realize you need to specify which конкурс you mean?