Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions doc/guide/publisher/publication-file.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,20 @@
</p>
</subsection>

<subsection xml:id="publication-file-webwork-interactive-processing">
<title>Interactive Processing</title>
<p>The attribute
<cd>
<cline>/publication/webwork/@interactive-processing</cline>
</cd>
can have value <c>webwork2</c> (the default). Once the standalone PG renderer is
better at supporting live rendering, it will also be possible to set this to
<c>renderer</c>. When <webwork/> exercises are <q>live</q>, embedded in HTML, this
is the method that will be used. Either communicating with a <c>webwork2</c> server
or a PG renderer.
</p>
</subsection>

<subsection xml:id="publication-file-webwork-pg-location">
<title>PG Location</title>
<p>The attribute
Expand All @@ -1035,6 +1049,20 @@
</p>
</subsection>

<subsection xml:id="publication-file-webwork-renderer">
<title>PG Renderer</title>
<p>
The URL to a PG renderer instance is in the attribute
<cd>
<cline>/publication/webwork/@renderer</cline>
</cd>
It should include the protocol (e.g.<nbsp/><c>http</c> or <c>https</c>) and not
include a trailing slash. The renderer should use PG 2.19 or later. The default
value is <c>https://webwork-dev.aimath.org</c>. At this time, this is the only
instance of the PG renderer that is configured to work for <pretext/>.
</p>
</subsection>

<subsection xml:id="publication-file-webwork-server">
<title>Server</title>
<p>
Expand Down
98 changes: 50 additions & 48 deletions doc/guide/publisher/webwork.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

<introduction>
<p>
You can embed <webwork/> exercises in your <pretext/> project. This requires using a
<c>webwork2</c> server that is version 2.16 or later. The server could be the AIM <webwork/>
server that has been set up for this purpose, so to get started, there is no need to establish
your own <c>webwork2</c> server.
You can embed <webwork/> exercises in your <pretext/> project. This requires using either a
<c>webwork2</c> server that is version 2.16 or later, or a PG renderer that uses PG 2.19 or
later. Either of these could be AIM servers that have been set up for this purpose, so to get
started, there is no need to establish your own <c>webwork2</c> server or PG renderer.
</p>
<p>
Part of the process can optionally be sped up by using a local copy of the <c>pg</c>
Expand Down Expand Up @@ -177,6 +177,27 @@
</p>
</section>

<section xml:id="webwork-renderer-static-processing">
<title>Using a PG rendering service</title>
<p>
<webwork/> problems can be processed using a standalone PG renderer. At this time, this
feature is under development. There is one functional renderer on an AIM server. We hope to
make the renderer something that is easy for anyone to install at other locations. The
renderer is more lightweight than a <c>webwork2</c> server and runs significantly faster
(although not as fast as using local <c>pg</c>).
</p>
<p>
To use this processing method, in a publisher file, you can set the <tag>webwork</tag> element
to have <attr>static-processing</attr> with value <c>renderer</c>. This will use the AIM
instance of the renderer. When the renderer becomes something you can install on other
servers, you will have another publisher option to specify where it is.
</p>
<p>
At this time, you will still need to use a <c>webwork2</c> server for problems in your HTML
output to render as live interactive exercises.
</p>
</section>

<section xml:id="webwork-server-configuration">
<title>Configuring a <c>webwork2</c> Server for <pretext/></title>
<p>
Expand All @@ -189,7 +210,7 @@
<webwork/> needs to be 2.16 or later for use with <pretext/>.
</p>
<p>
The only thing you need to do at the serverlevel is set the web server to use certain headers
The only thing you need to do at the server level is set the web server to use certain headers
on content that is fetched. These headers tell a web browser that you are authorizing it to
display content from this web server as embedded content inside pages from another web server
(in particular, where you are hosting you <pretext/> book).
Expand Down Expand Up @@ -295,7 +316,7 @@
<q>Allowed to view course home page</q> which should also be set to <c>login_proctor</c>.
</p>
<p>
In the Accounts Manager(Classlist Editor in older versions of <webwork/>), add a user named
In the Accounts Manager (Classlist Editor in older versions of <webwork/>), add a user named
<c>anonymous</c> (again, you could use some other name), and set that user's permission level
to <c>login_proctor</c>, the permission level one higher than <c>student</c>. Set that user's
password to <c>anonymous</c> (again, you could use some other password). Note that because
Expand Down Expand Up @@ -362,30 +383,34 @@
</section>

<section xml:id="webwork-pg-macros">
<title>PG Macros from the <pretext/> Source</title>
<title>PG Macros from the <pretext/> source</title>
<p>
The project's <webwork/> exercises may rely on PG macros that are written into the project's
source. For example, the exercises might have TikZ images that rely on
<tag>docinfo/latex-image-preamble</tag>.
</p>
<p>
For this, a PG macro library file must be built and placed in the host course's
<c>templates/macros/</c> folder <em>before</em> attempting to process the <webwork/>
exercises. To build this macro library, run:
For this, a PG macro library file must be built and placed wherever it is needed. To build
this macro library, run:
<cd>
pretext -c pg-macros aota.ptx
</cd>
<c>aota.ptx</c> in the example is the root file for your <pretext/> project. You could also
specify a location to place the resulting macro library file:
<cd>
pretext -c pg-macros -d some/file/path aota.ptx
pretext/pretext/pretext -c pg-macros -p publication.xml mainfile.ptx
</cd>
<ul>
<li>
<q><c>publication.xml</c></q> should be your project's publisher file that declares a
generated folder, and you may need to include the path to this file.
</li>
<li>
<q><c>mainfile.ptx</c></q> should be the main file for your <pretext/> project.
</li>
</ul>
This will place the PG macros file in <c>generated/webwork/pg/[TITLE]/macros/</c> where
<c>[TITLE]</c> is a file-safe version of the title of your project. If you are using a host
course on a <c>webwork2</c> server, plase this macros file in that course's macros folder.
</p>
<p>
Once you have the macro library file, upload it to the host <webwork/> course's
<c>templates/macros</c> folder. If your project relies on the AIM <webwork/> server and you
need to supply a macro library file to a host course on that server, post to
<email>pretex-support@googlegroups.com</email> and we can help with that.
If the project's source changes in such a way that these PG macros would change, this file
should be regenerated.
</p>
</section>

Expand Down Expand Up @@ -535,7 +560,8 @@
that you wrote, set defintion files corresponding to the sections (or other chunks) of your
project, and header files for those sets. All of this was placed into your project's
<c>generated/webwork/pg</c> folder when you executed <c>pretext -c webwork</c>, so you could
find it there and package it all up to send to your <webwork/> server. </p>
find it there and package it all up to send to your <webwork/> server.
</p>
<p>
Alternativley, you may run the following:
</p>
Expand Down Expand Up @@ -568,33 +594,9 @@
</li>
<li>
<p>
Certain aspects of specifying borders of a <pretext/> <tag>tabular</tag> are not
realizable in a <init>PGML</init> table. Specifically,
<ul>
<li>
<p>
Specifying column-specific top border attributes are not implemented.
</p>
</li>
<li>
<p>
Cell-specific bottom border attributes are not implemented.
</p>
</li>
<li>
<p>
<c>medium</c> and <c>major</c> table rule-thickness attributes will be handled as
if they were <c>minor</c>.
</p>
</li>
</ul>
</p>
</li>
<li>
<p>
When constructing a list (<tag>ul</tag> or <tag>ol</tag>) specifying some number of
columns (using the <attr>cols</attr> attribute) will be ignored. PGML markup has no way
to declare multicolumn lists.
When constructing a list (<tag>ul</tag> or <tag>ol</tag>)
specifying some number of columns (using the <attr>cols</attr> attribute)
will be ignored. PGML markup has no way to declare multicolumn lists.
</p>
</li>
</ul>
Expand Down
7 changes: 4 additions & 3 deletions examples/webwork/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ PGOUT = $(SCRATCH)/pg
# folder. There are no macros for the minimal example, so omitted.

sample-chapter-macros:
install -d $(PGOUT)/macros
cd $(PGOUT)/macros; \
$(PTX)/pretext/pretext -v -c pg-macros -p $(SMPCPUB) $(SMPC)
$(PTX)/pretext/pretext -v -c pg-macros -p $(SMPCPUB) -d $(PGOUT)/macros $(SMPC)


#########################################################################
# Extract webwork problems into a single XML file.
# Location is within generated folder (named in the publisher file),
# within "webwork" subfolder
# This also produces PG files for each problem, PG macros, set defintion
# files for problem sets, and set header files all within the "webwork/pg"
# folder

sample-chapter-representations:
$(PTX)/pretext/pretext -v -c webwork -p $(SMPCPUB) $(SMPC)
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions examples/webwork/minimal/publication.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
<source>
<directories generated="generated" external="external"/>
</source>
<webwork
server="https://webwork-ptx.aimath.org"
course="anonymous"
user="anonymous"
password="anonymous"
task-reveal="preceding-correct"
static-processing="webwork2"
/>

<!-- These are the defaults but written explicitly here to serve as a model. -->
<webwork
Expand Down
8 changes: 7 additions & 1 deletion js/pretext-webwork/2.19/pretext-webwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
async function handleWW(ww_id, action) {
const ww_container = document.getElementById(ww_id);
const ww_domain = ww_container.dataset.domain;
const ww_processing = 'webwork2';
const ww_renderer = ww_container.dataset.renderer;
const ww_processing = ww_container.dataset.processing;
const ww_origin = ww_container.dataset.origin;
const ww_problemSource = ww_container.dataset.problemsource;
const ww_sourceFilePath = ww_container.dataset.sourcefilepath;
Expand Down Expand Up @@ -75,6 +76,8 @@ async function handleWW(ww_id, action) {
let url;
if (ww_processing == 'webwork2') {
url = new URL(ww_domain + '/webwork2/render_rpc');
} else if (ww_processing == 'renderer') {
url = new URL(ww_renderer + '/renderer/render-api');
}
let formData = new FormData();

Expand Down Expand Up @@ -415,6 +418,9 @@ async function handleWW(ww_id, action) {
.quill-toolbar { scrollbar-width: thin; overflow-x: hidden; }
</style>` +
'</head><body>' +
'<div id="latex-macros" class="hidden-content process-math" style="display:none"><span class="process-math">\\(' +
document.getElementById('latex-macros-text').textContent +
'\\)</span></div>' +
'<main class="pretext-content problem-content" data-iframe-height="1">' + form.outerHTML + '</main></body>' +
'</html>';

Expand Down
Loading