WeBWorK Main Forum

Controlling the correct answer preview in MathObject

by Yoav Freund -
Number of replies: 13
I would like to write questions in Combinatorics. Things like "how many ways
are there to order 2 white balls, 3 red balls and one greenball.

I have several questions:
1) How can I expand the set of functions recognized to include, in addition to
factorial (which is already included) the binomial function Binom(m,n) and the
multinomial function multi(m,n1,n2,n3,...,n_k) ? so that the students can use these functions in their answers and not get bogged down in numerical computations.

2) When the student chooses to see the correct answer, I would like the answer
to be the original formula (containing factorials, binomials etc) with a nice typeset, rather than the numeric answer? I do however, what to compare the correct answer to the student's answer numerically as there are many ways to compute the correct answer.

3) Is there a tutorial somewhere that explains some pedagogical approaches to WW? How to write questions that are more instructive, in other words, detect the correct parts of the student's answer, use hints and use a multi-step questions?

Re: Controlling the correct answer preview in MathObject

by Jason Aubrey -
Hi Yoav,

I'm sure others will chime in here, but to offer an approach to question (1). Permutations and combinations are defined in pg/lib/contextIntegerFunctions.pl.

https://github.com/openwebwork/pg/blob/master/macros/contextIntegerFunctions.pl

So: Download this file and place a copy in your course macros directory (accessible from within the file manager). Macros in the course macros directory trump macros in pg/macros and those in the problem library. Then you can add custom functions which will be available when you load contextIntegerFunctions.pl in a loadMacros() statement.

Also, you might be interested in Nandor Sieben's collection of combinatorics problems:

https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/NAU

Instructions for installing his graph theory library are here:

https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/NAU/lib

If you're on the MAA servers I believe this is available, and if not we can easily install it.

Hope this helps with (1).

Jason

Re: Controlling the correct answer preview in MathObject

by Yoav Freund -
Thanks Jason,

What I find frustrating is finding all these different pieces of information...

Is there something like a reference manual or at least a master index for
PG/MathObjects/libraries/macros ?

I know about the webwork documentation wiki, but I find that very hard to navigate. Are there any usable PDF documents ?

Yoav

Re: Controlling the correct answer preview in MathObject

by Davide Cervone -
I understand the frustration with the Wiki.

These past few weeks I've been working hard on the documentation for MathObjects, at least from an authoring standpoint. So if you haven't looked there recently, you might try it and see if it is any better. I've reworked the introduction page, and added a number of new pages, including individual pages for each of the main MathObject classes. These give examples of creating and working with each type of object, what its answer-checker options are, and lists of its methods and properties.

I still have to work on the Context information, but hope to improve that as well.

There is not very much in the way of documentation about extending MathObjects, and that is definitely one of the things that needs work. A number of the sample problem techniques on the Wiki do this, but as far as I know, there isn't a comprehensive list for these.

There are some examples in the pg/doc/MathObjects directory, and I've also updated that documentation, which you can check out on my fork of pg-dev. The extensions directory in particular give some examples of extending MathObjects in different ways.

Hope that helps a little.

Davide

Re: Controlling the correct answer preview in MathObject

by Yoav Freund -
Downloading your fork of pg-dev I see that the documentation is written mostly in the POD format that I am not familiar with. Is there a recommended way to view and navigate these documentation files? Can I transform them into HTML files or PDF files with links?

Yoav

Re: Controlling the correct answer preview in MathObject

by William Wheeler -
Dear Yoav,

Your Perl installation should include programs pod2html and pod2latex that can be used to convert .pod files to HTML and LaTeX (from whence you can generate PDF files).

You can use either the man command or the perldoc command to get instructions for using pod2html and pod2latex.

Sincerely,

Bill Wheeler

by Yoav Freund -
Thanks!

Yoav

Re: Controlling the correct answer preview in MathObject

by Yoav Freund -
Hi Jason,

I also managed to upload them using the File Manager.

However, I am failing to add the problems to a problem set on my account so that I can try them. Maybe this has to do with the .def file that visible
sets seem to have? How do I create this .def file ?

As an alternative, are all of the problems in the Git repository also available through the Library browser in WebWorks instructor tools?

Yoav

Re: Controlling the correct answer preview in MathObject

by Jason Aubrey -
Hi Yoav,

Nandor's problems should be available already on your server if you have a reasonably up to date copy of the problem library.

So, I'd suggest that you first check in your Library browser.

Browsing via the "NPL Directory" button will allow you to directly look for the NAU/setCount directory.  If you browse via the default view of the problem library, then you'll have to search by subject/chapter/section.

Since you uploaded them to your file manager, you can also find them in the Library browser by browsing via the "Local Problems" button which will allow you to browse your course directory and display problem collections you select there.

However, unless somebody has compiled and installed Nandor's C code and associated perl module on the server running your webwork installation, then his graph theory problems that use it will display an error.  (If you're on an MAA server and get such an error let me know).

Oh, regarding your last question: Yes, except for on collection we added this week (contributed by Robin Cruz, College of Idaho, for introductory statistics) all of the problems in the git repository should be available in your library browser as long as your copy of the library is reasonably up to date (i.e. updated sometime this spring or summer).

BTW, bug fixes come in all the time for the problem library, so it's a good idea to up date it regularly.  It's pretty safe to do so also, so for example, you could put it on a monthly cron job and still sleep pretty well.

Hope this helps,

Jason

PS: If you're familiar with IRC, we are regularly on #webwork on freenode.net and can answer questions there live when we're available.

Re: Controlling the correct answer preview in MathObject

by Davide Cervone -
Jason has already pointed you to one of the key examples that you will need for your question (1). There is also the second example on the Adding Functions example on the wiki.

In order to do your multi() function, however, you will need to do a little more work, since these examples are only for one or two arguments. To do more than that, you will need to make a new subclass of the Parser::Function class and implement a few additional methods that handle checking the parameters, evaluating the function, and so on.

There are no official examples for that, but the code at pg/lib/Parser/Function/ are the ones that implement the existing functions. In particular, numeric.pm and numeric2.pm are the ones to look at.

The _check() routine is the one that checks parameters during the parsing, and these call service routines that are in lib/Parser/Function.pm. You would need to make your own version of these for handling arbitrary numbers of parameters (or at least even numbers). You would also need to make _eval() and _call() methods that handle arbitrary parameters.

I will see if I can work up an example for you, but you can start there yourself if you want.

As for question (2), the formatStudentAnswer option for the answer checkers controls how the "entered" value is displayed. By default it is "evaluated", meaning the final result, but you can change it to "parsed" or "reduced" if you want to show the original formula instead. E.g.,

    ANS(\$ans->cmp(formatStudentAnswer=>"parsed"));

I don't know the answer to question (3). Multi-step questions are still not easy to produce, but people are working on that. There are some macros in pg/macros/compoundProblem.pl that implement one approach, but it has its problems.

Answer hints can be handled in several ways. There are examples on the wiki; see Answer Hints, for an example using the answerHints.pl macros.

Hope that helps.

Davide

Re: Controlling the correct answer preview in MathObject

by Yoav Freund -
Dear Davide,

Is PGML compatible with CompoundProblems?

Going through the examples is helpful, but in order to work on new problems,
rather than edit old problems, it would be extremely useful to have a reference manual for PGML / MathObjects as well as for other more specialized items such as compound problems.

Without those I am just writing and praying...

A manual for the PGML markdown language would be particularly useful.

I saw some useful documentation in compoundProblem.pl but none in PGML.pl

Yoav

Re: Controlling the correct answer preview in MathObject

by Davide Cervone -
Is PGML compatible with CompoundProblems?

It should be. I haven't tried it out specifically, but I don't see why not.

I have just completed an expansion of the MathObject documentation on the WeBWork Wiki, so that should be a much better reference than before. But you are right, there is nothing on PGML. I never quite finished PGML and still considered it in experimental shape when it was included in WeBWorK, and so had not done the documentation, and haven't gotten back to it. I had hoped to work on that this summer, but the other MathObject documentation took all my available time.

The compounProblem macros desperately need rewriting, but that will have to wait as well. But, as you say, at least there is some documentation there. The best I can offer for PGML is the PGML lab linked from the PGlabs wiki page. In the first link, Problem 1 is a lab for PGML and it has a number of examples that describe some of how it works. The "for reference" menus list all the commands, so perhaps that is some help.

The second problem was supposed to be a lab for the Typeset context (which is part of PGML), but it doesn't seem to be working at the moment.

Davide

Re: Controlling the correct answer preview in MathObject

by Yoav Freund -
Hi Davide,

The new documentation of MathObjects is great.

The annotated PGML problem is also great: http://webwork.maa.org/wiki/SampleProblem4

I wish there was some way for me to print out the list of PGML example problems (https://courses.webwork.maa.org/webwork2/cervone_course/PGML-examples/?login_practice_user=true) together with the source code, that could serve as searchable/browsable documentation. Without it switching back and forth between browser windows is tiresome.

Yoav