Question Authors' Forum

how to run a simple script (not function)

Picture of Richard Lobb
Re: how to run a simple script (not function)
by Richard Lobb - Tuesday, 4 September 2018, 10:38 PM

I'm not quite sure what you're after here. The documentation explains the architecture of CodeRunner and how question types work in general.

If you want to understand how a particular question is working, you can open it for editing and temporarily check the Customise checkbox. You will then be able to inspect the template that is being used for that particular question. Uncheck it when you're done.

The Twig web site explains how the Twig macro expander (which is what is used to expand the template) works.

If you wish to inspect the actual code that is generated, open the question for editing, check the Template debugging checkbox, save the question, and then run it. The result page will then show you all the code that is being run on the Jobe server.

The template for the standard Python3 question type constructs a program consisting of the student's answer followed by the test code. If that's not what you want (e.g. if you wish to use the test code to define some variables before the student code runs and, say, prints out results that use those variables) you'll have to edit the template to suit. I'd suggest not using a combinator template (i.e., uncheck the Is combinator box), and trying something simple like:

{{ TEST.testcode }}

to get a feel for it. Here's a screenshot of a trivial question written using that template.

The documentation describes how you can define your own question types, so you don't have to customise each individual question.