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
200 stars 117 forks source link

A "debug" function to render any JME type as a string #851

Closed christianp closed 9 months ago

christianp commented 2 years ago

Could be useful while debugging marking algorithms - feedback(debug(obj))

christianp commented 1 year ago

The request to show an expanded view of values in the editor in numbas/editor#493 would make debugging marking algorithms easier, but it's worth adding this function, too.

debug might be too ambiguous; maybe debug_string?

christianp commented 1 year ago

@Lycanic - this would be a good issue for you to try when you're ready to do some work on Numbas internals.

Lycanic commented 9 months ago

Taking a look through some issues and this one intrigued me (/seemed possibly viable)

Things I wanted to check: a) Is this still a desired function (I notice the referenced other issue is closed)? b) what is an intended use/example? c) are the items 'tokenToDisplayString' and 'typeToDisplayString' in jme.js relevant?

(Example for b: is what we want that "Numbas.jme.debug_string(Numbas.jme.compile('expression("x+y")'))" would resolve to "Expression: 'x+y'"?, or is that completely off the mark intention wise?)

christianp commented 9 months ago

Suupose I have a question variable direction := vector(1,2,3). I'd like to be able to write a JME expression in another variable's definition, or in a content area, showing the JME representation of direction: debug_string(direction) should return "vector(1, 2,3 )".

Internally, the debug_string function should call Numbas.jme.display.treeToJME({tok: tok}), where tok is the argument.