numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
202 stars 117 forks source link

Permutations extension, creating permutation from list #793

Closed ugoertz closed 3 years ago

ugoertz commented 3 years ago

In the Permutations extension, one can create a permutation by giving a list of numbers, but this list must be "zero-based", i.e., to get the transposition (2,3), say, one has to use permutation([0, 2, 1]). I suggest that this is explained in the documentation. (It might in fact be worth changing this behaviour? But of course that could break existing questions.)

If one creates a variable where 0 (or any "intermediate" number) does not occur, say permutation([1,2,3]) or permutation([0,2,3]), there is an uncaught javascript error (visible in the web developer console) since converting the list into a cycle presentation does not work. This breaks the variable editor (for the new variable, type "permutation" but no value is shown, and creating other variables does not work correctly) without displaying an error message in the Numbas interface.

christianp commented 3 years ago

Thanks for reporting this. I've added a note to the documentation about zero-indexing, and added a few lines to catch errors with badly-defined permutations.