## WeBWorK Main Forum

### Source of PGML problems

by Yoav Freund -
Number of replies: 5
Where can I find the source files for the following 10 problem set?

https://courses.webwork.maa.org/webwork2/cervone_course/Introduction/?effectiveUser=practice5&user=practice5&key=TQklozqMTgeRLVxjCPdbV3rLZ3Z0Csfp

I like these example problems and would like to construct similar examples, but for this set I don't see a "see source" button. Neither could I find them in the problem library or in Git.

Yoav

### Re: Source of PGML problems

by Davide Cervone -
Hmmm. That seems to be a homework set in a course with my name, but it is not one that I set up. It looks like an example homework set that someone set up for use at a conference or as a tutorial.

All the problems are ones that are in the OPL somewhere but they are scattered around. I was going to send you the set.def file, but it turns out that the problems have been moved to the course's local directory, so that won't really help (other than to give individual file names without their locations).

In any case, I'm not sure these 10 are the best examples to use for starting points for your own code. Many are quite old and use outdated techniques.

Your title suggests you are looking for PGML examples, but none of those 10 are PGML problems. They are plain or traditional PG. If you are looking for PGML examples, there are some linked intot he grey box at the PGML labs page.

Davide

### Re: Source of PGML problems

by Yoav Freund -
Hi Davide,

I see, if these problems are not in PGML, then they are not of much use for me.

I am looking for answers to the following questions:

1) Suppose I have an answer to a question that is of the form $ans = Formula("($a+$b)! / ($a!*$b!)"); where$a and $b are randomly chosen positive integers. I would like the answer checker to compute the numeric answer and compare it to the student's answer. I would also like it to present the expanded expression when giving the correct answer, as this is much more informative than the numerical answer. I know how to do this in PG, but not in PGML. 2) How do I define long answers in PGML ? 3) How do I define hints in PGML. I am interested mostly in giving a hint, for one of the questions in a page, after the student tried answering it 2-3 times. I am also interested in Response-sensitive hints. Can you answer these questions? Are there documents that answer them? Yoav In reply to Yoav Freund ### Re: Source of PGML problems by Davide Cervone - For (1), to get the behavior you want, enclose the formula in quotation marks in your PGML answer. E.g., $a = 2; $b = 3; BEGIN_PGML [_____]{"($a+$b)! / ($a!*$b!)"} END_PGML  will show the correct answer as "(2+3)! / (2!*3!)". Outside of PGML, you should use Compute() rather than Formula() to get this effect. The Compute() function not only return the MathObject that is the result of your expression, but also sets its correct answer to be exactly the string you passed it, so that you control how the correct answer is displayed. For (2), I'm not sure I understand what you mean by a long answer. Do you mean a longer answer blank? To do that in PGML, use more underscores, so  [_____________________]{"x+1"}  would give a longer answer blank than  [______]{"x+1"}  For (3), that would be handled through the usual hint macros. Set the $showHint variable to the number of attempts before you get the hint, and then use HINT() or BEGIN_HINT/END_HINT to provide the hint. If you want the hint to go in the middle of the problem, use two separate BEGIN_PGML/END_PGML blocks with the hint placed in between.

I suppose hints and solutions are something that could be added to PGML to make this easier.

Davide

### Re: Source of PGML problems

by Yoav Freund -
Thanks for (1), that answers my question.

In (2) what I meant is "Solution" not "Answer".

If I understand correctly, the way to add Solutions and answers to
a PGML section is to simply add the commands

BEGIN_HINT
...
END_HINT

or

...

within the

BEGIN_PGML
END_PGML

block?

As for the answer, sample problem 4: http://webwork.maa.org/wiki/SampleProblem4

suggests that the right way to do it is use the block

BEGIN_PGML_SOLUTION

.....
END_PGML_SOLUTION

*outside* of the BEGIN_PGML / END_PGML block...

it really would help if there was a formal definition of the PGML language
somewhere ...

Yoav