Hi Kirsty

Out of the box, there's only one Octave/Matlab question type, called *Octave function*.

You can find out a bit more about any selected CodeRunner question type by opening the *Question Type Details* section in the question authoring form and you can see the template that each question type is using by clicking the *Customise *checkbox. In the case of *Octave function*, you'll be told that the question type is experimental and has had very little use, but that's not true any longer. I'll remove that on the next push.

The template for the *Octave function *type is simply

{{ STUDENT_ANSWER }}
format free
{{ TEST.testcode }};

which means that the script passed to Octave for execution just consists of the student's code (whatever they pasted into the answer box), a command to use Octave's 'free' mode for output formatting (see the Octave documentation) and then whatever code you've chosen to paste into each of the *Test case <n>* boxes.

Here's what a trivial "Write an Octave function" would look like to a student:

I attach a Moodle XML export of this question; if you import this and open it you'll see how it's set up.

There are two other Octave question types provided if you import the file *uoc_prototypes.xml *from the *db* folder in the source into the Moodle Question bank. They are called *Matlab function* and *Matlab script*, though the names are slight misnomers as they actually use Octave. [We have several other Matlab question types that we use in-house, but they're way more complicated and not appropriate if you're just starting to use CodeRunner.] The *Matlab function* question type is more-or-less the same as the *Octave function* type except that the template starts with a re-declaration of the *disp* function that more-closely mimics Matlab's *disp* function so that the output the students see in a CodeRunner question is the same as they get (usually) when they run their code in Matlab. It doesn't use Octave's free output format mode.

*Matlab script* is a somewhat different type of question. The question type details for it say "Used for Matlab scripts (so-called). Runs the test code first (which probably sets up a context) and then runs the student's code, which may or may not generate output dependent on the context. Finally the extra code is run (if any)." I rarely use this. It allows you to ask questions of the form *Given variables a and b, write code to compute or print some derived value c*. The test code defines *a *and *b*, the student's code computes or prints *c*. If they just compute *c*, you can put code in the *Extra* field of the question authoring form to display *c* yourself, or check it in some other way. This question type is useful only for introductory questions when students are just learning to write simple assignment statements or expressions. Getting them to write functions early in their course provides a much safer context for feeding input parameters to them and getting printed output or computed return values back again.

If your students are developing in Matlab and submitting code to be graded with Octave, you should be warned that there are a few gotchas, particularly when students submit bad code - Matlab accepts all sorts of rubbish that Octave warns them about. There are also subtle differences in how some functions work and of course most of the toolboxes are missing from Octave. But if your students are using Octave too, none of these issues matter.

You should also be warned that regardless of whether you're using Octave or Matlab, you must be very careful with floating point tests, as the student's full-precision numeric output will only rarely be the same as yours. At very least you need to use *fprintf* to limit the precision to which numeric data is displayed and even then things can go wrong. One of my colleagues has developed an Octave question type that compares all floating point numbers to a specified tolerance, but this is a very complex question type that does lots of other clever stuff as well (e.g. lots of style checking) so ask us about it in a year or so :-) In the meantime, if you run into this problem, you can always write more sophisticated tests that, rather than just printing the student's answer, compare it with the expected output and print a message like YES or NO (so the expected output is then YES).

Hope that's enough to get you going,

Enjoy,

Richard