Sorry Pascal but I don't plan on changing the current randomisation capability. I accept that Twig has its limitations but it's the template language used to expand the question template and all other components of the question including the question text and all test cases (if TwigAll is set).
There are usually ways around the sort of problem you describe. For example:
- Precompute a list of parameter sets (e.g. a, n and the answer b in your example) and pick one at random. Just don't precompute too many possibilities or you'll find Twig bogs down at the start of test, processing the large lists you've given it. For your example question you could precompute a triangle of modular inverses as at https://oeis.org/A102057 and then just generate random row and column indices.
- Generate the question parameters (a and n in your example) and let the grader determine if the answer is right. In a simple case like your example, if the student's answer is b, the grader need check only if (a * b) % n == 1 to determine if the answer is right.
- As an extension of (2), use a template grader so that the Expected column of the result table can be filled in, too.