--- loncom/homework/hint.pm	2004/03/16 19:47:47	1.51
+++ loncom/homework/hint.pm	2004/08/24 15:56:13	1.55
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # implements the tags that control the hints
 #
-# $Id: hint.pm,v 1.51 2004/03/16 19:47:47 albertel Exp $
+# $Id: hint.pm,v 1.55 2004/08/24 15:56:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,8 +29,9 @@
 package Apache::hinttags; 
 
 use strict;
-use Apache::lonnet;
+use Apache::lonnet();
 use capa;
+use Apache::lonlocal;
 
 BEGIN {
     &Apache::lonxml::register('Apache::hinttags',('hintgroup','hintpart','numericalhint','stringhint','formulahint','optionhint','radiobuttonhint'));
@@ -47,21 +48,30 @@ sub start_hintgroup {
 	my $id=$Apache::inputtags::part;
 	my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
 	if ( $numtries eq '') { $numtries = 0; }
-	my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries");
-	if ($ENV{'request.state'} eq 'construct' &&
-	    defined($Apache::inputtags::params{'hinttries'})) {
-	    $hinttries=$Apache::inputtags::params{'hinttries'};
-	}
-
-	if ( $hinttries eq '') { $hinttries = 1; }
+	my $hinttries=&Apache::response::get_response_param($id,"hinttries",1);
 	&Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
-	my $gradestatus=$Apache::lonhomework::history{"resource.$id.solved"};
-	if ( $numtries < $hinttries || $gradestatus =~ /^correct/) {
+	my $gradestatus=
+	    $Apache::lonhomework::history{"resource.$id.solved"};
+	my $showoncorrect=lc(&Apache::lonxml::get_param('showoncorrect',$parstack,$safeeval));	
+	&Apache::lonxml::debug("onc orrect $showoncorrect, $gradestatus");
+	if ( ($showoncorrect ne 'yes' && $gradestatus =~ /^correct/) ||
+	     ( $numtries < $hinttries) ) {
+	    &Apache::lonxml::debug("Grabbin all");
 	    &Apache::lonxml::get_all_text("/hintgroup",$parser);
 	}
 	&Apache::lonxml::startredirection;
     } elsif ($target eq 'tex') {
 	$result .= '\keephidden{';
+    } elsif ($target eq 'edit') {
+	$result.=&Apache::edit::tag_start($target,$token);
+	$result.=&Apache::edit::select_arg('Show hint even if problem Correct:','showoncorrect',[['no',&mt('No')],['yes',&mt('Yes')]]);
+	$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
+    } elsif ($target eq 'modified') {
+	my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'showoncorrect');
+       if ($constructtag) {
+           $result =&Apache::edit::rebuild_tag($token);
+           $result.=&Apache::edit::handle_insert();
+       }
     }
     @Apache::hint::which=();
     return $result;
@@ -75,8 +85,7 @@ sub end_hintgroup {
 	my $id=$Apache::inputtags::part;
 	my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
 	if ( $numtries eq '') { $numtries = 0; }
-	my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries");
-	if ( $hinttries eq '') { $hinttries = 1; }
+	my $hinttries=&Apache::response::get_response_param($id,"hinttries",1);
 	&Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
 	my $hinttext=&Apache::lonxml::endredirection;
 	if ($Apache::lonhomework::type ne 'exam' &&
@@ -158,7 +167,7 @@ sub end_numericalhint {
 	my $response = $Apache::lonhomework::history{
 			    "resource.$partid.$submitid.submission"};
 	&Apache::lonxml::debug("hintgroup is using $response<br />\n");
-	my $hideunit=&Apache::lonnet::EXT('resource.'.$submitid.'_'.$id.'.turnoffunit');
+	my $hideunit=&Apache::response::get_response_param($partid.'_'.$submitid,'turnoffunit');
 	my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
 	$$args_ref{'response'}=$response;
 	#need to get all possible parms