I am working on a custom wrapper/template grader API for our Java (class or method) CodeRunner quizzes, to simplify the generation of custom result tables (especially considering that JSON outputs are notoriously difficult to generate in Java). The exact API isn't really relevant, the point is that the question author can use it to define outcomes of dynamically generated test cases and how they should be presented.
I would like to build the API in such a way that I can migrate existing questions easily. Currently, very few of our questions use the built-in test cases, so most of the testing logic is in the question template code.
In my "ideal scenario", I would define the custom grader class in a prototype question, change the existing question to that new prototype without losing the customization, and have access to the custom grader in the question template, perhaps by including a new Twig variable. I realize that it probably isn't quite that easy.
The main point is that I would like to define the custom grader so I can share it across all questions with a prototype, but also have custom template code for each individual question. I've considered moving the existing template code into globalextra, but without the Ace editor that would make it quite tedious to edit question templates later on. I've also considered putting the custom grader in a support file, but those cannot use Twig variables (and couldn't be updated easily if necessary).
Is this at all realistic? Is there maybe an entirely different approach to accomplishing this that I should consider instead?
Thank you very much for any advice!