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

If you include an HTML variable in an MCQ choice, it only appears in the "expected answer" version #886

Closed christianp closed 2 years ago

christianp commented 2 years ago

HTML elements aren't copied when they're inserted into the display, so that event handlers are preserved and any other code that keeps a direct reference to the element still works.

This is a problem when inserting an HTML value into an MCQ part choice, because the "expected answer" box also needs to display the same choice.

Could elements be duplicated before insertion into "expected answer", on the assumption that they don't need to be interactive? I suppose it's possible that an element could have some kind of animation that you'd still want in the expected answer area.

christianp commented 2 years ago

Just duplicating the element doesn't work: the JSXGraph extension waits until the element is inserted in the page before it starts drawing it, so the copy looks blank.