E-assessment of coding theory in Numbas

Christian Lawson-Perfect, Newcastle University


  • Stage 3 coding theory module.
  • Lecturer had 5 written homeworks, very procedural, sick of marking.
“CP, can you help?”

The maths

A code is a set of codewords that are each strings over a finite alphabet (\(\mathbb{Z}_p^n\) for our purposes).

A linear code is closed under addition.

Lots of linear algebra involved: matrices to generate codes, check codewords, etc.


\[ [4,2]\text{-repetition} = \{ \mathtt{0000}, \mathtt{0101}, \mathtt{1010}, \mathtt{1111} \} \]


  1. Receive homework sheets, solutions, and course notes from lecturer
  2. Identify commonly-used routines, bundle them in an extension
  3. Transcribe written questions into Numbas, without randomisation
  4. Add in randomisation
  5. Lecturer tests everything works
  6. Delivered to students!

In practice

Implementing the algorithms was fun.

But YEESH avoiding bugs was hard.

Having a "codeword" as a data type in Numbas made writing questions very easy.

In practice

All but one of the written questions could be marked automatically.

We improved some questions, and added some more formative questions on top.

A couple of bugs found by students - equal mix of my fault and faulty algorithm from the lecturer.

Existing homework sheet

Codewords extension

Adds code and codeword data types,
and functions to work with them.


A = repeat(

basis = identity_left(A)

C = code(set_generated_by(parity_check_matrix(basis)))

min_distance = minimum_distance(C)

Also provides scripts to mark lists of codewords.

Permutations extension

I also used an extension I'd written for a group theory course, which adds routines for dealing with groups of permutations (elements of \( S_n \)).


It helped with things like randomising generating matrices.


codewords extension available to everyone.

20 questions, free to reuse on mathcentre.