How to get Dynamic Webwork Problems?

166 views
Skip to first unread message

Karl Schmitt

unread,
Aug 31, 2017, 5:07:17 PM8/31/17
to pretext...@googlegroups.com
So.. I thought webwork embedded in the HTML would be dynamic, that is, new values generated on each reload... but it seems I might have missed a flag somewhere, or did something wrong for that..

Right now, I get exactly the same numbers every time I load the page. 

Any ideas what I missed/did wrong? 

I realize some WW's are hard coded...these are not, as when I look at them in the library browser on our server, I get different numbers..

Thanks as always for the help!
Karl



==================================================
To schedule a meeting or appointment try:
https://karlrbschmitt.youcanbook.me/

Dr. Karl Schmitt
Assistant Professor
Department of Mathematics and Statistics
Department of Computing and Information Sciences
Director of Data Science Program
Director of Analytics and Modeling Graduate Program
Valparaiso University, Indiana
==================================================

jordancanonical

unread,
Aug 31, 2017, 11:36:43 PM8/31/17
to PreTeXt support
The HTML embedding is not so much "dynamic" as it is "interactive".

The same randomization seed is used at every load.
This is intentional, to keep the eBook saying the same thing that the print book says.
And also so that a student reader doesn't invest lots of time trying to solve something,
and then come back to it to find there is a different problem there.

You can give your webwork elements a @seed attribute.
If you do not, currently some specific default seed is used.
I think it may be 123456 or something like that.
(Side note: default seeds should actually differ for each webwork,
and my revisions that are underway will make such a change.)

You can use  one of WeBWorK's own abilities to re-randomize a problem,
if you are writing the problem source (as opposed to calling an existing OPL problem).
I won't get into how you do that unless you confirm you are writing the problem source.
I suspect you are using OPL problems.
But what happens is the user either explicitly pushes something to re-randomize,
or there is re-randomization after some set number of checks.
(If you refresh or reload the page, it will go back to the first version.)

And lastly, there is a future where you can enable WeBWorK's
"Show Me Another" feature within this PreTeXt output.
Again there would be a button to explicitly re-randomize.
It's on the to-do list for PTX-WeBWorK enhancements,
but relatively low priority given the other things.

Karl Schmitt

unread,
Sep 1, 2017, 10:57:22 AM9/1/17
to pretext...@googlegroups.com
Hrm..

Ideally what I'd want is that "show me another" feature... with my OPL problems. 

I'm not currently writing my own problems, but I suppose I could _almost_ as easily copy an OPL and add the randomization.

Or I might just hack it and put 2-3 copies of the same OPL problem, then just give them different seeds.



==================================================
To schedule a meeting or appointment try:
https://karlrbschmitt.youcanbook.me/

Dr. Karl Schmitt
Assistant Professor
Department of Mathematics and Statistics
Department of Computing and Information Sciences
Director of Data Science Program
Director of Analytics and Modeling Graduate Program
Valparaiso University, Indiana
==================================================

--
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-support+unsubscribe@googlegroups.com.
To post to this group, send email to pretext-support@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/b09677bd-ef7e-413f-b3cf-310c8a775e7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rob Beezer

unread,
Sep 1, 2017, 11:08:31 AM9/1/17
to pretext...@googlegroups.com
I'm with you on this one Karl.

On 09/01/2017 07:57 AM, Karl Schmitt wrote:
> Or I might just hack it and put 2-3 copies of the same OPL problem, then just
> give them different seeds.

Read the modularization material in the Author's Guide and put the problem in an
external file that you can xi:include with the parse="text" attribute.

jordancanonical

unread,
Sep 1, 2017, 11:15:08 AM9/1/17
to PreTeXt support
Here is the original announcement about embedding WeBWorK cells in HTML:
http://michaelgage.blogspot.com/2015/06/whether-writing-full-text-book-or-just.html

A slightly modified, evolved version of this is what PTX uses.
The first step to getting SMA in PTX output would be
to just make it a possibility for regular WeBWorK embedding.
Here is the WeBWorK forum:
http://webwork.maa.org/moodle/mod/forum/index.php?id=3
And the development mailing list is described at:
http://webwork.maa.org/wiki/Mailing_Lists

If you posted interest in Show Me Another in embedded HTML
(referencing that first announcement link) then
one of the WeBWorK developers
might help move things along.
Otherwise it will be an unknown amount of tie before I try to make it happen.


jordancanonical

unread,
Sep 1, 2017, 11:19:53 AM9/1/17
to PreTeXt support
Also...

In the knowl.html file for the webwork problem, you will find a url, where one of the javascript selectors will be something like &seed=123456. If anyone wanted to bypass actual chnages to WeBWorK, you could make some js that would alter that seed, and then reload the iframe the problem sits in.

Karl Schmitt

unread,
Sep 1, 2017, 11:28:27 AM9/1/17
to pretext...@googlegroups.com
Alex, where should we post interest in the show me another... (not that I have more time than to just give a "thumbs up" to the idea...

==================================================
To schedule a meeting or appointment try:
https://karlrbschmitt.youcanbook.me/

Dr. Karl Schmitt
Assistant Professor
Department of Mathematics and Statistics
Department of Computing and Information Sciences
Director of Data Science Program
Director of Analytics and Modeling Graduate Program
Valparaiso University, Indiana
==================================================

On Fri, Sep 1, 2017 at 10:19 AM, jordancanonical <jordanc...@gmail.com> wrote:
Also...

In the knowl.html file for the webwork problem, you will find a url, where one of the javascript selectors will be something like &seed=123456. If anyone wanted to bypass actual chnages to WeBWorK, you could make some js that would alter that seed, and then reload the iframe the problem sits in.

--
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-support+unsubscribe@googlegroups.com.
To post to this group, send email to pretext-support@googlegroups.com.

jordancanonical

unread,
Sep 1, 2017, 12:09:40 PM9/1/17
to PreTeXt support
You can either sign up to the WeBWorK forum I linked,
or sign up to the development mailing list, also linked.
And then post to whichever one that you would like to see Show Me Another
enabled in embedded WeBWorK problems in HTML
(and link to that planet WeBWorK post for clarity).
Ask if there are plans to have that feature in version 2.14,
and explain some your interests in having it.
You can mention PreTeXt, but many readers may not know what that is.
And also it's not relevant to the WeBWorK developers for enabling SMA
in embedded WeBWorK.


Enrique Acosta

unread,
Jan 23, 2019, 9:34:58 AM1/23/19
to PreTeXt support
Thanks to this thread I now understand the logic of having a hard coded seed, but I would still like to use the "Get a new version of this problem/show me another"  in a "more practice subsection". This allows me to just put one copy of each problem in that subsection and have students try as many versions as they want instead of making many copies.

I just attempted the following which almost worked:
<pg-macros>
    <macro-file>problemRandomize.pl</macro-file>
</pg-macros>
<setup>
                  <pg-code>
                           ProblemRandomize(when=>"always",onlyAfterDue=>0,style=>"Button");
                            $a = Compute(random(1, 9, 1));
                            $b = Compute(random(1, 9, 1));
                            $c = $a + $b;
                  </pg-code>
</setup>

This gives a "Get a new version of this problem" button after submitting the problem, but the new seed does not behave well in PreText. Specifically, it defaults to the original seed after submitting the new answer, and so marks the student wrong.

Is there any way to make this approach work?

Thanks!
Enrique

Alex Jordan

unread,
Jan 23, 2019, 1:00:30 PM1/23/19
to pretext...@googlegroups.com
The short answer is you cannot do what you want right now,
but maybe someday we can do it.

When your WW problem is embedded in the HTML page,
it is done so via a URL to the WW server that includes a seed
as a query value, like here where you can see problemSeed=1:

/solveQuad90.pg&amp;displayMode=MathJax&amp;courseID=anonymous&amp;userID=anonymous&amp;course_password=anonymous&amp;outputformat=simple

For the embedded HTML version, that is what controls the
randomization. Something needs to change that query key,
and then reload.

At the end of that sample URL, you see outputformat=simple.
This is specifying a template format for the layout of the problem,
including things like the Check answers button. I believe it would
be possible to make a new outputformat that had an additional
button, and clicking this button would trigger javascript to change
the problemSeed and reload.

That should be part of a larger conversation about what we would
like the outputformat for PreTeXt HTML embeddings to be like.
And if we want to allow more than one option. Some other things
we have thought to change are to remove the Preview button,
change "Submit" to "Check", and load some CSS overrides that
make it all look nicer in the context of a PreTeXt HTML embedding.




--
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/df07cea5-dde5-4eda-a713-2d7a21336837%40googlegroups.com.

Rob Beezer

unread,
Jan 23, 2019, 1:31:23 PM1/23/19
to pretext...@googlegroups.com
On 1/23/19 10:00 AM, Alex Jordan wrote:
> The short answer is you cannot do what you want right now,
> but maybe someday we can do it.

I'd love to see this. Is it possible to have the server endpoint get new
functionality? With no problem seed, or maybe the problem seed is a flag (0,
-1), and the server generates a random seed each time?

Then as authored in PTX we can just include some sort of attribute to initiate
this behavior.

An *endless* supply of "identical" problems with "different numbers" strikes me
as a fantastic feature of an online text. Maybe we could make the static
version have a finite number of such a problem by specifying a handful of seeds
in the PTX source?

I know there have been requests for "copies" of WW problems. Maybe we can do
the best possible thing for each format, with minimal source creation and
maintenance for authors?

Rob

Alex Jordan

unread,
Jan 23, 2019, 1:53:21 PM1/23/19
to pretext...@googlegroups.com
On Wed, Jan 23, 2019 at 10:31 AM Rob Beezer <bee...@ups.edu> wrote:
On 1/23/19 10:00 AM, Alex Jordan wrote:
> The short answer is you cannot do what you want right now,
> but maybe someday we can do it.

I'd love to see this.  Is it possible to have the server endpoint get new
functionality?  With no problem seed, or maybe the problem seed is a flag (0,
-1), and the server generates a random seed each time?

Anything is possible :)

The issue is going to be around the concept of "each time". No one is logged in,
nothing is being recorded. Something has to change something in the URL query
keys for the second time to be any different than the first time. I think that the
format template (a server side thing) can be made to do this, and would be
preferable. The other option is some PTX HTML thing that would alter the query
keys. I'll look into it at some point not too far off.




Then as authored in PTX we can just include some sort of attribute to initiate
this behavior.

An *endless* supply of "identical" problems with "different numbers" strikes me
as a fantastic feature of an online text.  Maybe we could make the static
version have a finite number of such a problem by specifying a handful of seeds
in the PTX source?

It will be nice, but also come with mildly itchy side effects. Like a student worked
on some version in the library, didn't understand why their answer was not accepted,
but now in the professor's office cannot get back to that same version.
 

I know there have been requests for "copies" of WW problems.  Maybe we can do
the best possible thing for each format, with minimal source creation and
maintenance for authors?

I tried this once, and got stumped with an issue inside the PG and set def archiving.
Maybe now so much has changed with the core production flow that I should
revisit it. You'd have:
webwork/@xmlid=foo
webwork/@copy=foo

And also you'd expect different seeds, which could be manually specified or different
with their default which is currently based on the count of preceding webwork~s.

 

Rob


--
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.

Enrique Acosta

unread,
Jan 23, 2019, 2:42:50 PM1/23/19
to PreTeXt support
Thanks for the replies! I look forward to this being implemented at some point!

There are certainly issues about identifiers for student versions in case they have questions about a problem, and issues about the textbooks looking different for different people. Maybe this "Get a new version of this problem/show me another" functionality could be reserved to some special "practice" sections/subsections? In these, students can go an try out as many versions of a same problems as they feel they need (which is what I am imagining). Maybe the seed value can be displayed to the student as a "problem identifier" so that they learn to record that when they have a particular question. The problemRandomize.pl macro I mentioned had an option that allowed one to specify the seed instead of just a "new version" button. This would certainly be important for teachers.

In any case, just throwing ideas out there.

Thanks again!
Enrique

Oscar Levin

unread,
Jan 23, 2019, 4:41:54 PM1/23/19
to pretext...@googlegroups.com
A while back there was a suggestion that pages with WeBWorK should load the static version initially, and then only load the live version when a student clicks on the problem (or a button next to the problem, using some javascript).  As I understood it, this was intended to increase the speed at which a page loads, and the lower the server load on WeBWorK.  Could this also solve the current problem?  I don't know how how the seed thing works, but presumably if javascript can dynamically call for the webwork problem, it could also call for one with a random seed.

David Farmer

unread,
Jan 23, 2019, 4:44:38 PM1/23/19
to pretext...@googlegroups.com

We definitely need to start loading individual WW problems as they
are actually needed. Both the server load and the page loading
time are issues.

The knowls code has an option to open its content in place of
existing content, and this was a planned use case.

Realistically, this will not be tacked until after this semester
is over.
> https://groups.google.com/d/msgid/pretext-support/CAOU9BaXzrLX6HdmmFC94MZQkcR40cwRGqcOPyvaytb-bhYO8jw%40mail.gmail.com.

Alex Jordan

unread,
Jan 23, 2019, 5:31:00 PM1/23/19
to pretext...@googlegroups.com
A while back there was a suggestion that pages with WeBWorK should load the static version initially, and then only load the live version when a student clicks on the problem (or a button next to the problem, using some javascript).  As I understood it, this was intended to increase the speed at which a page loads, and the lower the server load on WeBWorK.  Could this also solve the current problem?  I don't know how how the seed thing works, but presumably if javascript can dynamically call for the webwork problem, it could also call for one with a random seed.

Yes! Thanks for the reminder about this.

Based on my sample size of experience with one WW-using book,
I would still like to see inline exercises start out live. So maybe it
would be a little bit configurable. For exercise~s inside exercises~s,
this could become the default (only allowed?) behavior.


 

Reply all
Reply to author
Forward
0 new messages