Diff for /loncom/homework/grades.pm between versions 1.81 and 1.82

version 1.81, 2003/03/28 23:44:31 version 1.82, 2003/04/01 05:21:48
Line 2819  sub scantron_uploads { Line 2819  sub scantron_uploads {
     return $result;      return $result;
 }  }
   
   sub scantron_scantab {
       my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
       my $result='<select name="scantron_format">'."\n";
       foreach my $line (<$fh>) {
    my ($name,$descrip)=split(/:/,$line);
    if ($name =~ /^\#/) { next; }
    $result.='<option value="'.$name.'">'.$descrip.'</option>'."\n";
       }
       $result.='</select>'."\n";
   
       return $result;
   }
   
 sub scantron_selectphase {  sub scantron_selectphase {
     my ($r) = @_;      my ($r) = @_;
     my ($symb,$url)=&get_symb_and_url($r);      my ($symb,$url)=&get_symb_and_url($r);
Line 2827  sub scantron_selectphase { Line 2840  sub scantron_selectphase {
     my $default_form_data=&defaultFormData($symb,$url);      my $default_form_data=&defaultFormData($symb,$url);
     my $grading_menu_button=&show_grading_menu_form($symb,$url);      my $grading_menu_button=&show_grading_menu_form($symb,$url);
     my $file_selector=&scantron_uploads();      my $file_selector=&scantron_uploads();
       my $format_selector=&scantron_scantab();
     my $result;      my $result;
     $result.= <<SCANTRONFORM;      $result.= <<SCANTRONFORM;
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">  <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantro_process">
   <input type="hidden" name="command" value="scantron_configphase" />    <input type="hidden" name="command" value="scantron_process" />
   $default_form_data    $default_form_data
   <table width="100%" border="0">    <table width="100%" border="0">
     <tr>      <tr>
Line 2851  sub scantron_selectphase { Line 2865  sub scantron_selectphase {
  Filename of scoring office file: $file_selector   Filename of scoring office file: $file_selector
     </td>      </td>
           </tr>            </tr>
             <tr bgcolor="#ffffe6">
               <td>
                 Format of data file: $format_selector
       </td>
             </tr>
         </table>          </table>
       </td>        </td>
     </tr>      </tr>
Line 2863  SCANTRONFORM Line 2882  SCANTRONFORM
     return $result;      return $result;
 }  }
   
 sub scantron_configphase {  sub get_scantron_config {
       my ($which) = @_;
       my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
       my %config;
       foreach my $line (<$fh>) {
    my ($name,$descrip)=split(/:/,$line);
    if ($name ne $which ) { next; }
    chomp($line);
    my @config=split(/:/,$line);
    $config{'name'}=$config[0];
    $config{'description'}=$config[1];
    $config{'CODElocation'}=$config[2];
    $config{'CODEstart'}=$config[3];
    $config{'CODElength'}=$config[4];
    $config{'IDstart'}=$config[5];
    $config{'IDlength'}=$config[6];
    $config{'Qstart'}=$config[7];
    $config{'Qlength'}=$config[8];
    $config{'Qoff'}=$config[9];
    $config{'Qon'}=$config[10];
    last;
       }
       return %config;
   }
   
   sub username_to_idmap {
       my ($classlist)= @_;
       my %idmap;
       foreach my $student (keys(%$classlist)) {
    $idmap{$classlist->{$student}->[&Apache::loncoursedata::CL_ID]}=
       $student;
       }
       return %idmap;
   }
   
   sub scantron_parse_scanline {
       my ($line,$scantron_config)=@_;
       my %record;
       my $questions=substr($line,$$scantron_config{'Qstart'}-1);
       my $data=substr($line,0,$$scantron_config{'Qstart'}-1);
       if ($$scantron_config{'CODElocation'} ne 0) {
    if ($$scantron_config{'CODElocation'} < 0) {
       $record{'CODE'}=substr($data,$$scantron_config{'CODEstart'}-1,
      $$scantron_config{'CODElength'});
    } else {
       #FIXME interpret first N questions
    }
       }
       $record{'ID'}=substr($data,$$scantron_config{'IDstart'}-1,
    $$scantron_config{'IDlength'});
       my @alphabet=('A'..'Z');
       my $questnum=0;
       while ($questions) {
    $questnum++;
    my $currentquest=substr($questions,0,$$scantron_config{'Qlength'});
    substr($questions,0,$$scantron_config{'Qlength'})='';
    my (@array)=split(/$$scantron_config{'Qon'}/,$currentquest);
    if (scalar(@array) gt 2) {
       #FIXME do something intelligent with double bubbles
       Apache->request->print("<br ><b>Wha!!!</b> ".scalar(@array).
      '-'.$questions.'-'.$currentquest.'-'.$questnum.
      '-'.length($questions).
      '-'.$line.'-'.length($line).'-'.
      '-'.$data.'-'.length($data).'-'.
      '<br />');
    }
    if (length($array[0]) eq $$scantron_config{'Qlength'}) {
       $record{"$questnum.answer"}='';
    } else {
       $record{"$questnum.answer"}=$alphabet[length($array[0])];
    }
       }
       $record{'maxquest'}=$questnum;
       $Apache::lonxml::debug=1;
       &Apache::lonhomework::showhash(%record);
       $Apache::lonxml::debug=0;
       return %record;
   }
   
   sub scantron_add_delay {
   }
   
   sub scantron_find_student {
   }
   
   sub scantron_process_students {
     my ($r) = @_;      my ($r) = @_;
     my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'});      my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'});
     my $result;  
     my ($symb,$url)=&get_symb_and_url($r);      my ($symb,$url)=&get_symb_and_url($r);
     if (!$symb) {return '';}      if (!$symb) {return '';}
     my $default_form_data=&defaultFormData($symb,$url);      my $default_form_data=&defaultFormData($symb,$url);
     my $grading_menu_button=&show_grading_menu_form($symb,$url);  
     my $file_selector;      my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
     $result.= <<SCANTRONFORM;      my $scanlines=Apache::File->new($Apache::lonnet::perlvar{'lonScansDir'}."/$ENV{'form.scantron_selectfile'}");
       my $classlist=&Apache::loncoursedata::get_classlist();
       my %idmap=&username_to_idmap($classlist);
       my $result= <<SCANTRONFORM;
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">  <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantronupload">
   <input type="hidden" name="command" value="scantron_configphase" />    <input type="hidden" name="command" value="scantron_configphase" />
   $default_form_data    $default_form_data
   <table width="100%" border="0">  
     <tr>  
       <td bgcolor="#777777">  
         <table width="100%" border="0">  
           <tr bgcolor="#e6ffff">  
             <td>  
               &nbsp;<b>Select a format for the data file.</b>  
             </td>  
           </tr>  
           <tr bgcolor="#ffffe6">  
             <td>  
                Format of data file:  
     </td>  
           </tr>  
           <tr bgcolor="#ffffe6">  
             <td>  
  Filename of scoring office file: $file_selector  
     </td>  
           </tr>  
         </table>  
       </td>  
     </tr>  
   </table>  
   <input type="submit" value="Submit" />  
 </form>  
 $grading_menu_button  
 SCANTRONFORM  SCANTRONFORM
     #FIXME Needs to present some lines from the file and allow the instructor to specify which columns represent what data, possibly have some nice defaults setup, probably should do a pass through all problems for a student to get an idea of how many questions there are, and homw many lines we'll have,      $r->print($result);
     return $result;  
 }  
   
 sub scantron_process_students {      my @delayqueue;
   
       foreach my $line (<$scanlines>) {
    my $scan_record=&scantron_parse_scanline($line,\%scantron_config);
    my ($uname,$udom);
    if ($uname=&scantron_find_student($scan_record,\%idmap)) {
       &scantron_add_delay(\@delayqueue,$line,
    'Unable to find a student that matches');
    }
    ($uname,$udom)=split(/:/,$uname);
    #FIXME
    #get iterator for $sequence
    #foreach question 'submit' the students answer to the server
    #   through grade target {
    #   generate data to pass back that includes grade recevied
    #}
       }
       foreach my $delay (@delayqueue) {
    #FIXME
    #print out each delayed student with interface to select how
    #  to repair student provided info
    #Expected errors include
    #  1 bad/no stuid/username
    #  2 invalid bubblings
   
       }
     #FIXME      #FIXME
     #   loop through students, {  
     #      Check if studnet info valid, if not add line to delay queue  
     #      foreach question 'submit' the students answer to the server  
     #             through grade target {  
     #         generate data to pass back that includes grade recevied  
     #      }  
     #   }  
     #   loop through delay queue {  
     #      print out each delayed student with interface to select how  
     #          to repair student provided info  
     #       Expected errors include  
     #           1 bad/no stuid/username  
     #           2 invalid bubblings  
     #   }  
     # if delay queue exists 2 submits one to process delayed students one      # if delay queue exists 2 submits one to process delayed students one
     #     to ignore delayed students, possibly saving the delay queue for later      #     to ignore delayed students, possibly saving the delay queue for later
   
Line 3275  sub handler { Line 3364  sub handler {
     }      }
  } elsif ($command eq 'scantron_selectphase') {   } elsif ($command eq 'scantron_selectphase') {
     $request->print(&scantron_selectphase($request));      $request->print(&scantron_selectphase($request));
  } elsif ($command eq 'scantron_configphase') {   } elsif ($command eq 'scantron_process') {
     $request->print(&scantron_configphase($request));      $request->print(&scantron_process_students($request));
  } else {   } else {
     $request->print("Unknown action: $command:");      $request->print("Unknown action: $command:");
  }   }

Removed from v.1.81  
changed lines
  Added in v.1.82


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