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:
factorise(n)returns a list of the powers in the prime-power decomposition of $n$ (the simplest way I could think of to represent a factorisation as a list)
distinct(list)returns a copy of the input list, with duplicates removed.
singularif $n$ is 1, and
lcmnow takes any number of arguments, and returns the lowest common multiple of all of them.
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.
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!
variables dictionary. The objects in
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
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.
- 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.