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

Mathematical expressions are marked correct if they aren't #788

Closed YannickNeyt closed 3 years ago

YannickNeyt commented 3 years ago

I have an inequality I'd like the students to simplify, but it does something unexpected.

image

Something like 5>=x also gets marked as correct, while something as -3>=x gets marked as incorrect.

image

The question itself: https://numbas.mathcentre.ac.uk/question/84481/test-ongelijkheden/

YannickNeyt commented 3 years ago

I think I found my mistake: I have to use the accuracy tab to fix this.

Is it possible to let it check all integers between -10 and 10 (once) though?

christianp commented 3 years ago

Marking inequalities is difficult: the standard marking algorithm checks numerically, which doesn't work particularly well for boolean expressions like this.

You can check a fixed set of values with a custom marking algorithm, redefining the vset note to contain all the values of x you want to check:

vset:
   map(["x": x], x, -10..10)

But that doesn't work when the student has a non-integer on the right hand side of the inequality.

This question is really about the form of the student's answer, so you should use a pattern restriction. A pattern of

x <= (`+- $n);rhs

would check that the student has simplified the inequality as far as you know they can. You can then set Numbas to check only the number part, which will require the student's number to be exactly the same number as in your expected answer.

I've made a copy of your question which does this at https://numbas.mathcentre.ac.uk/question/share/view/e1a6230b-acea-4aea-a57c-68ebf5e296a9