https://github.com/maths/moodle-qtype_stack/blob/dev/doc/en/Installation/API.md
I’ve been getting to grips with both PreText and docker myself. I’ve not had a chance to look at how webwork integrated with PreText in detail yet, but there is a very good prospect of us being able to support STACK question use through the API. I’ll need help in getting this working, especially since I haven’t looked at the “player” website which includes webwork. Would someone be able to give me any pointers for how this works please?"
Many thanks

Thanks Chris, David, Michael. Rob could confirm or correct me, but I think that David's Task 2 would need to be in effect first before PTX developers would invest time in Task 1. Or maybe not. In the past with MOM we essentially had Task 1 first. But that was in the old days, before the CLI, and when it was easier to have an experimental, partly functional feature.
Task 2 sounds like something where there should be collaboration between STACK developers and someone familiar with the PTX XML vocabulary. Just to understand the mapping from STACK source to PTX well.
An aside for Michael: WeBWorK/PG does have the ability to give custom responses to answers. I'm not sure if that's what you mean. But for example the WeBWorK sample chapter has an exercise asking for x^3*x^5, and if you enter x^15 there is special feedback for that. For each "flavor" of incorrect answer, you have to code the response you want (it's not AI). Is that the kind of thing you mean by personalized feedback? If so, send me an example exercise and I can show you how to code it. Or if not, please describe that more so I can confirm WeBWorK/PG can't already do this.
That last paragraph is not to be construed as sidestepping STACK integration with PTX, which would be great to have.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/af63ad90-c1fa-4d21-ae5d-4598e83cec80n%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxMy5iZWV6ZXI.1742525759%40pnsh.
(Copied from the PR)
I've been working on generating static representations for STACK questions. I've written a function as a starting point (to be extended with error handling, etc), and you can test it on the example STACK question by running the stack_to_pretext.py script I added. (Note: The public STACK API server used in this example is a bit temperamental, so if you get an error the first time around, try again.)
I'm trying to figure out how to integrate this into the larger asset generation process. I assume this should happen akin to the webwork_to_xml function which generates the webwork_representations.xml with static and PG versions of the webwork questions. In the STACK case we'll only have the static version (at this point anyway), as for the dynamic version a STACK question XML file will simply be referenced in the HTML. I guess those STACK question XML files would then be assets, e.g. like image files referenced in the text.
The part I don't have a good understanding of is the work done by the XSL templates. For example, in webwork_to_xml, we apply extract-pg.xsl to the input XML and then pick out the server parameters from the resulting XML file (e.g. to get the API URL, which must originate from the publication PTX file), so that we can call the server to retrieve the questions and/or generate the static versions. Obviously, a lot more is going on in that XSL template, most of which isn't applicable to STACK, but I don't understand what I'd need to mirror from there and what to ignore.
Similarly, I don't really understand the work the XSL templates are doing when building a target, such as HTML or pdf. For STACK, all that'd need to happen is either take the static version from the representations file that we generated (e.g. PDF target), or simply insert a single div referencing the STACK question XML file (HTML target), something like
<div class="container-fluid que stack" data-qfile="questions/integrate.xml">
from the example where I embedded an interactive STACK question into HTML generated by pretext, as well as including the javascript headers. (I'll work on improving the actual Javascript logic to make it behave more closely to how webwork questions behave.)
Some pointers how to proceed from here would be really helpful, especially around the XSL templating. (I can make some sense of the pretext and pretext-cli python code if I dig into it a bit, but high-level guidance would still be helpful.)
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/582fca98-4132-4143-8ac4-5c57379ba234n%40googlegroups.com.
We'll need to protect #stack from the #stack already used in side-by-sides.
This should look like how #webwork is structured.
2. Use pretext-html.xsl to turn that into the #div.stack you describe
below, and get a problem to render in HTML output. Presumably the PreTeXt
#stack will have some sort of attribute that has "integrate" or
"questions/integrate" or "questions/integrate.xml", however little an author can
get away with (we provide the rest).
3. Then some XSL to extract whatever is needed to get the server to produce a
static version. I'd use the MyOpenMath (MOM) code as an example, the WeBWorK
(WW) has a lot of extra stuff going on that ight get in your way. Python
applies this XSL, makes requests of the server, packages up static. I think I'd
rather do this as one-file-per-problem, like MOM, not one huge file like WW.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDA0OC5iZWV6ZXI.1751484497%40pnsh.
I see in the PR that this is problem 17332? Is their a server hosted version?
Would source here diverge over time?
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAzMi5iZWV6ZXI.1752460906%40pnsh.
Uncaught TypeError: can't access property "input", MathJax._ is undefined
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxOS5iZWV6ZXI.1752504087%40pnsh.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/CAHDrpCe4NCjb74UcTKK_eCF%2BHtULQC2JSwhaPyPUHrbRFqqD4w%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/CAHDrpCfmiXL3VnKoWuOGsPSyhCVcYz_roRi0A2Q3T9E0YqqJfw%40mail.gmail.com.
* Is there a single canonical world-wide source-of-truth server? (This how we
use Runestone.) I think you would have sent me there if there were.
* If not, are there disparate versions in production use at different locations?
* Do the problem collections differ across server installations?
* Do problems have unique world-wide stable identifiers (17332,
"01_integration_with_feedback")?
* As an instructor can I author a STACK question, put it onto my server, and it
never leaves my institution?
* Maybe the Docker container for use generating static versions answers a lot
of these questions (and maybe you already told me that).
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/CAO-sG%2B2Dz9Uyrpf%3DZ%2BVmLFHpK8-3pZPt4bk74hbF29WnvSVW%2Bw%40mail.gmail.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/CAHDrpCcn%2BYQWz09kYMWgczurWFHFduzi7%3DW4Coa0PES_qa%3D4JQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAzNC5iZWV6ZXI.1755310321%40pnsh.
--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/51e4c1f0-7c90-482b-a655-c565bfe7e3e8n%40googlegroups.com.
Dueling MathJax.
Static: the #fillin created for an answer blank needs to be an empty element.
Invalid XML as it is now.
Figure out why we have to ask for a new question, and do not get an initial
version with the loaded page.
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyNy5iZWV6ZXI.1755627004%40pnsh.
Some PreTeXt warnings about coincidental elements (#input for one) went away
when I added a namespace. The PreTeXt schema should get more attention than it
does, but I think we'll be able to separate a STACK schema from the PreTeXt one
via namespaces.
Georg provided two Javascript files, and I don't really have the skills to know
everything they are doing. But they interact with MathJax. For example,
"stackapicalls.js" has a line that looks like:
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
Not sure if this is re-purposed JS, or one-off JS for PreTeXt support. In any
event, maybe this is v2 syntax not supported by v3, or it is assuming a
different configuration, or I don't know what. We have an extensive
configuration - for example we output HTML where all the math/LaTeX is already
marked with spans and divs (since we know it comes only from #m, #me, #md,...)
and then we tell MJ that it does not have to parse the page any more than
looking for these spans and divs. When you show a preview of a student's input
for an answer, maybe you are inside an iframe doing mathJax rendering
on-the-fly? I'd guess that where maybe we need to coordinate?
YAML? That's new (or another thing I've forgotten about). Having questions as
XML is a huge plus. A text version gives us little room to maneuver. I already
have to fight the slow creep of JSON! In any event, it is easy to "see" that
the current version has a #question element (say) and know what sort of XML it
is. This is the sort of visibility we lose with plain text. The whole point of
choosing XML is in part so we don't have to parse LaTeX (yet anothr markup
language).
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAwMS5iZWV6ZXI.1755880387%40pnsh.
I have tidied up the publisher variable for the server. Within the XSL you
should now find the (global) variable $stack-server is available and is set
for the sample article.
--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxNy5iZWV6ZXI.1755904445%40pnsh.
--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/CAO-sG%2B0Zhg53dcpArjApkV9XxoMV1aeiinOLEkXzzms3rh-zzQ%40mail.gmail.com.
This is the only issue that really concerns me. We need to identify just where
this is happening. If the pre-processor is working too hard (too many XML
elements overall), with a namespace we should be able to short-circuit that.
INFO : XSL conversion of ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/source/main.ptx by ~/.ptx/2.28.3/core/xsl/pretext-html.xsl
XSL conversion via ~/.ptx/2.28.3/core/xsl/pretext-html.xsl of ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/source/main.ptx to None and/or into directory /tmp/ptx-42pjqwuk with parameters {'cli.version': '2.28', 'rs-js': 'prefix-runtime.9f7f6b353cd8c357.bundle.js:prefix-723.3e6434f80549315a.bundle.js:prefix-runestone.629fdbd852876870.bundle.js', 'rs-css': 'prefix-723.3bccd435914aa0ff.css:prefix-runestone.557d81b04b3ec0e4.css', 'rs-version': '7.9.13', 'publisher': '~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/publication/publication.ptx'}
Because the XML for the question is no well-formed? Need to know more about why
this is happening.
INFO : XSL conversion of ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/source/main.ptx by ~/.ptx/2.28.3/core/xsl/extract-latex-image.xsl
DEBUG : XSL conversion via ~/.ptx/2.28.3/core/xsl/extract-latex-image.xsl of ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/source/main.ptx to None and/or into directory /tmp/ptx-dhhc_qz9 with parameters {'cli.version': '2.28', 'publisher': '~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/publication/publication.ptx'}
INFO : messages from the log for XSL processing:
INFO : * failed to load external entity "~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/generated-assets/stack/syntax-equation.ptx"
...
INFO : * failed to load external entity "~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/generated-assets/stack/graph-analysis-hyperbola-and-intersecting-lines-with-b-0.ptx"
ERROR : processing with ~/.ptx/2.28.3/core/xsl/extract-latex-image.xsl has failed
ERROR : Unable to generate some latex-image assets:
Cannot resolve URI ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/generated-assets/stack/graph-analysis-hyperbola-and-intersecting-lines-with-b-0.ptx
DEBUG : Cannot resolve URI ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/generated-assets/stack/graph-analysis-hyperbola-and-intersecting-lines-with-b-0.ptx
Traceback (most recent call last):
File "~/projects/stack/pretext-cli/pretext/project/__init__.py", line 1057, in generate_assets
core.latex_image_conversion(
File "~/projects/stack/pretext-cli/pretext/core/pretext.py", line 628, in latex_image_conversion
xsltproc(extraction_xslt, xml_source, None, tmp_dir, stringparams)
File "~/projects/stack/pretext-cli/pretext/core/pretext.py", line 5167, in xsltproc
raise (e)
File "~/projects/stack/pretext-cli/pretext/core/pretext.py", line 5163, in xsltproc
raise (texc)
File "~/projects/stack/pretext-cli/pretext/core/pretext.py", line 5126, in transform
result_tree = xslt(src_tree, **stringparams)
File "src/lxml/xslt.pxi", line 576, in lxml.etree.XSLT.__call__
File "src/lxml/etree.pyx", line 349, in lxml.etree._ExceptionContext._raise_if_stored
lxml.etree.XSLTApplyError: Cannot resolve URI ~/projects/stack/textbook/pretext-repos/Ethiopia-University-Basic-Maths/generated-assets/stack/graph-analysis-hyperbola-and-intersecting-lines-with-b-0.ptx
CRITICAL: There were errors during the build. See above.
Not sure these are really schema warnings. An HTML build does not validate the
source. Can you provide a better transcript of what you are seeing? If
namespaces are involved, let's get that right first.
WARNING : * PTX:WARNING: There are apparent XML elements in locations that should be text only (8528 times).
WARNING : * PTX:WARNING: There is an apparent XML element (<name>) inside an <input> element, which should only contain text. Using an escaped "less than" ('<') might be the solution, or using a CDATA section.
Speculation: there is an "exercise" element inside the question's XML?
Numbering can pick up "phantom" elements (like a "table" present in HTML used in
an #interactive) when counting instances. This is a good example of why
namespaces are necessary.
--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxMS5iZWV6ZXI.1760479003%40pnsh.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAzOS5iZWV6ZXI.1760628989%40pnsh.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxMi5iZWV6ZXI.1760639989%40pnsh.
find stack/ -not \( -name .svn -prune -o -name .git -prune \) -type f -print0 | xargs -0 sed -i "s|<quiz>|<quiz xmlns=\"http://stack-assessment.org/2025/moodle-question\">|g"
Minimal STACK article - this is nice to have. But I want to test with the
sample article since that is where we will see any bad interactions, like
Checkpoints' numbers advancing by two. So I will let you manage this as you wish.
[...]
That PR is about relative links to things like plots associated with a problem
(I think). When something like this changes, it would be good to add an example
that stresses the changes. And now the sample article is ready to receive such
a thing. This will make it valuable for testing.
--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxNS5iZWV6ZXI.1760825090%40pnsh.
I think we can alleviate most of the problems by having a #stack-moodle element
that lives in the "main" source file (replacing #stack) and surrounds the
#xi:include. Then the @xmlns can go on #stack-moodle. You should be ble to go
back and forth. [...]
Would you like to make a PR to make the necessary adjustments? It'll give you a
chance to touch some of the relevant XSL. I'll test with diffs of before/after
versions of the HTML and LaTeX, so make sure you use that to guide your work.
I think having all the questions come to you in one file is a
problem you'll need to script a solution for.
Won't know until we get there. ;-) This is more about philosophy and
consistency. I'd base64 PNG images and have them in source if I didn't think
that was a bit over the line.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAwMi5iZWV6ZXI.1761235938%40pnsh.
First experiment: run pretext/pretext with the format (-f) set to
"assembly-static" and/or "assembly-dynamic". This is the pre-processor, which
should ordinarily only take about 10% of total time.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/gkZ4sSj8nVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxOS5iZWV6ZXI.1761576649%40pnsh.