Annotation of loncom/homework/hint.pm, revision 1.2

1.1       albertel    1: package Apache::hinttags; 
                      2: 
                      3: use strict;
                      4: use Apache::lonnet;
                      5: 
                      6: sub BEGIN {
                      7:   &Apache::lonxml::register('Apache::hinttags',('hintgroup','hintpart'));
                      8: }
                      9: 
1.2     ! albertel   10: 
1.1       albertel   11: sub start_hintgroup {
1.2     ! albertel   12:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
        !            13:   my $id=$Apache::inputtags::part;
        !            14:   my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
        !            15:   if ( $numtries eq '') { $numtries = 0; }
        !            16:   my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries");
        !            17:   if ( $hinttries eq '') { $hinttries = 1; }
        !            18:   &Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
        !            19:   if ( $numtries < $hinttries ) {
        !            20:     &Apache::lonxml::get_all_text("/hintgroup",$$parser[$#$parser]);
        !            21:   }
        !            22:   return '';
1.1       albertel   23: }
                     24: 
                     25: sub end_hintgroup {
                     26: }
                     27: 
1.2     ! albertel   28: # a part shows if it is on, if no specific parts are on, then default shows
1.1       albertel   29: sub start_hintpart {
1.2     ! albertel   30:   return '';
1.1       albertel   31:   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
                     32: 
                     33:   my $show ='0';
                     34:   if ($target ne 'meta' && $target ne 'grade') {
                     35:     my $args ='';
                     36:     if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
                     37:     my $on = &Apache::run::run("{$args;".'return $on}',$safeeval);
                     38:     if ( $on eq 'default') {
                     39:     } else {
                     40:       my (%results) = &Apache::run::run("{$args; return ".'\%'.$on,$safeeval);
                     41:       my $key;
                     42:       foreach $key (keys %results) {
                     43: 	&Apache::lonxml::debug("Got $key");
                     44:       }
                     45:     }
                     46:     if (!$show) {
                     47:       &Apache::lonxml::get_all_text("/problem",$$parser[$#$parser]);
                     48:     }
                     49:   } else {
                     50:     &Apache::lonxml::get_all_text("/problem",$$parser[$#$parser]);
                     51:   }
                     52:   return '';
                     53: }
                     54: 
                     55: sub end_hintpart {
                     56: }
                     57: 
                     58: 1;
                     59: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>