Diff for /loncom/homework/hint.pm between versions 1.40 and 1.49

version 1.40, 2003/04/08 02:47:42 version 1.49, 2004/03/12 21:06:19
Line 48  sub start_hintgroup { Line 48  sub start_hintgroup {
  my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};   my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
  if ( $numtries eq '') { $numtries = 0; }   if ( $numtries eq '') { $numtries = 0; }
  my $hinttries=&Apache::lonnet::EXT("resource.$id.hinttries");   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; }   if ( $hinttries eq '') { $hinttries = 1; }
  &Apache::lonxml::debug("found :$id:$numtries:$hinttries:");   &Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
  if ( $numtries < $hinttries ) {   my $gradestatus=$Apache::lonhomework::history{"resource.$id.solved"};
    if ( $numtries < $hinttries || $gradestatus =~ /^correct/) {
     &Apache::lonxml::get_all_text("/hintgroup",$parser);      &Apache::lonxml::get_all_text("/hintgroup",$parser);
  }   }
  &Apache::lonxml::startredirection;   &Apache::lonxml::startredirection;
Line 74  sub end_hintgroup { Line 80  sub end_hintgroup {
  &Apache::lonxml::debug("found :$id:$numtries:$hinttries:");   &Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
  my $hinttext=&Apache::lonxml::endredirection;   my $hinttext=&Apache::lonxml::endredirection;
  if ($Apache::lonhomework::type ne 'exam' &&   if ($Apache::lonhomework::type ne 'exam' &&
     $numtries >= $hinttries && $hinttext !~/^\s*$/) {      $numtries >= $hinttries && $hinttext =~/\S/) {
     $result='<table bgcolor="#dddddd"><tr><td>'.      $result='<table bgcolor="#dddddd"><tr><td>'.
  $hinttext.'</td></tr></table>';   $hinttext.'</td></tr></table>';
  }   }
Line 102  sub start_numericalhint { Line 108  sub start_numericalhint {
     $result.=&Apache::edit::text_arg('Format:','format',$token,4).      $result.=&Apache::edit::text_arg('Format:','format',$token,4).
  &Apache::loncommon::help_open_topic('Numerical_Response_Format');   &Apache::loncommon::help_open_topic('Numerical_Response_Format');
  } elsif ($token->[1] eq 'stringhint') {   } elsif ($token->[1] eq 'stringhint') {
     $result.=&Apache::edit::select_arg('Type:','type',['cs','ci','mc'],$token);      $result.=&Apache::edit::select_arg('Type:','type',
       [['cs','Case Sensitive'],['ci','Case Insensitive'],
        ['mc','Case Insensitive, Any Order']],$token);
  } elsif ($token->[1] eq 'formulahint') {   } elsif ($token->[1] eq 'formulahint') {
     $result.=&Apache::edit::text_arg('Sample Points:','samples',$token,40);      $result.=&Apache::edit::text_arg('Sample Points:','samples',$token,40);
  }   }
Line 142  sub end_numericalhint { Line 150  sub end_numericalhint {
  }   }
  $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);   $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
  my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);   my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
  &Apache::response::setup_params('numericalhint');   &Apache::response::setup_params('numericalhint',$safeeval);
  my $partid=$Apache::inputtags::part;   my $partid=$Apache::inputtags::part;
  my $id=$Apache::inputtags::response['-1'];   my $id=$Apache::inputtags::response['-1'];
  #id submissions occured under   #id submissions occured under
Line 155  sub end_numericalhint { Line 163  sub end_numericalhint {
     $$parstack[$#$parstack];      $$parstack[$#$parstack];
  #need to get all possible parms   #need to get all possible parms
  foreach my $key (keys(%Apache::inputtags::params)) {   foreach my $key (keys(%Apache::inputtags::params)) {
     $expression.= ';my $'. #'      $expression.= ';my $__LC__'. #'
  $key.'="'.$Apache::inputtags::params{$key}.'"';   $key.'="'.$Apache::inputtags::params{$key}.'"';
  }   }
    if ($$tagstack[-1] eq 'formulahint') {
       $expression.=';my $__LC__type="fml";';
    } elsif ($$tagstack[-1] eq 'numericalhint') {
       $expression.=';my $__LC__type="float";';
    }
  $expression.="');";   $expression.="');";
  $result = &Apache::run::run($expression,$safeeval);   my @answer=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
    &Apache::lonxml::debug('answer is'.join(':',@answer));
    @{$safeeval->varglob('CAPARESPONSE_CHECK_LIST_answer')}=@answer;
   
    ($result,my @msgs) = &Apache::run::run($expression,$safeeval);
  &Apache::lonxml::debug("$expression:result:$result:$Apache::lonxml::curdepth");   &Apache::lonxml::debug("$expression:result:$result:$Apache::lonxml::curdepth");
  my ($awards) = split /:/ , $result;   my ($awards) = split /:/ , $result;
  my ($ad) = &Apache::inputtags::finalizeawards(split /,/ , $awards);   my ($ad) = &Apache::inputtags::finalizeawards(split /,/ , $awards);
Line 348  sub end_radiobuttonhint { Line 365  sub end_radiobuttonhint {
  my $response = $Apache::lonhomework::history{   my $response = $Apache::lonhomework::history{
     "resource.$part_id.submission"};      "resource.$part_id.submission"};
  ($response)=&Apache::lonnet::str2hash($response);   ($response)=&Apache::lonnet::str2hash($response);
  if ($answer[0] eq 'foil' && $response eq $answer[1]) {   &Apache::lonxml::debug("response is $response");
     push (@Apache::hint::which,$name);  
    if ($answer[0] eq 'foil') {
       shift(@answer);
       foreach my $answer (@answer) {
    if ($response eq $answer) {
       push (@Apache::hint::which,$name);
       last;
    }
       }
  } elsif ($answer[0] eq 'concept') {   } elsif ($answer[0] eq 'concept') {
     if (ref($Apache::hint::radiobutton{"$part_id.concept.".$answer[1]})) {      shift(@answer);
  my @names=@{ $Apache::hint::radiobutton{"$part_id.concept.".$answer[1]} };      foreach my $answer (@answer) {
  if (grep(/^\Q$response\E$/,@names)) {   if (ref($Apache::hint::radiobutton{"$part_id.concept.".$answer})) {
     push(@Apache::hint::which,$name);      my @names=@{ $Apache::hint::radiobutton{"$part_id.concept.".$answer} };
       if (grep(/^\Q$response\E$/,@names)) {
    push(@Apache::hint::which,$name);
    last;
       }
  }   }
     }      }
  }   }

Removed from v.1.40  
changed lines
  Added in v.1.49


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