Diff for /loncom/homework/grades.pm between versions 1.188 and 1.191

version 1.188, 2004/04/24 08:31:57 version 1.191, 2004/04/29 04:47:47
Line 3422  sub scantron_uploads { Line 3422  sub scantron_uploads {
     my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};      my $cname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,      my @files=&Apache::lonnet::dirlist('userfiles',$cdom,$cname,
     &Apache::loncommon::propath($cdom,$cname));      &Apache::loncommon::propath($cdom,$cname));
       $result.="<option></option>";
     foreach my $filename (@files) {      foreach my $filename (@files) {
  ($filename)=split(/&/,$filename);   ($filename)=split(/&/,$filename);
  if ($filename!~/^scantron_orig_/) { next ; }   if ($filename!~/^scantron_orig_/) { next ; }
Line 3435  sub scantron_uploads { Line 3436  sub scantron_uploads {
 sub scantron_scantab {  sub scantron_scantab {
     my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');      my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
     my $result='<select name="scantron_format">'."\n";      my $result='<select name="scantron_format">'."\n";
       $result.='<option></option>'."\n";
     foreach my $line (<$fh>) {      foreach my $line (<$fh>) {
  my ($name,$descrip)=split(/:/,$line);   my ($name,$descrip)=split(/:/,$line);
  if ($name =~ /^\#/) { next; }   if ($name =~ /^\#/) { next; }
Line 3451  sub scantron_CODElist { Line 3453  sub scantron_CODElist {
     my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);      my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
     my $namechoice='<option></option>';      my $namechoice='<option></option>';
     foreach my $name (@names) {      foreach my $name (@names) {
    if ($name =~ /^error: 2 /) { next; }
  $namechoice.='<option value="'.$name.'">'.$name.'</option>';   $namechoice.='<option value="'.$name.'">'.$name.'</option>';
     }      }
     $namechoice='<select name="scantron_CODElist">'.$namechoice.'</select>';      $namechoice='<select name="scantron_CODElist">'.$namechoice.'</select>';
Line 3512  sub scantron_selectphase { Line 3515  sub scantron_selectphase {
             <td> Each CODE is only to be used once:</td><td> $CODE_unique </td>              <td> Each CODE is only to be used once:</td><td> $CODE_unique </td>
           </tr>            </tr>
           <tr bgcolor="#ffffe6">            <tr bgcolor="#ffffe6">
             <td>  
 <!-- FIXME this is lazy, a single parse of the set should let me know what this is -->  
               Last line to expect an answer on: </td><td>  
                 <input type="text" name="scantron_maxbubble" />  
     </td>  
           </tr>  
           <tr bgcolor="#ffffe6">  
     <td> Options: </td>      <td> Options: </td>
             <td>              <td>
                 <input type="checkbox" name="scantron_options" value="redo_skipped"/> Redo skipped records <br />                  <input type="checkbox" name="scantron_options_redo" value="redo_skipped"/> Redo skipped records <br />
                 <input type="checkbox" name="scantron_options" value="ignore_corrections"/> Ignore Original Corrections                  <input type="checkbox" name="scantron_options_ignore" value="ignore_corrections"/> Ignore Original Corrections
     </td>      </td>
           </tr>            </tr>
           <tr bgcolor="#ffffe6">            <tr bgcolor="#ffffe6">
Line 3689  sub scantron_fixup_scanline { Line 3685  sub scantron_fixup_scanline {
        $args->{'username'}.':'.$args->{'domain'});         $args->{'username'}.':'.$args->{'domain'});
  }   }
     } elsif ($field eq 'CODE') {      } elsif ($field eq 'CODE') {
  if (length($args->{'CODE'}) > $$scantron_config{'CODElength'}) {   if ($args->{'CODE'} eq 'use_unfound') {
     return ($line,1,'New CODE value too large');      &scan_data($scan_data,"$whichline.useCODE",'1');
  }   } else {
  if (length($args->{'CODE'}) < $$scantron_config{'CODElength'}) {      if (length($args->{'CODE'}) > $$scantron_config{'CODElength'}) {
     $args->{'CODE'}=sprintf('%-'.$$scantron_config{'CODElength'}.'s',   return ($line,1,'New CODE value too large');
        $args->{'CODE'});      }
  }      if (length($args->{'CODE'}) < $$scantron_config{'CODElength'}) {
  substr($line,$$scantron_config{'CODEstart'}-1,   $args->{'CODE'}=sprintf('%-'.$$scantron_config{'CODElength'}.'s',$args->{'CODE'});
        $$scantron_config{'CODElength'})=$args->{'CODE'};      }
  if ($args->{'CODE'}=~/^\s*$/) {      substr($line,$$scantron_config{'CODEstart'}-1,
     &scan_data($scan_data,"$whichline.CODE",$args->{'CODE'});     $$scantron_config{'CODElength'})=$args->{'CODE'};
   #    if ($args->{'CODE'}=~/^\s*$/) {
   # &scan_data($scan_data,"$whichline.CODE",$args->{'CODE'});
   #    }
  }   }
     } elsif ($field eq 'answer') {      } elsif ($field eq 'answer') {
  my $length=$scantron_config->{'Qlength'};   my $length=$scantron_config->{'Qlength'};
Line 3737  sub scantron_parse_scanline { Line 3736  sub scantron_parse_scanline {
     my $data=substr($line,0,$$scantron_config{'Qstart'}-1);      my $data=substr($line,0,$$scantron_config{'Qstart'}-1);
     if ($$scantron_config{'CODElocation'} ne 0) {      if ($$scantron_config{'CODElocation'} ne 0) {
  if ($$scantron_config{'CODElocation'} < 0) {   if ($$scantron_config{'CODElocation'} < 0) {
     $record{'scantron.CODE'}=substr($data,$$scantron_config{'CODEstart'}-1,      $record{'scantron.CODE'}=substr($data,
       $$scantron_config{'CODEstart'}-1,
     $$scantron_config{'CODElength'});      $$scantron_config{'CODElength'});
       if (&scan_data($scan_data,"$whichline.useCODE")) {
    $record{'scantron.useCODE'}=1;
       }
  } else {   } else {
     #FIXME interpret first N questions      #FIXME interpret first N questions
  }   }
Line 3836  sub scantron_process_corrections { Line 3839  sub scantron_process_corrections {
     'username'=>$ENV{'form.scantron_username'},      'username'=>$ENV{'form.scantron_username'},
     'domain'=>$ENV{'form.scantron_domain'}});      'domain'=>$ENV{'form.scantron_domain'}});
     } elsif ($ENV{'form.scantron_corrections'} =~ /^(duplicate|incorrect)CODE$/) {      } elsif ($ENV{'form.scantron_corrections'} =~ /^(duplicate|incorrect)CODE$/) {
  my $newCODE=$ENV{'form.scantron_CODE'};   my $resolution=$ENV{'form.scantron_CODE_resolution'};
    my $newCODE;
    if      ($resolution eq 'use_unfound') {
       $newCODE='use_unfound';
    } elsif ($resolution eq 'use_found') {
       $newCODE=$ENV{'form.scantron_CODE_selectedvalue'};
    } elsif ($resolution eq 'use_typed') {
       $newCODE=$ENV{'form.scantron_CODE_newvalue'};
    }
  ($line,$err,$errmsg)=   ($line,$err,$errmsg)=
     &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which,      &scantron_fixup_scanline(\%scantron_config,$scan_data,$line,$which,
      'CODE',{'CODE'=>$newCODE});       'CODE',{'CODE'=>$newCODE});
Line 3868  sub scantron_validate_file { Line 3879  sub scantron_validate_file {
     if ($ENV{'form.scantron_corrections'}) {      if ($ENV{'form.scantron_corrections'}) {
  &scantron_process_corrections($r);   &scantron_process_corrections($r);
     }      }
       $r->print("<p>Gathering neccessary info.</p>");$r->rflush();
       my $max_bubble=&scantron_get_maxbubble($r);
     #get the student pick code ready      #get the student pick code ready
     $r->print(&Apache::loncommon::studentbrowser_javascript());      $r->print(&Apache::loncommon::studentbrowser_javascript());
     my $result= <<SCANTRONFORM;      my $result= <<SCANTRONFORM;
Line 3875  sub scantron_validate_file { Line 3888  sub scantron_validate_file {
   <input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" />    <input type="hidden" name="selectpage" value="$ENV{'form.selectpage'}" />
   <input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" />    <input type="hidden" name="scantron_format" value="$ENV{'form.scantron_format'}" />
   <input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" />    <input type="hidden" name="scantron_selectfile" value="$ENV{'form.scantron_selectfile'}" />
   <input type="hidden" name="scantron_maxbubble" value="$ENV{'form.scantron_maxbubble'}" />    <input type="hidden" name="scantron_maxbubble" value="$max_bubble'" />
     <input type="hidden" name="scantron_CODElist" value="$ENV{'form.scantron_CODElist'}" />
     <input type="hidden" name="scantron_CODEunique" value="$ENV{'form.scantron_CODEunique'}" />
     <input type="hidden" name="scantron_options_redo" value="$ENV{'form.scantron_optiond_redo'}" />
     <input type="hidden" name="scantron_options_ignore" value="$ENV{'form.scantron_optiond_ignore'}" />
   $default_form_data    $default_form_data
 SCANTRONFORM  SCANTRONFORM
     $r->print($result);      $r->print($result);
Line 4116  sub scantron_get_correction { Line 4133  sub scantron_get_correction {
   $$scan_record{'scantron.FirstName'}."</p>");    $$scan_record{'scantron.FirstName'}."</p>");
  $r->print("<p>How should I handle this? <br /> \n");   $r->print("<p>How should I handle this? <br /> \n");
  $r->print("\n<br /> ");   $r->print("\n<br /> ");
  $r->print("<input type='radio' name='scan_CODE_resolution' value='use_unfound' checked='on' /> Use the CODE <b><tt>".$$scan_record{'scantron.CODE'}."</tt></b> that is was on the paper, ignoring the error.");   $r->print("<input type='radio' name='scantron_CODE_resolution' value='use_unfound' checked='on' /> Use the CODE <b><tt>".$$scan_record{'scantron.CODE'}."</tt></b> that is was on the paper, ignoring the error.");
  $r->print("\n<br />");   $r->print("\n<br />");
  $r->print(<<ENDSCRIPT);   $r->print(<<ENDSCRIPT);
 <script type="text/javascript">  <script type="text/javascript">
 function change_radio(field) {  function change_radio(field) {
     var slct=document.scantronupload.scan_CODE_resolution;      var slct=document.scantronupload.scantron_CODE_resolution;
     var i;      var i;
     for (i=0;i<slct.length;i++) {      for (i=0;i<slct.length;i++) {
         if (slct[i].value==field) { slct[i].checked=true; }          if (slct[i].value==field) { slct[i].checked=true; }
Line 4135  ENDSCRIPT Line 4152  ENDSCRIPT
    "&scantron_CODElist=".&Apache::lonnet::escape($ENV{'form.scantron_CODElist'}).     "&scantron_CODElist=".&Apache::lonnet::escape($ENV{'form.scantron_CODElist'}).
    "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}).     "&curCODE=".&Apache::lonnet::escape($$scan_record{'scantron.CODE'}).
    "&scantron_selectfile=".&Apache::lonnet::escape($ENV{'form.scantron_selectfile'});     "&scantron_selectfile=".&Apache::lonnet::escape($ENV{'form.scantron_selectfile'});
  $r->print("<input type='radio' name='scan_CODE_resolution' value='use_found' /> <a target='_blank' href='$href'>Select</a> a CODE from the list of all CODEs and use it. Selected CODE is <input readonly='true' type='text' size='8' name='scan_CODE_selectedvalue' onfocus=\"javascript:change_radio('use_found')\" onchange=\"javascript:change_radio('use_found')\" />");   $r->print("<input type='radio' name='scantron_CODE_resolution' value='use_found' /> <a target='_blank' href='$href'>Select</a> a CODE from the list of all CODEs and use it. Selected CODE is <input readonly='true' type='text' size='8' name='scantron_CODE_selectedvalue' onfocus=\"javascript:change_radio('use_found')\" onchange=\"javascript:change_radio('use_found')\" />");
  $r->print("\n<br />");   $r->print("\n<br />");
  $r->print("<input type='radio' name='scan_CODE_resolution' value='use_typed' /> Use <input type='text' size='8' name='scan_CODE_newvalue' onfocus=\"javascript:change_radio('use_typed')\" onkeypress=\"javascript:change_radio('use_typed')\" /> as the CODE.");   $r->print("<input type='radio' name='scantron_CODE_resolution' value='use_typed' /> Use <input type='text' size='8' name='scantron_CODE_newvalue' onfocus=\"javascript:change_radio('use_typed')\" onkeypress=\"javascript:change_radio('use_typed')\" /> as the CODE.");
  $r->print("\n<br /><br />");   $r->print("\n<br /><br />");
     } elsif ($error eq 'doublebubble') {      } elsif ($error eq 'doublebubble') {
 #FIXME Need to print out who this is along with the paper info  #FIXME Need to print out who this is along with the paper info
Line 4194  sub scantron_validate_CODE { Line 4211  sub scantron_validate_CODE {
     if ($scantron_config{'CODElocation'} &&      if ($scantron_config{'CODElocation'} &&
  $scantron_config{'CODEstart'} &&   $scantron_config{'CODEstart'} &&
  $scantron_config{'CODElength'}) {   $scantron_config{'CODElength'}) {
  if (!$ENV{'form.scantron_CODElist'}) {   if (!defined($ENV{'form.scantron_CODElist'})) {
     &FIXME_blow_up()      &FIXME_blow_up()
  }   }
     } else {      } else {
  &Apache::lonnet::logthis(" CODE stuf $scantron_config{'CODElocation'}:$scantron_config{'CODEstart'}:$scantron_config{'CODElength'}");  
  return (0,$currentphase+1);   return (0,$currentphase+1);
     }      }
           
Line 4208  sub scantron_validate_CODE { Line 4224  sub scantron_validate_CODE {
     my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};      my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
     my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'};      my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
     my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum);      my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum);
     my %allcodes=map {($_,1)} split(',',$result{$old_name});      my %allcodes=map {(&Apache::lonprintout::num_to_letters($_),1)} split(',',$result{$old_name});
   
     my ($scanlines,$scan_data)=&scantron_getfile();      my ($scanlines,$scan_data)=&scantron_getfile();
     for (my $i=0;$i<=$scanlines->{'count'};$i++) {      for (my $i=0;$i<=$scanlines->{'count'};$i++) {
Line 4218  sub scantron_validate_CODE { Line 4234  sub scantron_validate_CODE {
  $scan_data);   $scan_data);
  my $CODE=$$scan_record{'scantron.CODE'};   my $CODE=$$scan_record{'scantron.CODE'};
  my $error=0;   my $error=0;
  if (!exists($allcodes{$CODE})) {   if (!exists($allcodes{$CODE}) && !$$scan_record{'scantron.useCODE'}) {
     &scantron_get_correction($r,$i,$scan_record,      &scantron_get_correction($r,$i,$scan_record,
      \%scantron_config,       \%scantron_config,
      $line,'incorrectCODE',$CODE);       $line,'incorrectCODE',$CODE);
Line 4258  sub scantron_validate_doublebubble { Line 4274  sub scantron_validate_doublebubble {
     return (0,$currentphase+1);      return (0,$currentphase+1);
 }  }
   
   sub scantron_get_maxbubble {
       my ($r)=@_;
       if (defined($ENV{'form.scantron_maxbubble'}) &&
    $ENV{'form.scantron_maxbubble'}) {
    return $ENV{'form.scantron_maxbubble'};
       }
       my $navmap=Apache::lonnavmaps::navmap->new();
       my (undef,undef,$sequence)=
    &Apache::lonnet::decode_symb($ENV{'form.selectpage'});
       my $map=$navmap->getResourceByUrl($sequence);
       my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
       &Apache::lonnet::delenv('form.counter');
       foreach my $resource (@resources) {
    my $result=&Apache::lonnet::ssi($resource->src());
       }
       &Apache::lonnet::delenv('scantron\.');
       my $envfile=$ENV{'user.environment'};
       $envfile=~/\/([^\/]+)\.id$/;
       $envfile=$1;
       &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
        $envfile);
       $ENV{'form.scantron_maxbubble'}=$ENV{'form.counter'}-1;
       return $ENV{'form.scantron_maxbubble'};
   }
   
 sub scantron_validate_missingbubbles {  sub scantron_validate_missingbubbles {
     my ($r,$currentphase) = @_;      my ($r,$currentphase) = @_;
     #get student info      #get student info
Line 4267  sub scantron_validate_missingbubbles { Line 4308  sub scantron_validate_missingbubbles {
     #get scantron line setup      #get scantron line setup
     my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});      my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
     my ($scanlines,$scan_data)=&scantron_getfile();      my ($scanlines,$scan_data)=&scantron_getfile();
     my $max_bubble=$ENV{'form.scantron_maxbubble'};      my $max_bubble=&scantron_get_maxbubble();
     if (!$max_bubble) { $max_bubble=2**31; }      if (!$max_bubble) { $max_bubble=2**31; }
     for (my $i=0;$i<=$scanlines->{'count'};$i++) {      for (my $i=0;$i<=$scanlines->{'count'};$i++) {
  my $line=&scantron_get_line($scanlines,$i);   my $line=&scantron_get_line($scanlines,$i);

Removed from v.1.188  
changed lines
  Added in v.1.191


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