Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.231 and 1.240

version 1.231, 2008/09/09 13:56:49 version 1.240, 2010/10/14 04:02:07
Line 305  sub start_numericalresponse { Line 305  sub start_numericalresponse {
  my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');   my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');
  &Apache::lonxml::debug("Got unit $hideunit for $partid $id");   &Apache::lonxml::debug("Got unit $hideunit for $partid $id");
  #no way to enter units, with radio buttons   #no way to enter units, with radio buttons
  if (lc($hideunit) eq "yes") {   if ((lc($hideunit) eq "yes") && ($Apache::lonhomework::type ne 'exam')) {
     my $unit=&Apache::lonxml::get_param_var('unit',$parstack,      my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
     $safeeval);      $safeeval);
     if ($unit =~ /\S/) { $result.=" (in $unit) "; }      if ($unit =~ /\S/) { $result.=" (in $unit) "; }
  }   }
         if (($token->[1] eq 'formularesponse') &&   
             ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')) {  
         }  
  if (  &Apache::response::show_answer() ) {   if (  &Apache::response::show_answer() ) {
     &set_answertext($tag_internal_answer_name,$target,$token,$tagstack,      &set_answertext($tag_internal_answer_name,$target,$token,$tagstack,
     $parstack,$parser,$safeeval,-1);      $parstack,$parser,$safeeval,-1);
Line 430  sub check_submission { Line 427  sub check_submission {
  }   }
     } elsif ($tag eq 'numericalresponse') {      } elsif ($tag eq 'numericalresponse') {
  $$args_ref{'type'}='float';   $$args_ref{'type'}='float';
       } elsif ($tag eq 'stringresponse') {
           if ($$args_ref{'type'} eq '') {
               $$args_ref{'type'} = 'ci';
           }
     }      }
       
     &add_in_tag_answer($parstack,$safeeval);      &add_in_tag_answer($parstack,$safeeval);
   
     if (!%answer) {      if (!%answer) {
Line 532  sub end_numericalresponse { Line 533  sub end_numericalresponse {
    $Apache::inputtags::params{'sig'});     $Apache::inputtags::params{'sig'});
  }   }
  &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");   &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");
  if ($Apache::lonhomework::type eq 'survey' &&                  if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
     ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||                       $ad eq 'EXACT_ANS')) {
      $ad eq 'EXACT_ANS')) {      if ($Apache::lonhomework::type eq 'survey') {
     $ad='SUBMITTED';          $ad='SUBMITTED';
  }      } elsif ($Apache::lonhomework::type eq 'surveycred') {
                           $ad='SUBMITTED_CREDIT';
                       } elsif ($Apache::lonhomework::type eq 'anonsurvey') {
                           $ad='ANONYMOUS';
                       } elsif ($Apache::lonhomework::type eq 'anonsurveycred') {
                           $ad='ANONYMOUS_CREDIT';                     
                       }
                   }
  &Apache::response::handle_previous(\%previous,$ad);   &Apache::response::handle_previous(\%previous,$ad);
  $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;   $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
  $Apache::lonhomework::results{"resource.$partid.$id.awardmsg"}=$msg;   $Apache::lonhomework::results{"resource.$partid.$id.awardmsg"}=$msg;
Line 584  sub end_numericalresponse { Line 592  sub end_numericalresponse {
  &get_table_sizes($number_of_bubbles,$bubble_display);   &get_table_sizes($number_of_bubbles,$bubble_display);
     my $j=0;      my $j=0;
     my $cou=0;      my $cou=0;
     $result.='\vskip -1 mm \noindent \begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]';      $result.='\vskip 2mm \noindent ';
       $result .= '\textbf{'.$Apache::lonxml::counter.'.} \vskip -3mm ';
   
     for (my $i=0;$i<$number_of_tables;$i++) {      for (my $i=0;$i<$number_of_tables;$i++) {
  $result.='\vskip -1 mm \noindent \setlength{\tabcolsep}{2 mm}\begin{tabular}{';   if ($i == 0) {
       $result .= '\vskip -1mm ';
    } else {
       $result .= '\vskip 1mm ';
    }
    $result.='\noindent \setlength{\tabcolsep}{2 mm}\hskip 2pc\begin{tabular}{';
  for (my $ind=0;$ind<$table_range[$j];$ind++) {   for (my $ind=0;$ind<$table_range[$j];$ind++) {
     $result.='p{3 mm}p{'.$celllength.' mm}';      $result.='p{3 mm}p{'.$celllength.' mm}';
  }   }
Line 599  sub end_numericalresponse { Line 614  sub end_numericalresponse {
  $j++;   $j++;
  $result.='\\\\\end{tabular}\vskip 0 mm ';   $result.='\\\\\end{tabular}\vskip 0 mm ';
     }      }
     $result.='\end{enumerate}';  
  } else {   } else {
     $increment = &Apache::response::repetition();      $increment = &Apache::response::repetition();
  }   }
Line 607  sub end_numericalresponse { Line 621  sub end_numericalresponse {
  }   }
         if (($target eq 'web') && ($tag eq 'formularesponse')          if (($target eq 'web') && ($tag eq 'formularesponse')
             && ($Apache::lonhomework::type ne 'exam') && ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')              && ($Apache::lonhomework::type ne 'exam') && ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER')
     && (&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoneditor') ne 'no')){         && (&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffeditor') ne 'yes')) {
            $result.=&Apache::response::edit_mathresponse_button($id,"HWVAL_$id");              $result.=&Apache::response::edit_mathresponse_button($id,"HWVAL_$id");
 #hier  
         }          }
                           
  &Apache::response::setup_prior_tries_hash(\&format_prior_response_numerical);   &Apache::response::setup_prior_tries_hash(\&format_prior_response_numerical);
Line 752  sub end_numericalresponse { Line 765  sub end_numericalresponse {
     if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {      if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
  my $error;   my $error;
  if ($tag eq 'formularesponse') {   if ($tag eq 'formularesponse') {
     $error=&mt('Computer\'s answer is incorrect ("[_1]").',join(', ',@$response));      $error=&mt("Computer's answer is incorrect ([_1]).",'"'.join(', ',@$response).'"');
  } else {   } else {
     # answer failed check if it is sig figs that is failing      # answer failed check if it is sig figs that is failing
     my ($ad,$msg)=&check_submission($response,$partid,$id,      my ($ad,$msg)=&check_submission($response,$partid,$id,
     $tag,$parstack,      $tag,$parstack,
     $safeeval,1);      $safeeval,1);
       $error=&mt("Computer's answer is incorrect ([_1]).",'"'.join(', ',@$response).'"').' ';
     if ($sigline ne '') {      if ($sigline ne '') {
  $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] or significant figures [_3] need to be adjusted.',join(', ',@$response),$tolline,$sigline);   $error.=&mt('It is likely that the tolerance range [_1] or significant figures [_2] need to be adjusted.',$tolline,$sigline);
     } else {      } else {
  $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] needs to be adjusted.',join(', ',@$response),$tolline);   $error.=&mt('It is likely that the tolerance range [_1] needs to be adjusted.',$tolline);
     }      }
  }   }
  if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {   if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
Line 1161  sub end_stringresponse { Line 1175  sub end_stringresponse {
     my @args = ('type');      my @args = ('type');
     my $args_ref = &setup_capa_args($safeeval,$parstack,      my $args_ref = &setup_capa_args($safeeval,$parstack,
     \@args,$response);      \@args,$response);
                       if ($$args_ref{'type'} eq '') {
                           $$args_ref{'type'} = 'ci';
                       }
     &add_in_tag_answer($parstack,$safeeval);      &add_in_tag_answer($parstack,$safeeval);
     my (@final_awards,@final_msgs,@names);      my (@final_awards,@final_msgs,@names);
     foreach my $name (keys(%answer)) {      foreach my $name (keys(%answer)) {
Line 1178  sub end_stringresponse { Line 1194  sub end_stringresponse {
  push(@names,$name);   push(@names,$name);
  &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");   &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");
     }      }
     my ($ad, $msg, $name) =       ($ad, $msg, my $name) = 
  &Apache::inputtags::finalizeawards(\@final_awards,   &Apache::inputtags::finalizeawards(\@final_awards,
    \@final_msgs,     \@final_msgs,
    \@names,1);     \@names,1);
  }   }
  if ($Apache::lonhomework::type eq 'survey' &&                  if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
     ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||                       $ad eq 'EXACT_ANS')) {
      $ad eq 'EXACT_ANS')) {      if ($Apache::lonhomework::type eq 'survey') {
     $ad='SUBMITTED';          $ad='SUBMITTED';
  }      } elsif ($Apache::lonhomework::type eq 'surveycred') {
                           $ad='SUBMITTED_CREDIT';
                       } elsif ($Apache::lonhomework::type eq 'anonsurvey') {
                           $ad='ANONYMOUS';
                       } elsif ($Apache::lonhomework::type eq 'anonsurveycred') {
                           $ad='ANONYMOUS_CREDIT';
                       }
                   }
  &Apache::response::handle_previous(\%previous,$ad);   &Apache::response::handle_previous(\%previous,$ad);
  $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;   $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
  $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg;   $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg;

Removed from v.1.231  
changed lines
  Added in v.1.240


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