## WeBWorK Problems

### Link to a Webpage in PGML

by Daniele Arcara -
Number of replies: 4
How do I insert a link to a webpage if I am using PGML? I tried to use the

\{ htmlLink( "http://...", "description here" ) \}

format that I saw on the wiki, but it did not work. Looking up for more info related to this stuff and PGML, I only found links on how to embed a powerpoint or a video, but not a way to just post a link.

Here is my code, which does not work (i.e., it produces no link, but simply lists the website):

DOCUMENT();

"PGstandard.pl",
"PGML.pl",
"PGcourse.pl"
);

TEXT(beginproblem());

$f = Formula("(2x+1)/(3x-2)");$a = random(2,5,1);
$b = random(2,4,1);$c = random(2,3,1);
$g = Formula("(($a*x+$b)**2)**3");$h = Formula("(x+3)/((2x+1)**$c)");$k = Formula("sqrt(x^2+3)");

BEGIN_PGML

To enter some expressions, you will need to use parenthesis, just like in most calculators.
WeBWorK has a "Preview My Answer" feature that allows you to preview what your expression looks like before you submit your answer. This can be useful to make sure that you have entered the expression correctly.

For example, the fraction [ [$f] ] should be typed with parenthesis as (2x+1)/(3x-2). If you just typed 2x+1/3x-2, it would actually be interpreted it as [ 2x+\frac1{3x}-2 ]. Please read the following page to learn some more "tricks", and how to enter certain functions in WeBWork: \{ htmlLink( "http://webwork.maa.org/wiki/Available_Functions", "http://webwork.maa.org/wiki/Available_Functions" ) \}. Try typing the following expressions correctly: a. [ [$f] = ] [____________]{$f} a. [ [$g] = ] [____________]{$g} a. [ [$h] = ] [____________]{$h} a. [ [$k] = ] [____________]{$k} END_PGML ENDDOCUMENT; Thank you for the help! In reply to Daniele Arcara ### Re: Link to a Webpage in PGML by Paul Pearson - Hi Daniele, With vanilla PG, use BEGIN_TEXT \{ ...Perl code here... \} END_TEXT With (chocolate?) PGML, use BEGIN_PGML [@ ...Perl code here... @]* END_PGML So, what you want is [@ htmlLink(...) @]* Best regards, Paul Pearson In reply to Paul Pearson ### Re: Link to a Webpage in PGML by Daniele Arcara - Thank you for the help! That worked well. Follow-up question: When generating a pdf file for the assignment, it gave me an error. The actual pdf looked pretty good, and I know that I can go in and change the .tex file myself to make it look even better, but is there a way to avoid getting the error altogether? I would prefer if the students did not receive an error when they try to make their own pdf of the assignment (if they chose to do so). But if it is not possible, no big deal. Here is the error message I got: 2 errors occured while generating hardcopy: • Failed to convert TeX to PDF with command 'cd /var/www/html/wwtmp/MA112-SP16/hardcopy/work.aDCiuzce && /usr/bin/pdflatex >pdflatex.stdout 2>pdflatex.stderr hardcopy' (exit=1 signal=0 core=0). • First error in TeX log is: ! Missing$ inserted.
<inserted text>
\$
l.458 ...webwork.maa.org/wiki/Available_Functions}
}
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

### Re: Link to a Webpage in PGML

by Dick Lane -
Some problems in the OPL have syntax errors which are detected only when there is an attempt to generate hardcopy.

Examining an incomplete or mangled PDF, or the corresponding log, may help you to identify which problem in your assignment needs a bug-fix.  If you, as instructor, then view that problem on your screen, you can use an instructor's button to report the bug.

In the case of your posting, searching the PDF for "available" or "available functions" may get you near the defective problem.

### Re: Link to a Webpage in PGML

by Paul Pearson -
Hi all,

You will need to use protect_underbar() since your URL has underscores in it.  The hyperlinks are apparently not working properly in the pdf hardcopy, but this is a minor issue since most people will not click the links in the pdf hardcopy (they will print a paper copy instead).

Best regards,

Paul Pearson

##########################

DOCUMENT();

"PGstandard.pl",
"PGML.pl",
"PGcourse.pl"
);

TEXT(beginproblem());

BEGIN_PGML

Use [| protect_underbar() |] whenever underscore appears in a string outside of math mode.

a. [@ htmlLink( protect_underbar("http://webwork.maa.org/wiki/Available_Functions"), protect_underbar("http://webwork.maa.org/wiki/Available_Functions") ); @]*

- hyperlink works in HTML mode
- link text displays properly in HTML mode
- hyperlink does not work properly in pdf hardcopy: it directs to [| http://webwork.maa.org/wiki/Available |] instead of where it's supposed to go
- link text displays properly in pdf hardcopy

b. [@ htmlLink( protect_underbar("http://webwork.maa.org/wiki/Available_Functions"), "functions webwork understands" ); @]*

- hyperlink works in HTML mode
- link text displays properly in HTML mode
- hyperlink does not work properly in pdf hardcopy: when the mouse hovers over it, there no link
- link text displays properly in pdf hardcopy

END_PGML

ENDDOCUMENT;