Member of the e-learning unit in Newcastle University's School of Mathematics and Statistics.

Lead developer of Numbas.

I'm happy to answer any questions - email me.

Browse Christian's content


Christian's activity

Picture of Christian Lawson-Perfect

Christian Lawson-Perfect commented on Exploration activity: Define a class, add methods to it, then use it 3 years, 10 months ago

I've made this a bit more complete. Now there are two parts about adding methods, and a final part where you have to use them.

I've put the validation tests in variables, so each part uses the last part's tests plus some new ones.

Picture of Christian Lawson-Perfect

Christian Lawson-Perfect commented on Make a plot 3 years, 10 months ago

I've written a generic r_load_files function to load a list of files out of the webR environment. For pdfs it returns a blob URL; for everything else it returns the contents of the file as a string. This is a promise, so you can use it as a pre-submit task; it fills in the entry 'r_files' in the pre_submit note.

I made the feedback() marking function take HTML, so you can display the plot in the feedback without any magic.

The blob URLs won't work in suspend data. We need a reliable way of serializing file binary contents to strings. base64 encoding is the only thing i can think of at the moment.

The load_files function should be built in to the extension, and work for whatever language runner.

Picture of Christian Lawson-Perfect

Christian Lawson-Perfect on Exploration activity: Define a class, add methods to it, then use it 3 years, 10 months ago

Gave some feedback: Needs to be tested

Picture of Christian Lawson-Perfect

Christian Lawson-Perfect commented on Sum of triangular numbers (with optional steps) 3 years, 10 months ago

I've fixed the expected answer display.

You need to be careful when testing numpy arrays. When a and b are arrays, a == b returns an array, not a bool.

So, to test if two arrays are equal, you need np.array_equal(a,b).

Also, Pyodide doesn't seem to be able to post numpy values back from the worker, so you need to return a Python built-in type. I've added a special case checking for the numpy.bool_ type, because wrapping every test in bool() would get boring quickly, but you can't pass back numpy.array or numpy.int64/float64.

Picture of Christian Lawson-Perfect

Christian Lawson-Perfect commented on Exploration activity: Define a class, add methods to it, then use it 3 years, 10 months ago

Does it matter that the student is free to change their original class? I suppose refactoring is a natural thing, and they shouldn't be put off doing that.

Another way to do this would be to put the student's answer in the preamble, and ask them to make a class RectangleWithArea(Rectangle), inheriting from their previous one.

Picture of Christian Lawson-Perfect

Christian Lawson-Perfect commented on Exploration activity: Define a class, add methods to it, then use it 3 years, 10 months ago

I've changed the placeholder option for the widget to render(settings["placeholder"]), so it subs into curly braces.

Christian Lawson-Perfect created Filter a list 3 years, 10 months ago

Christian Lawson-Perfect published Assign a variable 3 years, 10 months ago