WeBWorK Main Forum

Changing display of Hints

Changing display of Hints

by Kyle Maddox -
Number of replies: 7
I would like to use BEGIN_HINT / END_HINT to display some text but I don't like the text "HINT:" that is automatically added at the start. Is there a way to change it?

Thanks!
In reply to Kyle Maddox

Re: Changing display of Hints

by Michael Gage -
Try putting 
sub HINT_HEADING  {
return ' ';
}
at the top of the problem where you want to get rid of the hint.

(You'll get some warnings about redefining subroutines in your apache error log which you can ignore. ) 

You could try 
sub HINT_HEADING {
return 'foobar'; 
}
to get a clearer idea of what is being changed.

The relevant sections of PGbasicmacros where these things are defined are:

and HINT (where HINT_HEADING is used):
In reply to Michael Gage

Re: Changing display of Hints

by Michael Gage -
I'm afraid that putting 

sub HINT_HEADING   {
return ' ';
}
at the top of the problem where you want to get rid of the hint.

Is not enough.  By the time it gets to that change the behavior of BEGIN_HINT/END_HINT has already been defined and redefining
HINT_HEADING has no effect.

However defining that macro in PGcourse.pl and loading the PGcourse.pl file does work.

and defining this at the top of the problem where you want to get rid of hints also works:

PG_restricted_eval("
sub HINT_HEADING {
               return ' bar';
}
");

It forces evaluation at run time.



In reply to Michael Gage

Re: Changing display of Hints

by Kyle Maddox -
It looks like that block of code actually isn't doing anything on my end. To be clear, the following image demonstrates what I'd like to do:

xlGLMKh.png
In reply to Kyle Maddox

Re: Changing display of Hints

by Michael Gage -
##DESCRIPTION
##  Algebra problem: true or false for inequality 
##ENDDESCRIPTION

## DBsubject(WeBWorK)
## DBchapter(Projects)
## Date(6/3/2002)
## TitleText1('Precalculus')
## AuthorText1('Stewart, Redlin, Watson')
## EditionText1('3')
## Section1('1.1')
## Problem1('22')
## KEYWORDS('algebra', 'inequality', 'fraction')
########################################################################
DOCUMENT();      
loadMacros(
   "PGstandard.pl",     # Standard macros for PG language
   "MathObjects.pl",
   "PGinfo.pl",
   #"source.pl",          # allows code to be displayed on certain sites.
   #"PGcourse.pl",      # Customization file for the course
);
PG_restricted_eval("
     sub HINT_HEADING {
           return ' bar';
     }
");
# Print problem number and point value (weight) for the problem
TEXT(beginproblem());
# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;
##############################################################
#
#  Setup
#
#
Context("Numeric");
#listVariables();
$pi = Real("pi");
##############################################################
#
#  Text
#
#
$pi = Real($PI);
Context()->texStrings;
BEGIN_TEXT
Enter a value for \(\pi\):
\{$pi->ans_rule\}
$PAR
END_TEXT
Context()->normalStrings;
##############################################################
#
#  Answers
#
#
ANS($pi->with(tolerance=>.0001)->cmp);
# relative tolerance --3.1412 is incorrect but 3.1413 is correct
# default tolerance is .01 or one percent.
BEGIN_HINT
This is a hint. The header subroutine HINT_HEADING() was modified in PGcourse.pl to "FooBar" and again in the problem heading to "bar".
END_HINT
BEGIN_SOLUTION
This is a solution
END_SOLUTION
ENDDOCUMENT();        
In reply to Michael Gage

Re: Changing display of Hints

by Michael Gage -
This worked for me. (I actually tested it this time. :-) )

In reply to Michael Gage

Re: Changing display of Hints

by Kyle Maddox -
That's weird, because it's not working at all for me:

dRfTMft.png
I just copied and pasted exactly what you had. In your code, the PGcourse.pl macro was commented out, so that shouldn't be a problem.

I wonder why it isn't working on my end.
In reply to Kyle Maddox

Re: Changing display of Hints

by Michael Gage -
Not sure.  I'm using the develop branch but I wouldn't expect that to make a difference.  Sometimes some javascripts are cached by the browser. Doing shift reload might clear that.  Otherwise I'm at a loss.  I copied and pasted it back into my machine just to make sure.

-- Mike