The correct option is C The teacher remarked that they had all done very badly.
When a sentence is converted from direct to indirect speech, the present perfect tense of the verb changes into the past perfect tense, if the reporting verb is in the past tense.
Option C is correct because the present perfect form of the verb "have done" changes to "had done" as the reporting verb "remarked" is in the past tense.
Options A, B and D are incorrect as tenses are not in the past perfect form.