-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use an intermediate exam format in rendering code #45
Comments
This will partly be solved by #60. We still use DOM API's in rendering, but afterwards it will run with JSDOM. |
As an alternative or an intermediate solution, we could just add dedicated parser functions for each element type. This way each component wouldn't have to parse the attributes manually. As an example function ExamQuestion({ element }: ExamComponentProps) {
const { displayNumber, maxScore } = parseQuestionAttributes(element)
…
} where |
Right now we use
DOMParser
for parsing the mastered exam XML and interpret the document with the help of the regular DOM API. While it is has been quite convenient from a development standpoint, since we have been able to use the full power of the DOM API for free, there are some downsides:querySelectorAll
does not seem to work at all with namespaced XML elements.As an alternative, we could translate the XML document to a JSON format, which would contain Elements and Nodes just like a regular XML document. That is, it would be isomorphic to real XML.
This would have a few upsides:
The downside (apart from the work required) is that we would have to reinvent the wheel in some respects. We would have to implement our own functions for operations like “get the closest parent element like this” (
Element.closest
) and “query for elements like these in this subtree” (Element.querySelectorAll
).The text was updated successfully, but these errors were encountered: