I would like to write a c++ question where automated grading only counts for a fraction the marks. Say 50% of the points are based on the successful completion of test cases and for the other 50%, I would be able to enter a manual evaluation of the optimality or elegance of the code. Is there a way to do that?
You can't do this at present. There has been some discussion in the Moodle tracker (here) and a forum posting on Moodle 4.1 (here) of plans to implement a feature that might help with the problem (though I'm unsure).
For now, you have to use some sort of workaround. For example, you could follow the question with a manually-marked placeholder essay question, which teachers use for the style grading. You might for example ask students to paste their code into the essay question as well as into the correctness-testing question. Or ask them to provide a brief discussion of any design issues instead.
We do the whole process off line - download all the responses plus correctness marks, manually grade with our own system that provides markers with each student's code and a marking rubric, then upload the style marks back to Moodle.