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!
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):
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.
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:
##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();
This worked for me. (I actually tested it this time. :-) )
That's weird, because it's not working at all for me:
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.
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.
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