WeBWorK extraction issue - pulling different problem than NPL tag

23 views
Skip to first unread message

Matt Boelkins

unread,
Oct 10, 2018, 1:14:31 PM10/10/18
to PreTeXt support
I'm working on my new book project and am having a weird inconsistent issue with some WeBWorK problems.

Here's the start of the code for an exercise set (ignore the XML ids which make it appear like something is missing - I've had to comment out some WW problems that aren't working, but I think that's just because they are old):

<exercises xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="ez-changing-functions">

  <exercise xml:id="ez-changing-functions-WW2">
    <webwork source="Library/LoyolaChicago/Precalc/Chap1Sec1/Q24.pg" />
  </exercise>
  <exercise xml:id="ez-changing-functions-WW3">
    <webwork source="Library/LoyolaChicago/Precalc/Chap1Sec1/Q07.pg" />
  </exercise>
  <exercise xml:id="ez-changing-functions-WW6">
    <webwork source="Library/LoyolaChicago/Precalc/Chap1Sec1/Q19.pg" />
  </exercise>
  <exercise xml:id="ez-changing-functions-WW7">
    <webwork source="Library/LoyolaChicago/Precalc/Chap2Sec1/Connally3-2-1-25-Input-and-output.pg" />
  </exercise>

Note the Library address for the problem highlighted in red.  This is the second problem in the section's exercises.  I've attached a screenshot of that exercise from the NPL, which shows it to be an exercise where the user should see 8 graphs among which they will decide whether each is a function or not.

But after I run the WW extraction (make acs-extraction) and then make the html, I get the 2nd attached screenshot as output.  Note that exercise #2 in that screenshot should match the one from the NPL.  (It's not some random exercise that's appearing, but one that I previously used in a different section of the text.)

I have gotten a couple of other errors like this where a WW problem repeats despite there being two different source addresses in consecutive problems.

When I make the HTML, I also get this error message multiple times (which may be related):

PTX:BUG:     An object (li) lacks a serial number, search output for "[NUM]"

             located within: "extracted-webwork-15" (xml:id)


Thoughts?

Thanks,
Matt
WW-problem.png
PTX-HTML.png

Mitch Keller

unread,
Oct 10, 2018, 1:32:12 PM10/10/18
to pretext...@googlegroups.com
So, first a bit of additional information about the process Matt’s using here. We basically just modified the Makefile from Active Calculus to give him something that would work for Active Precalculus. In that Makefile, make html first does a merge step and then does the call to xsltproc on the merge file.

The first thing I would test is if there’s a failure in the merge step that’s getting washed out of sight. After doing make acs-extraction, try make acs-merge and look for an error. If there’s an error produced, what is it?

If there’s no error when doing make acs-merge, then we need to dig deeper. Look in output/webwork for webwork-extraction.xml and search for the problem. Also look in output/webwork/acs-merge.ptx for the spot where this problem is meant to live. What exists in those files for this problem?
> --
> You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
> To post to this group, send email to pretext...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/3aad777d-172f-4394-963d-8166a068d422%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <WW-problem.png><PTX-HTML.png>


Mitch Keller
mi...@rellek.net

Rob Beezer

unread,
Oct 10, 2018, 1:37:06 PM10/10/18
to pretext...@googlegroups.com
> When I make the HTML, I also get this error message multiple times (which may be
> related):
>
> PTX:BUG: An object (li) lacks a serial number, search output for "[NUM]"
>
> located within: "extracted-webwork-15" (xml:id)

That is new-ish, and due to a new error message I added, noted as an issue
already. So I don't think actual behaviors have changed. (I think the "li"
element is being recycled for problems with radio buttons, or similar.) I've
been ignoring it when I build the sample chapter, and considering it not to be
urgent. BUT, if you see a telltale "[NUM]" in your output, please follow up.

https://github.com/rbeezer/mathbook/issues/951

Thanks for the careful report. You could poke around in the intermediate files
produced (prior to being merged int your existing source), but I'd wait for Alex
to comment first.

Rob

Alex Jordan

unread,
Oct 10, 2018, 1:38:50 PM10/10/18
to pretext...@googlegroups.com
Without having examined the .pg file used for that problem,
I would be pretty surprised if it turns out to be PTX-compatible.
The structures that OPL authors have used to make arrays of images
like that appear in the output are usually too clunky to be PTX-compatible.

When a problem is not PTX-compatible, it will either
  1. be very obvious because the merge will fail, because the webwork-extraction.xml
    is not a valid XML file
  2. or you will have no clue at first, because the XML is valid
Anyway this wouldn't explain seeing some other problem showing up in its place.

To help (which I may not be able to do for a few days) I should look at:
  • the .pg file for this problem (which I can see in the OPL)
  • the webwork-extraction.xml file that you make. But actually just the
    webwork-reps element corresponding to this problem.
  • live HTML demonstrating the issue with the wrong problem
    appearing in its place.



Matt Boelkins

unread,
Oct 10, 2018, 1:47:37 PM10/10/18
to PreTeXt support
I ran make acs-merge and got no errors:

boelkinmHV2R:APC boelkinm$ make acs-merge

cd /Users/boelkinm/APC//output/webwork-extraction; \

xsltproc -xinclude  --stringparam webwork.extraction /Users/boelkinm/APC//output/webwork-extraction/webwork-extraction.xml /Users/boelkinm/mathbook//xsl/pretext-merge.xsl /Users/boelkinm/APC//src/index.xml > acs-merge.ptx


After remaking the HTML, that seems to have fixed the problem.  The problem I desired (with lots of graphs) has rendered fine (as have several others), and the issue of different WW problems appearing instead of the ones desired has vanished.  Thanks Mitch, Alex, and Rob for your quick replies.  

I'm still getting a big list of 

PTX:BUG:     An object (li) lacks a serial number, search output for "[NUM]"

             located within: "extracted-webwork-15" (xml:id)


in response to "make html", but I've not yet seen a "telltale NUM" anywhere in my output.  Eyes peeled :-).


Matt

Alex Jordan

unread,
Oct 10, 2018, 6:27:13 PM10/10/18
to pretext...@googlegroups.com
My best guesses are:
  • there was an older webwork-extraciton.xml that was used in a merge
  • browser caching something
I'm still suspicious about that PG problem. If you are using it as a live interacting
thing in the eBook, you won't see a problem. In that situation it is just loaded from
its place in the OPL on the WW server.

But the moment you try to make a PDF (or use it as a static problem in the eBook)
then the WW server needs to have returned good PTX XML for the problem.
And I doubt you can get that with this one. You will either get a table with images
inside cells (not [yet?] supported) or you will get some failed attempt at building
a sidebyside. I say "failed" because in the best case it will be valid PTX XML,
but structured such that the images will come out all aligned vertically.

When a WW problem is PTX-incompatible, there are basically 4 options:
  1. Edit the problem in the OPL to make it PTX-compatible. Takes time
    to get the OPL curators to review and approve.
  2. Enhance WW's ability to output PTX XML, so that the problem is now in
    the compatible zone. At present I'm the only person doing that kind of thing
    and it's not likely I can do more of it any time soon.
  3. Make your own version of the problem in PTX source. That requires some
    knowledge of PG coding, which is an obstacle.
  4. Cut the problem from your book.
Also with 1 and 3,  in cases like this problem, I'm not sure there is any way at all to
really recover the essence of the original problem.

With 2, there can be fundamental issues making it fairly impossible.


Matt Boelkins

unread,
Oct 11, 2018, 1:42:02 PM10/11/18
to pretext...@googlegroups.com
Thanks Alex.  You're right:  when I go to build PDF, I get error messages and the problem and others like it fail to render.

Is a good rule of thumb that for OPL problems with a single graphs, things are usually fine, but for those with a table of graphs, things are usually not fine?

I can work around all of these things by selecting other problems.  I like the ones with multiple graphs for the type of problem, but can counter that with non-WW exercises.

Matt

You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/Jf48BUFFDGQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.

To post to this group, send email to pretext...@googlegroups.com.

Alex Jordan

unread,
Oct 11, 2018, 2:59:04 PM10/11/18
to pretext...@googlegroups.com
Is a good rule of thumb that for OPL problems with a single graphs, things are usually fine, but for those with a table of graphs, things are usually not fine?

If there are two separate images presented side by side, it is usually not
going to work out. In some cases it will work out with the image aligned
vertically, and that may be acceptable.

I know that getting into the specifics of this problem is not so important,
but in case it is helpful for what to do in general, here is what process I
would go through.

Here is a live version of the problem:

And here is its source:

My observations are:
  • The graphs themselves are not randomly generated. There are 10 fixed
    images. (And 8 of them are randomly chosen and ordered for display.)
  • Those 10 fixed images are .gif files. While we hopefully are successful at
    downloading them, do I recall correctly that .gif is hard/impossible to insert
    into a tex-based PDF?
  • The presentation is not only ugly, but could have real issues with students
    just learning about these things. I am referring to how graphs in one row
    run right into each other.
  • You have to type out "Yes" or "No" when you could easily have a popup
    with those options instead. (Requiring typing adds a tiny bit of frustration
    when there is a typo in what you type.)

If I wanted to keep the problem, a new version needs to be built into your PTX
source. I would make it have just two images, where each image has four graphs.
Below each quadrimage, I would put four dropdowns. Probably it would be good to
have things like A, B, C, D within the quadrimage and use that to make it crystal
clear which dropdown refers to which plot.

To put four plots in one image, you would have to "draw" each set of axes instead
of using the built-in axes-drawing macro.

If you wanted to get fancy, you could program it in such a way that plot-and-answer
components are randomly built. But of course that would be a larger coding burden.

Unfortunately there is just no way to actually salvage certain OPL problems if you
really want them to work in other PTX output formats. If the math problem is
important to have, coding it in PTX is where I have settled for the best alternative.

Here is an untested mockup with some example structure. I know most of us haven't
done direct coding of WW problems. Is this example encouraging or discouraging?

<exercise>
    <webwork>
        <setup>
            <pg-code>
                $quadrimage = init_graph(0, -20, 160, 20, size=>[600, 150]);
                #draw axes and label
                for my $i (0..3) {
                    $quadrimage->moveTo(40*$i + 5, 0);
                    $quadrimage->arrowTo(40*$i + 35, 0, 'black', 1);
                    $quadrimage->lb( new Label(40*$i + 35, 0, 'x', 'black', 'center', 'top', 'large'));
                    $quadrimage->moveTo(40*$i + 20, -15);
                    $quadrimage->arrowTo(40*$i + 20, 15, 'black', 1);
                    $quadrimage->lb( new Label(40*$i + 20, 15, 'y', 'black', 'right', 'middle', 'large'));
                    $quadrimage->lb( new Label(40*$i + 20, 15, $ALPHABET[$i], 'black', 'left', 'middle', 'large'));
                }
                #plot A
                    $quadrimage->moveTo(5, 10);
                    $quadrimage->lineTo(15, 8, 'blue', 2);
                    $gr->stamps( closed_circle(15, 8, 'blue') );
                    $gr->stamps( open_circle(15, 4, 'blue') );
                    $quadrimage->moveTo(15, 4);
                    $quadrimage->lineTo(35, 15, 'blue', 2);
                    $popup[0] = PopUp(['?', 'does', 'does not'], 1);

                #plot B
                    $popup[1] = PopUp(['?', 'does', 'does not'], 2);

                #plot C
                    $popup[2] = PopUp(['?', 'does', 'does not'], 2);

                #plot D
                    $popup[3] = PopUp(['?', 'does', 'does not'], 1);
            </pg-code>
        </setup>
        <statement>
            <p>
                Decide whether each of the following graphs represent <m>y</m> as a function of <m>x</m>.
            </p>

            <sidebyside widths="100%">
                <image pg-name="$quadrimage" />
            </sidebyside>

            <p>
                Graph A <var name="$popup[0]" form="popup" />,
                Graph B <var name="$popup[1]" form="popup" />,
                Graph C <var name="$popup[2]" form="popup" />,
                and Graph D <var name="$popup[3]" form="popup" />.
            </p>
        </statement>
    </webwork>
</exercise>



Matt Boelkins

unread,
Oct 12, 2018, 9:37:47 AM10/12/18
to pretext...@googlegroups.com
Thanks Alex.  I think I will avoid having such problems in the text and use others from the OPL.

I appreciate all the help here and letting me know what some of the possible workarounds are.
Matt

Rob Beezer

unread,
Feb 22, 2019, 7:58:47 PM2/22/19
to pretext...@googlegroups.com
This bug has been fixed. Details at:

https://github.com/rbeezer/mathbook/issues/951
Reply all
Reply to author
Forward
0 new messages