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
205 stars 120 forks source link

Creating questions with intervals as answer (and built-in syntax help) #879

Open jhoobergs opened 2 years ago

jhoobergs commented 2 years ago

It currently seems impossible to allow answering a question with an interval (open, closed, half-open) without doing pattern matching? The pattern matching solution is not ideal because it makes it harder to allow variables and infinity.

The notations for the intervals that are used according to wikipedia are

notations-image

So the only difference is using square or round brackets for the open intervals. In Belgium we use the square brackets (as opposed to England I guess?), so I would like both options to be allowed / possible.

Adding intervals to jme seems useful? Or is it already possible somehow?

christianp commented 2 years ago

Interval notation is one of the use cases in #677. Because brackets have a different meaning, it needs a specialised parser. You'd have to decide just how complicated you want it to get: should you accept only expressions consisting of a single interval, or should you try to allow interval notation as part of a larger expression?

If you feel like having a go, the class Numbas.jme.Parser is written in a way that you can extend it and change the way tokens are handled. I think you'd just have to change the entries for brackets in the shunt_type_actions dictionary.

jhoobergs commented 2 years ago

@christianp Would it for interval notation be useful to just create jme functions: closedinterval(a, b) (for [a,b]), lopeninterval(a,b) (for ]a,b]), ropeninterval(a,b) (for [a,b[) and openinterval(a,b) (for ]a,b[)? This would remove the problem of the different notations and allow for a display style to show it with round or square brackets.

It might be better to just name them closed, open, lopen and ropen.

christianp commented 2 years ago

Yes, you could do that, but I'm not keen on asking students to write function names they're not used to. We have enough trouble with reminding students how to writesqrt(x).

jhoobergs commented 2 years ago

Maybe it is an idea to add a "quick start guide" to the default template that shows how to enter certain things when they don't know how to? It would be a simple help butten that shows an overlay with commands like:

This way, it is not really about remembering, but just about looking it up. It would also remove quite some duplicate explanation that we do for certain questions.

christianp commented 2 years ago

I thought we already had an issue for that, but I can't find it.

Actually, now I think about it, we talked about this a while ago and decided it would get too complicated: because of the huge range of contexts Numbas is used in, you'd want to let the exam author decide what it contains, so that students don't see masses of irrelevant information, and they're not missing anything provided by extensions.

It might be worth having an area for a help sheet in the interface, and the ability in the editor to create reusable templates so you don't have to copy and paste your help sheet into every exam.

jhoobergs commented 2 years ago

What do you think of the following:

This way, the question authors don't need to think about how they will show the explanation, but just which commands need to be explained.

christianp commented 2 years ago

I don't think this is enough to be useful: custom part types and extensions would either need to be missing from this list, or would have to be able to define their own items for the list. And even though the function names are the same, different people might choose to describe them in different ways.

For example, for children first encountering square roots, you might just describe sqrt(x) as

The square root of $x$, $\sqrt{x}$.

For maths undergraduates, you might be more precise:

The principal square root of $x$, $\sqrt{x}$. If $x$ is negative or complex, the complex root with positive imaginary part is returned.

jhoobergs commented 2 years ago
Well. as explanation I was thinking more in the way of showing the mathematical signs, instead of the meaning of the command. command meaning name
sqrt(x) √x square root
lopen(a,b) (a,b] left open interval

I get that it would be hard to make this usable for all extensions and custom part types. However, I do think that it would already be useful to help students insert their solutions if there is some table showing the builtin commands. In the ideal situation a table that only shows the commands that they might need in the exercise.

This would be mainly to solve the problem of students forgetting to use sqrt(x) for the square root of x. When a student asks this question, you just point them to the "notations help".

If you want to solve this for custom part types and extensions as well, those extensions would need to be able to specify this kind of table data for themselves.

christianp commented 2 years ago

It's the "meaning" and "name" columns that will be hard! Intervals are a very good example: the notation isn't the same everywhere, and it doesn't just depend on the interface language.

More examples from memory:

jhoobergs commented 2 years ago

Isn't that what display options (https://numbas-editor.readthedocs.io/en/latest/simplification.html?highlight=displaystyle#display-options) are used for? Currently Numbas uses \pmod to display mod, so there isn't really support for the other ones yet?

Maybe the notation help could be shown at the level of the jme input field (in the jme part type). This way to notation used in the table will be the same as shown in the preview when typing.

christianp commented 2 years ago

I don't think we've written a question where the student would have to write mod(..) in their answer yet. If we did, the preview would have to match the notation used in the prompt, which the current lecturer says is [a]_{b}.

If the syntax help is defined at the level of the part input, and could be different for two parts in the same question, this doesn't feel like it's saving any work or making things any clearer than the author writing a hint in the prompt.

christianp commented 2 years ago

Thank you for your continued engagement on this and good suggestions, but I really can't see how it would work well.

jhoobergs commented 2 years ago

No problem, it is indeed quite difficult 😅