File:  [LON-CAPA] / loncom / homework / hint.pm
Revision 1.2: download - view: text, annotated - select for diffs
Thu Dec 21 18:13:33 2000 UTC (23 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- most lectureonline tags work now, except for <hintpart> and <numericalresponse>

    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: 
   10: 
   11: sub start_hintgroup {
   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 '';
   23: }
   24: 
   25: sub end_hintgroup {
   26: }
   27: 
   28: # a part shows if it is on, if no specific parts are on, then default shows
   29: sub start_hintpart {
   30:   return '';
   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>