Installation

Math not rendering in solutions

Math not rendering in solutions

by Tim Alderson -
Number of replies: 4


Math is not rendering in the solution area of our problems after upgrade to 2.17, but renders fine in hmwk set editor


Problem source

DOCUMENT();
loadMacros("PG.pl","PGbasicmacros.pl","PGanswermacros.pl");
loadMacros("Parser.pl");
loadMacros("freemanMacros.pl");

$num = random(9, 30);
$mod = $num % 8;
$mt = $num % 4;
$quot = int $num / 8;
$ans = ($mod * pi) / 4;

Context()->texStrings;
BEGIN_TEXT
\{ beginproblem() \}
\{ textbook_ref_exact("Rogawski ET 2e", "1.4","1") \}
$PAR
Find the angle between \( 0 \) and \( 2 \pi \) that is equivalent to \( \displaystyle \frac{$num \pi}{4} \).
$PAR
\( \theta =  \) \{ans_rule()\}
END_TEXT

ANS($ans->cmp);

SOLUTION(EV3(<<'END_SOLUTION'));
$PAR
$SOL
$PAR
Because \( \frac{$num \pi}{4} > 2 \pi \), we repeatedly subtract  \( 2 \pi \) until we arrive at a radian measure that is between \( 0 \) and \( 2 \pi \).  $PAR

Since \( \frac{$num \pi}{4} - $quot (2 \pi) = \frac{$mod \pi}{4}\), and   \( 0 < \frac{$mod \pi}{4} < 2 \pi\),  we conclude that \(\frac{$mod \pi}{4} \) is the angle measure between \( 0 \) and \( 2 \pi \) that is equivalent to \( \frac{$num \pi}{4} \).
END_SOLUTION

ENDDOCUMENT();


In reply to Tim Alderson

Re: Math not rendering in solutions

by Tim Alderson -
Sorry for the useless post above, I did not realize the screenshots would not be included not to mention the math mode issue with verbatim paste.

The issue is that as soon as a math delimiter appears "\(" in any of the solutions, nothing else from that point forward is rendered.  Each problem and solution renders fine however in the homework Sets Editor preview.

The strange thing is that the problems/solutions render fine if I paste the problem code into another course on the same server. Also works if I copy the problem sets to another course.



  
In reply to Tim Alderson

Re: Math not rendering in solutions

by Danny Glin -

You can include screenshots as attachments to your post, but it looks like embedding them directly within the text isn't working.

The problem source that you included displays properly for me in both the Homework Sets Editor and when viewed from within a problem set.

Was the course where the problem occurs created before or after you upgraded to 2.17?  Does this happen consistently on either old courses or new courses?

Did you upgrade pg to 2.17 as well?

I don't know if these next observations relate to your issue, but they're good practices:

  • SOLUTION(EV3(<<'END_SOLUTION')); can be replaced with BEGIN_SOLUTION
    I believe that currently BEGIN_SOLUTION is an alias for the same command, but if there are changes in future versions they are more likely to be picked up by BEGIN_SOLUTION
  • You do not need the first three lines in the solution ($PAR $SOL $PAR).  Recent versions of WeBWorK include a title above the solution, which is what $SOL generates, so including this leads to a title of "Solution" above the box, and again within the box.
  • You should have Context()->normalStrings; after END_TEXT, followed by Context()->texStrings; again before BEGIN_SOLUTION, and finally Context()->normalStrings; after END_SOLUTION.

Having said all that, it is no longer recommended to use BEGIN_TEXT and END_TEXT at all, as PGML is the more current way to display questions in WeBWorK.

In reply to Danny Glin

Re: Math not rendering in solutions

by Tim Alderson -

Hi Danny,

Yes, I upgraded to 2.17. However, when I upgraded things went awry. Long story short, I had to move a live course (M1003) to our second server (which services another campus) which is version 2.16 while we fixed 2.17.  A few days later I archived M1003 on 2.16 and moved it back to the functioning 2.17 server. All seemed fine except for the strange behaviour of the solutions.

Before noticing the issue I also created another course on the 2.17 server by archiving M1003 and un-archiving it with a new name. This course has the same problem regarding the rendering of solutions, but at least that course is not live until Tuesday.

To get around the issue I created a new course based on the model course and copied all problem sets and local files over from M1003, and all seems to be working with that course.

I will deal with the second course this weekend.

Indeed I should take the time to rewrite everything in PGML, just never seem to have the time.  I will chip away at it.      

Thank you for the help and advice.

In reply to Tim Alderson

Re: Math not rendering in solutions

by Danny Glin -

If this is only happening in courses that were copied from a previous install, then there are a couple of places you can look for differences:

  • Check if there are any weird settings in course.conf or simple.conf.
  • Check the templates/macros directory to see if there are any local copies of macro files that behave differently than the ones from pg or the OPL.

With that being said, if your newly created courses don't have this problem then it's probably easier to stick with those.