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

Make source file valid markdown #4

Closed
rzach opened this issue May 20, 2020 · 4 comments
Closed

Make source file valid markdown #4

rzach opened this issue May 20, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@rzach
Copy link

rzach commented May 20, 2020

Suggestions: change or expand the accepted input format to be actually valid markdown. This would have the advantage that you could use other tools, such as pandoc, to preprocess the markdown quiz. As it stands, this can't be done because correct answers are indicated by a * at the beginning of the line. text2qti also balks at answers numbered a. instead of a).

(I'm hoping to make use of test2qti for generating test banks. The source will include lots of LaTeX formulas, but I can't use the images currently provided by test2qti. My plan would be to use pandoc to convert the LaTeX to plain HTML or MathML, and then run test2qti on the resulting Markdown.)

@gpoore
Copy link
Owner

gpoore commented May 20, 2020

I would have preferred plain markdown, but given the range of question types that need to be supported, I couldn't come up with a way to do that without making things much more verbose. For example, Pandoc discards literal list markers, so there would have to be another way to indicate correct answers. If you have suggestions for a way to use Pandoc Markdown for everything, without verbose syntax, I'd be interested in considering that as an alternate input format.

For math processing, I'm already extracting all math and processing it into a Canvas rendering URL. If you need that processed in another way instead, that could be added as an alternative to the default. I've expected that in some cases a different approach for LaTeX might be needed, but hadn't actually encountered any yet. What sort of processing does your LaTeX need to give plain HTML or MathML?

@rzach
Copy link
Author

rzach commented May 20, 2020

To indicate correct answers, you could just put that info at the beginning of the question text, e.g., instead of *c) Correct make it c) \* Correct.
You could indicate the start of a new question by a header rather than a list entry. Then you could use the header_attributes syntax of pandoc to add question metadata (e.g., point value, difficulty, question type, etc.).

You might even use three levels of headers for tests, section, and items.

Of course this all depends on what python's Markdown library can do.

As for LaTeX processing, I'd need the QTI XML to have LaTeX either approximated as HTML or converted to MathML. E.g., I'd put \forall x(P(x) \rightarrow (Q(x) \land R(x))) in the source file and run it through Pandoc to get

∀*x*(*P*(*x*) → (*Q*(*x*) ∧ *R*(*x*)))

ie: ∀x(P(x) → (Q(x) ∧ R(x))). But Pandoc also converts to MathML, so if you'd need more complex math, you could get Pandoc to spit out Markdown with embedded MathML. If your LMS has it and plays along, you can use the equation editor to edit the formula afterward. (Brightspace is happy with the MathML Pandoc generates.)

gpoore added a commit that referenced this issue May 21, 2020
…han with a Canvas LaTeX rendering URL (#4); fixed a bug that allowed trailing whitespace to cause incorrect indentation calculations
@gpoore
Copy link
Owner

gpoore commented May 21, 2020

I'm still not convinced that a pure Markdown solution can avoid being too verbose. Question metadata could be handled by attributes on a header or fenced div. The real issue is keeping the list of possible answers separate from the question itself, since the question can contain arbitrary content including lists. A logical approach would be to use a fenced div for the question, and another fenced div for the list of possible answers, or a header before the question and a fenced div around the answers, or a header before the question and a subheader before the answers. That, plus something like \* to indicate the correct answer, is more verbose than I want to deal with--and that's before handling questions other than multiple-choice. However, if someone ever does want to create an equivalent of quiz.py that is based off pure Pandoc Markdown, I'll be happy to accept a pull request for an alternate input format. Once Markdown is converted to HTML and that is divided up into the different elements, all the XML generating code for QTI could be reused.

In the last commit, I've added a new option --pandoc-mathml that converts all LaTeX to MathML via Pandoc. It looks like Pandoc is one of the best options for doing the conversion, and there doesn't seem to be anything comparable that's pure Python. This uses a cache file to minimize overhead. It actually works with Canvas, so that will probably give you what you need for your system.

@rzach
Copy link
Author

rzach commented May 21, 2020

Amazing, thank you!

@gpoore gpoore added the enhancement New feature or request label Jul 4, 2020
@gpoore gpoore closed this as completed Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants