Diff for /loncom/homework/response.pm between versions 1.210 and 1.216

version 1.210, 2008/12/23 18:09:36 version 1.216, 2009/05/24 13:08:18
Line 54  use strict; Line 54  use strict;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::lonmaxima();  use Apache::lonmaxima();
   use Apache::lonr();
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse'));      &Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse'));
Line 283  sub check_for_previous { Line 284  sub check_for_previous {
     my %previous;      my %previous;
     $previous{'used'} = 0;      $previous{'used'} = 0;
     foreach my $key (sort(keys(%Apache::lonhomework::history))) {      foreach my $key (sort(keys(%Apache::lonhomework::history))) {
  if ($key =~ /resource\.$partid\.$id\.submission$/) {   if ($key =~ /resource\.\Q$partid\E\.\Q$id\E\.submission$/) {
     if ( $last && $key =~ /^(\d+):/ ) {      if ( $last && $key =~ /^(\d+):/ ) {
  next if ($1 >= $last);   next if ($1 >= $last);
     }      }
Line 438  sub end_customresponse { Line 439  sub end_customresponse {
     ${$safeeval->varglob('LONCAPA::customresponse_submission')}=      ${$safeeval->varglob('LONCAPA::customresponse_submission')}=
  $response;   $response;
           
     my $award = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval);      my ($award,$score) = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval);
     if (!&Apache::inputtags::valid_award($award)) {      if (!&Apache::inputtags::valid_award($award)) {
  $error = $award;   $error = $award;
  $award = 'ERROR';   $award = 'ERROR';
Line 446  sub end_customresponse { Line 447  sub end_customresponse {
     &Apache::response::handle_previous(\%previous,$award);      &Apache::response::handle_previous(\%previous,$award);
     $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=      $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=
  $award;   $award;
               if ($award eq 'ASSIGNED_SCORE') {
                   $Apache::lonhomework::results{"resource.$part.$id.awarded"}=1.0*$score;
               }
     if ($error) {      if ($error) {
  $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=   $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=
     $error;      $error;
Line 508  sub start_mathresponse { Line 512  sub start_mathresponse {
  'answerdisplay',$token);   'answerdisplay',$token);
  $result.=&Apache::edit::select_arg('Algebra System:',   $result.=&Apache::edit::select_arg('Algebra System:',
    'cas',     'cas',
    ['maxima'],     ['maxima','R'],
    $token);     $token);
  $result.=&Apache::edit::text_arg('Argument Array:',   $result.=&Apache::edit::text_arg('Argument Array:',
  'args',$token).   'args',$token).
Line 538  sub edit_mathresponse_button { Line 542  sub edit_mathresponse_button {
 #    my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor');  #    my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor');
     my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};      my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
     return(<<ENDFORMULABUTTON);      return(<<ENDFORMULABUTTON);
 <script language="JavaScript">  <script type="text/javascript" language="JavaScript">
 function edit_${id}_${field} (textarea) {  function edit_${id}_${field} (textarea) {
     thenumber = textarea;      thenumber = textarea;
     thedata = document.forms['lonhomework'].elements[textarea].value;      thedata = document.forms['lonhomework'].elements[textarea].value;
     newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable");      newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable");
 }  }
 </script>  </script>
 <a href="javascript:edit_${id}_${field}('${field}');void(0);"><img class="stift" src='$iconpath/stift.gif' alt='$button' title='$button'/></a>  <a href="javascript:edit_${id}_${field}('${field}');void(0);"><img class="stift" src="$iconpath/stift.gif" alt="$button" title="$button" /></a>
 ENDFORMULABUTTON  ENDFORMULABUTTON
 }  }
   
Line 572  sub end_mathresponse { Line 576  sub end_mathresponse {
                 $award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args,                  $award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args,
                                                       &Apache::lonxml::get_param('libraries',$parstack,$safeeval));                                                        &Apache::lonxml::get_param('libraries',$parstack,$safeeval));
             }              }
               if ($cas eq 'R') {
                   my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)];
                   $award=&Apache::lonr::r_run($Apache::response::custom_answer[-1],$response,$args,
                                               &Apache::lonxml::get_param('libraries',$parstack,$safeeval));
               }
   
     if (!&Apache::inputtags::valid_award($award)) {      if (!&Apache::inputtags::valid_award($award)) {
  $error = $award;   $error = $award;
  $award = 'ERROR';   $award = 'ERROR';
Line 948  sub getresponse { Line 958  sub getresponse {
  my $id    = $Apache::inputtags::response[-1];   my $id    = $Apache::inputtags::response[-1];
   
  my $line;   my $line;
    my $startline = $env{'form.scantron_questnum_start.'.$part.'.'.$id};
           if (!$startline) {
               $startline = $Apache::lonxml::counter;
           }
  for ($line = 0; $line < $lines; $line++) {   for ($line = 0; $line < $lines; $line++) {
     my $theline = $Apache::lonxml::counter+$offset-1+$line;              my $theline = $startline+$offset-1+$line;
     $response = $env{"scantron.$theline.answer"};      $response = $env{"scantron.$theline.answer"};
     if ((defined($response)) && ($response ne "") && ($response ne " ")) {      if ((defined($response)) && ($response ne "") && ($response ne " ")) {
  last;   last;
     }      }
        
  }   }
   
  # save bubbled letter for later   # save bubbled letter for later

Removed from v.1.210  
changed lines
  Added in v.1.216


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