Mathematical expression test

25 views
Skip to first unread message

David Wishart

unread,
May 28, 2025, 8:30:19 AMMay 28
to Numbas Users
I have a question that tests a mathematical expression but it appears to be allowing almost any possible similar entry as correct. A cut down version is shown below.

I'm sure this syntax has worked in previous similar questions but am a bit lost at the moment as to why this one doesn't.




Laura Midgley

unread,
May 28, 2025, 7:10:04 PMMay 28
to Numbas Users
Because of the way mathematical expression marking works (randomly substituting in variables for i_1 and i_3), both the 'correct' answer and the students' answer are evaluating as 'false' basically every time, so they count as 'agreeing'.

You'll need to follow the docs for Marking an equation and add your own variable value generator.

An alternative is to re-write the question so that it is asking for an expression (eg asking for the left hand side of [LHS]=0), which will then mark as you'd expect.

David Wishart

unread,
May 29, 2025, 4:30:08 AMMay 29
to Numbas Users
Hello Laura,
Thanks for quick reply, certainly your second suggestion works for a quick fix so I'll use that for now but I'll have a look at doing it properly longer term as I'd like to leave flexibility in how the students answer. Much as I teach this question a specific way, there are several methods and I'd prefer not to dictate how they answer.

David Wishart

unread,
Jun 9, 2025, 8:35:26 AMJun 9
to Numbas Users
Following on from this, I've had a look at variable value generators which I've got working but for some reason don't like variable names with numbers in them. This aspect is fine the values that I generate in the question (such as r1, r2, v1 etc) but not for the expression ones. For the example below, part a works fine with x and y as variable names but part b does not with the x changed to x1.


Have I missed something? Ideally I'd like to use i1,i2 etc in place of x/y as the question is electronics based and i1 and i2 are loop currents and use that style notation as standard.

Christian Lawson-Perfect

unread,
Jun 10, 2025, 10:55:49 AMJun 10
to numbas...@googlegroups.com
This was a bug, sorry. Thanks for reporting it!
The root of the problem was that the marking algorithm for mathematical expression parts normalises all variable names, so that names ending in a digit always have a subscript: `x1` is rewritten to `x_1`, for example.
But the editor wasn't aware of this, so you were writing an expression to generate values of `x1`, which was never used. It wasn't applying the other restrictions on variable names either, such as "force single-letter variables".
I've changed the marking algorithm so it normalises names used in the dictionary of value generators, and also changed the editor so it correctly applies all the normalisation rules for the part.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/numbas-users/2188a588-cc96-4716-a4a5-5a4a96f874c5n%40googlegroups.com.

David Wishart

unread,
Jun 11, 2025, 7:50:12 AMJun 11
to Numbas Users
You're welcome, all good now thank-you.
Reply all
Reply to author
Forward
0 new messages