## Forum archive 2000-2006

### Jun Wang - Questions about $newProblemSeed, ensuremath, and answer box in a matrix. ### Jun Wang - Questions about$newProblemSeed, ensuremath, and answer box in a matrix.

by Arnold Pizer -
Number of replies: 0
 Questions about $newProblemSeed, ensuremath, and answer box in a matrix. topic started 5/20/2003; 12:43:30 PMlast post 5/21/2003; 5:55:40 PM  Jun Wang - Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/20/2003; 12:43:30 PM (reads: 2022, responses: 9) Hi, I need some help in dealing the following cases. 1. While playing with the MAA tutorial templates, I noticed that $newProblemSeed does not work in typeset2 mode on our system if there are images involed. TEXT mode and "formatted-text" mode show that the problem is changed. However, the images are not updated even after reloading. 2. When dealing with fractions with command "new Fracion()" as used in the 8th grade problems in Rochester CVS, "\ensuremath" is not interpreted by our system. We have latex2e installed. 3. In typeset2 mode, the answer box can not be displayed in a table or in a matrix on our system. Is there a way to resolve this? Thanks, Jun <| Post or View Comments |>  Michael Gage - Re: Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/20/2003; 4:04:40 PM (reads: 2238, responses: 0) Hi Jun, (1) When ever you use images the browser caches the images so that they do not need to be downloaded again. (Some browsers have a preference which allows you to turn this "feature" off.) Pressing the shift key while clicking "reload" will force the browser to reload the images (in most browsers). WeBWorK could help with this problem by renumbering the image everytime it is displayed. This would require some work however and is not high on our toDo list, since the problem you are discussing occurs mainly when instructors write problems, not when students view them. For this reason I tend to use the formattted-text mode when writing problems. (2) I believe that ensuremath is part of Latex2e (see http://www.nerc-essc.ac.uk/~dwcp/Latex/ensuremath.html for example) I suggest trying to debug this problem by writing a tex file directly on your system and processing it with the same tex system that is called by WeBWorK. (3) Using tth mode is one way to resolve it, but many browsers/OS systems don't have the needed fonts installed. John Jones is working on an improved version of display_matrix that will display the matrices as a table while processing the entries with Tex. You can follow his changes at http://webwork-db.math.rochester.edu/cgi-bin/cvsweb.cgi/webwork/system/courseScripts/PGmatrixmacros.pl and also download the latest versions. (If you want to keep up with changes this summer "as they happen" you can link to our CVS as described at http://webhost.math.rochester.edu/webworkdocs/docs/install/how_to_use_cvs Hope this helps. -- Mike <| Post or View Comments |>

 Arnold K. Pizer - Re: Questions about $newProblemSeed, ensuremath, and answer box in a matrix. 5/21/2003; 9:30:45 AM (reads: 2240, responses: 0) Hi Jun, Let me add one additional comment to Mike's reply about cached images. Assuming you are using WeBWorK 1.8, if you want to refresh images when you change seeds, you should put$refreshCachedImages = 1;into the .pg code for the problem. This disables WeBWorK's caching of images but you still have to handle the browser's caching of images. You can also set this as the default for the whole WeBWorK system or for a single course, but this is not recommended (see below). In typeset2 (dvipng) and typeset (latex2html) modes, WeBWorK caches the images on the server in order to speed up processing the next time the same problem is viewed. When a problem is viewed, WeBWorK checks that the cached images are newer than the problem .pg code and if not, regenerates the images. Thus if a problem is edited, the images are regenerated. However, since it is very rare for the seeds to be changed, no such check is done with seeds. Thus if a professor changes the seed for a problem, it is up to the professor to delete any cached images for that problem (or to set $refreshCachedImages = 1; for that particular problem if seeds will be changed a lot). It would not be too difficult to change the WeBWorK system code so that when the seed for a problem is changed, all associated cached images are deleted but WeBWorK does not currently work that way. Here is the documentation on$refreshCachedImages taken from Global.pm: $Global::PG_environment{refreshCachedImages} = 0; # Set to 0 or 1. If set to 1, the cached images for # problems will never be used and Latex2html, dvipng, or any new # modes that use cached images will always be called # on to create or recreate all images. This can be very time # consuming so almost never should this variable be set to 1. # This default can be over ridden for an individual problem by # setting e.g. refreshCachedImages = 1 in the .pg file for the problem. # This is the real reason for the variable and is useful for # conditional problems where the second part of the problem # will be displayed only if a student answers the first part # correctly. In this case the cached images would only show # for the first part so the second part would never appear in # typeset, etc. mode. <| Post or View Comments |>  Jun Wang - Re: Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/21/2003; 10:32:03 AM (reads: 2227, responses: 0) Thank you, Mike, (1), I tried "Shift+reload" on IE5 and Netscape 7.0, but they did not work. Formatted-text mode works fine and I was just wondering if I missed something. (2). I was referring to some grade 8th problems in Rochester CVS like http://webwork-db.math.rochester.edu/cgi-bin/cvsweb.cgi/rochester_grade8problems/setGrade8/U1orderingNumbers/ordering_numbers_2.pg?rev=1.2&content-type=text/x-cvsweb-markup&cvsroot=Rochester. When I copied them to our system, the problems displayed something like "\ensuremath{ \frac{11}{17} }" instead of a fraction. Last night I accidentally fixed it on our system by enclosing them with (...), that is, I changed "\{ $a->print \} \{ans_rule(5)\} \{$b->print \}$BR" in the template to "$$\{ a->print \}$$ \{ans_rule(5)\}$$\{ b->print \}$$$BR". However, I don't know why and I thought (...) or $were not needed in Latex2e. (3). We will keep up with the changes. Thank you. Jun <| Post or View Comments |>  Jun Wang - Re: Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/21/2003; 10:41:31 AM (reads: 2221, responses: 0) Hi, Arnie, It worked. This fixed my first question. Thank you. Jun <| Post or View Comments |>

 John Jones - Re: Questions about $newProblemSeed, ensuremath, and answer box in a matrix. 5/21/2003; 12:28:32 PM (reads: 2191, responses: 0) Hi Jun, I haven't researched your question about \ensuremath, but I have a few thoughts. \ensuremath is part of latex2e, so it will work as expected in some cases with WeBWorK. In particular, it should work in pdf production. On the other hand, when WeBWorK makes images from bits of math in a problem, it has to know where those bits of math are. It does it by searching for  and . Other ways of invoking math mode will be missed, which includes use dollar signs (which would be hell to support because of their special nature in perl) and \ensuremath. Looking at the code for EV3, it doesn't look to hard to add support for \ensuremath. After it has dealt with the two basic types of math expressions above, it would then look for \ensuremath{...} and treat it as $$...$$. One difficulty may be jumping past matching braces inside the \ensuremath, but I think a suitable regular expression can be made. John <| Post or View Comments |>  Zbigniew Fiedorowicz - Re: Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/21/2003; 1:35:40 PM (reads: 2214, responses: 0) Hi Arnie, << Thus if a professor changes the seed for a problem, it is up to the professor to delete any cached images for that problem (or to set $refreshCachedImages = 1; for that particular problem if seeds will be changed a lot). It would not be too difficult to change the WeBWorK system code so that when the seed for a problem is changed, all associated cached images are deleted but WeBWorK does not currently work that way. >> I would request that you make this change. The current situation can easily lead to unpleasant misunderstandings between the professors and students. Zig <| Post or View Comments |>  Michael Gage - Re: Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/21/2003; 1:48:36 PM (reads: 2203, responses: 0) Hi Jun and John, Jun, I think you have found a "feature/bug" in Fraction.pm. That module has not been tested in the field very much, so I guess I shouldn't be surprised. I expect it will work in Latex2HTML mode which analyzes the entire file, not just the math strings. We have two choices, remove the ensuremath tags in the Fraction.pm module. This means that fractions will always need to be printed inside math mode e.g. $$\{a->print} - \{ b->print \} = \{ ans_rule \}$$ which is not elegant, but it is consistent. Alternatively we could also try to make WeBWorK do something more sophisticated along the lines of John's suggestion. This would allow us to write \{$a->print\} when the fraction is used alone. How useful is it to be able to use \{$a->print \} instead of $$\{ a->print }$$ ? is it worth the extra effort? -- Mike <| Post or View Comments |>

 John Jones - Re: Questions about $newProblemSeed, ensuremath, and answer box in a matrix. 5/21/2003; 2:17:31 PM (reads: 2211, responses: 0) Hi, On << Thus if a professor changes the seed for a problem, it is up to the professor to delete any cached images for that problem (or to set$refreshCachedImages = 1; for that particular problem if seeds will be changed a lot). It would not be too difficult to change the WeBWorK system code so that when the seed for a problem is changed, all associated cached images are deleted but WeBWorK does not currently work that way. >> I think images are deleted automatically if the professor changes a seed through the professor's page. What is not noticed is if the seed is changed by the problem itself. If that possibility is built into a problem, then the problem should set $refreshCachedImages = 1. John <| Post or View Comments |>  Jun Wang - Re: Questions about$newProblemSeed, ensuremath, and answer box in a matrix.  5/21/2003; 5:55:40 PM (reads: 2228, responses: 0) Hi, Mike and John, John is right and it works in the pdf production of hard copies. The current version is fine to me. I just need to make a note and remember to use math mode, different from other situations such as printing multiple choices. Thanks. Jun <| Post or View Comments |>