WeBWorK Problems

Writing conditional hints, possible?

Writing conditional hints, possible?

by Andrew Parker -
Number of replies: 4
In a multi-step problem, I'd like to only offer a hint on the first incorrect step of the problem. Is this possible?
In reply to Andrew Parker

Re: Writing conditional hints, possible?

by Paul Pearson -
Hi Andrew,

If you're checking each answer blank separately (not using MulitAnswer), then you want to use answerHints.pl and ->withPostFilter(AnswerHints()) as on this page:

http://webwork.maa.org/wiki/AnswerHints


If you're using parserMultiAnswer.pl, the ->setMessage() method on this page is what you would want to use:

http://webwork.maa.org/wiki/MultiAnswerProblems

Good luck!

Paul Pearson
In reply to Paul Pearson

Re: Writing conditional hints, possible?

by Andrew Parker -
I'm sorry, I wasn't clear enough with my question.

Using BEGIN_HINT/END_HINT, I'd like to offer guidance on finding the next step of the solution after a certain number of incorrect attempts. I am using separate answer blanks. Is there a binary "correctness" value associated to answer1, answer2, etc, that I can conditionally reference within a BEGIN_HINT/END_HINT?

Context: I have a 7-part problem, solving a non-homogeneous second-order linear differential equation with constant coefficients, and I'd prefer not to have hints for all seven parts appearing at once.
In reply to Andrew Parker

Re: Writing conditional hints, possible?

by Paul Pearson -
Hi Andrew,

The things you are trying to accomplish are similar to a few of the macros I wrote (ConditionalHint.pl and PeriodicRerandomization.pl). The IsAnswerCorrect() method in ConditionalHint.pl is probably what you want to use, although if you want to build something that's more complex you may want to also look at PeriodicRerandomization.pl. If you write a macro, please consider sharing it. I would be happy to help you get it put into the OPL.

Here are links to the macros:

https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/macros/FortLewis/ConditionalHint.pl

https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/macros/FortLewis/PeriodicRerandomization.pl

Best regards,

Paul Pearson

In reply to Paul Pearson

Re: Writing conditional hints, possible?

by Paul Pearson -
Hi,

In case you were wondering, there are two ways to install these macros.

1. Install them locally: only the course that has the macros in its course templates/macros directory will be able to use them. This method of installation can be done by instructors, and macros put into the templates/macros directory of a course will override any macros by the same name installed globally. To install a macro locally, log in to WeBWorK and click on "File Manager" and then double click the "macros" directory. This will put you in the "templates/macros" directory for the course. Then, click the "New File" button. When prompted for a file name, enter the name of the macro file you want to create, e.g. ConditionalHint.pl . Find the source code of the macro you would like to use on GitHub, e.g.,

https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/macros/FortLewis/ConditionalHint.pl

Then, copy and paste the source code from GitHub into the file editor in WeBWorK and save the file (there should be a "Save" button at the bottom of the file editor within webwork). That's it -- the macro is installed locally and can be loaded by loadMacros(); just like any other macro file.

2. Install them globally: all courses on the server can use them. This will require system administrator privileges to accomplish. The macro files contributed to WeBWorK by individuals are in the OPL in the location OpenProblemLibrary/macros . I don't know off the top of my head if anything special (i.e., beyond the normal procedure for installing the OPL) is necessary to get the macros in this location working. Perhaps Jason Aubrey or someone else has a definitive answer.

Good luck!

Paul Pearson