While going thru the second link, I found: "Turn on the Twig All checkbox, so that all fields of the question will get processed by Twig, once the template parameters have been set up." Where can I find this checkbox?
It's in the topmost panel of the question authoring form, as shown in the figure below. However, it's a new feature and may not be in your version of CodeRunner. It's only relevant when you're randomising questions, so if this is still about adding prolog to CodeRunner you can ignore it.