Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow simple form input elements within parts of equations #3338

Closed
sangwinc opened this issue Feb 27, 2025 · 3 comments
Closed

Allow simple form input elements within parts of equations #3338

sangwinc opened this issue Feb 27, 2025 · 3 comments

Comments

@sangwinc
Copy link

I'm the lead developer of the STACK online assessment system (https://stack-assessment.org/) which is a very popular online assessment system for mathematics. Students type in expressions to answer quizzes online, and Maxima (a computer algebra package) is used to assess their mathematical expressions. The system uses MathJax to display mathematics - thank you all for a superb library.

We would like to be able to create questions where students "fill in the blanks". In particular creating part of an expression/equation and have some html form input elements within the mathematical expression for students to type in a simple expression.

We would like support for things like <input type="text" name="q1174:3_ans1" class="algebraic" value="(x-4)^6"> inside a mathematical expression.

For example, we could have a LaTeX command like \forminput{...} which has contents like this

\forminput{<input type="text" name="q1174:3_ans1" class="algebraic" value="(x-4)^6">}

MathJax would render the rest of the equation, but retain the HTML input element box within the equation.

Our alternative currently is to spit up equations, e.g. here the student is expected to type in an integrand:

\( \int \) <input type="text" name="q1174:3_ans1" class="algebraic" value="(x-4)^6"> \( \mathrm{d}x\)

This only works in a small set of circumstances.

This is not a duplicate of this issue: #1831

@dpvc
Copy link
Member

dpvc commented Feb 27, 2025

The page you link to for the STACK assessment tool seems to be using MathJax v2.7.0, which is over 8 years old (the current version is 3.2.2, with v4.0 out in beta release). So I assume you are looking for a v2 solution? If you are planning to stick with v2, you should at least update to v2.7.9, the most recent version of v2.

In versions 2 and 3, you can not have HTML element directly within a LaTeX expression, so your request for \forminput{<input ... >} would not be possible. (In version 4, you can have HTML embedded in LaTeX, if you are interested in updating to that version. Note, however that the v2 to v3 update involves a significant change to the API, so could involve changes to the code that calls MathJax, depending on how sophisticated your MathJax usage is.)

On the other hand, it is possible to implement TeX macros that include form input elements, and that has already been done. For v2, see the forminput legacy third-party extension. For v3, this StackExchange post shows how to do it. For v4, see the v4-alpha release notes section on HTML in TeX for details of how to include HTML form input elements directly in LaTeX.

@dpvc
Copy link
Member

dpvc commented Feb 27, 2025

duplicate of #2210.

@dpvc dpvc added the Duplicate label Feb 27, 2025
@sangwinc
Copy link
Author

Thanks @dpvc for the comments, and pointing out the duplicate. I did look but didn't spot this! I'll comment in 2210 about the issue.

I'm very happy to upgrade our version if that fixes the issue. Use of an older version is inertia: it's working very well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants