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
203 stars 118 forks source link

"Flat fractions" display flag #626

Closed christianp closed 4 years ago

christianp commented 5 years ago

A display flag to render fractions on one lines.

When enabled, fractions should be rendered in LaTeX as \left. numerator \middle/ denominator \right.

The numerator and denominator would sometimes need brackets - we can reuse the logic from treeToJME, since that's on one line.

MatthewBosek commented 5 years ago

Hey, can I work on this ticket?

christianp commented 5 years ago

@MatthewBosek yes, thanks! Have a look at our page on contributing to Numbas for info on setting up a development environment: https://www.numbas.org.uk/contributing-to-numbas/#contributing-code Submit a pull request when you've got something for us to look at, and please ask if you need any help.

MatthewBosek commented 5 years ago

@christianp Hey, I think I bit off more than I could chew. I have been reading through the documentations and have a few questions. I'm not sure how to go about this or what classes/ methods I would be updating/changing. What is a flag? How is the flag enabled? What is a tree? Will I be updating the jme_display_settings with the new flag? If you have any additional items or insight to help clarify, it would be most appreciated!

christianp commented 5 years ago

Display flags are boolean values which change how mathematical expressions are displayed. They're defined in jme-rules.js in the object Numbas.jme.rules.displayFlags.

Authors turn the flags on by listing them in the optional argument to the \var and \simplify LaTeX macros. In code, you can call Numbas.jme.display.exprToLaTeX with a list of rules, e.g. Numbas.jme.display.exprToLaTeX('3/5',['flatFractions'],Numbas.jme.builtinScope).

JME expressions are parsed into an abstract syntax tree - a structure starting from a root node, which links to child nodes. Each node is either a function, operator, or a value such as a number or string.

The jme_display_settings typedef is for documentation, listing the possible display flags. You should add flatFractions to it.

I hope that helps, and that you've got enough to have a go at this issue. But if it's too complicated, that's fine.

tpilewicz commented 4 years ago

Hey, I have some time to work on this, may I? @MatthewBosek are you still on it?

christianp commented 4 years ago

@tpilewicz I never heard any more from @MatthewBosek. I'll be happy to look at anything you come up with.

tpilewicz commented 4 years ago

Cool I'll give it a shot then