[LON-CAPA-cvs] cvs: loncom /homework hint.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 16 Mar 2004 22:24:31 -0000


albertel		Tue Mar 16 17:24:31 2004 EDT

  Modified files:              
    /loncom/homework	hint.pm 
  Log:
  - adding <hintgroup> param showoncorrect, defaults to no, BUG#1028
  
  
Index: loncom/homework/hint.pm
diff -u loncom/homework/hint.pm:1.52 loncom/homework/hint.pm:1.53
--- loncom/homework/hint.pm:1.52	Tue Mar 16 17:00:51 2004
+++ loncom/homework/hint.pm	Tue Mar 16 17:24:31 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # implements the tags that control the hints
 #
-# $Id: hint.pm,v 1.52 2004/03/16 22:00:51 albertel Exp $
+# $Id: hint.pm,v 1.53 2004/03/16 22:24:31 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'));
@@ -49,13 +50,28 @@
 	if ( $numtries eq '') { $numtries = 0; }
 	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 when 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;