# Numbas

## Development log – July 2014

Development on Numbas continues apace, so I thought it’d be a good idea to start writing about changes in more detail here so they don’t slip by unnoticed.

### New JME functions

I’ve added the following new JME functions:

### Pattern matching

I’ve vastly extended the pattern-matching algorithm (previously only used tom implement simple rewriting rules in the simplification algorithm) so it’s much more versatile. It now takes commutativity of operations into account, and has regular expression-like operators to do things like match any one of several patterns, match the negation of a pattern, and so on. There’s some very light documentation in the editor docs, and I also wrote a less coherent post on my personal blog about the thinking behind it.

### Documentation

I’ve brought the editor and Javascript API documentation up to date with all the recent changes. I’ve also added some information on writing extensions for Numbas.

### Custom scripts

Each part now has a “when the part is created” script, which you can use to do some setup before the student sees the question. You could already do this in the question preamble, but you had to know the position of the part. This allows you to attach initialisation code to the part which doesn’t break when you add, move, or remove parts.

The preamble, and part scripts, now catch errors and display them, instead of just failing silently. This should make debugging a lot easier!

Part scripts can access unwrapped, JavaScript-friendly versions of the question’s variables through the variables dictionary. The objects in question.scope.variables are wrapped up in a form for use by the JME system, which meant you had to do some work to unwrap them to use in JavaScript. The objects in the variables dictionary are unwrapped for you, so you can use them without having to write any boilerplate code at the start of your script.

There are also new variables called part and question, which point to the current part and its parent question. The magic JavaScript this variable already pointed to the current part object, but we felt it was better to use a clearer name.

In the question preamble, I’ve tidied up the methods to run code at different stages during initialisation. Now there are new methods question.onHTMLAttached and question.onVariablesGenerated, which each take a callback function to run once their respective tasks have finished.

### Other changes

• You can produce a normal dollar sign in text, without going into maths mode, by typing \$. Thanks to Joshua Beals for pointing out this was missing.
• I’ve finally fixed the bug which caused the “Saving…” message to get stuck when there’s an error in a question’s variable definitions.

### Documentation

Numbas features full documentation which is always in line with the most recent version.

### Numbas Blog

We regularly update our blog with articles about new and future features, as well as other useful information.