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

version 1.80, 2003/03/28 20:49:55 version 1.82, 2003/04/01 05:21:48
Line 2779  sub updateGradeByPage { Line 2779  sub updateGradeByPage {
 #  #
 #------ start of section for handling grading by page/sequence ---------  #------ start of section for handling grading by page/sequence ---------
   
   sub defaultFormData {
       my ($symb,$url)=@_;
       return '
         <input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
        '<input type="hidden" name="url"     value="'.$url.'" />'."\n".
        '<input type="hidden" name="saveState" value="'.$ENV{'form.saveState'}.'" />'."\n".
        '<input type="hidden" name="probTitle" value="'.$ENV{'form.probTitle'}.'" />'."\n";
   }
   
 sub getSequenceDropDown {  sub getSequenceDropDown {
     my ($request,$symb)=@_;      my ($request,$symb)=@_;
     my $result='<select name="selectpage">'."\n";      my $result='<select name="selectpage">'."\n";
Line 2796  sub getSequenceDropDown { Line 2805  sub getSequenceDropDown {
     return $result;      return $result;
 }  }
   
   sub scantron_uploads {
       if (!-e $Apache::lonnet::perlvar{'lonScansDir'}) { return ''};
       my $result= '<select name="scantron_selectfile">';
       opendir(DIR,$Apache::lonnet::perlvar{'lonScansDir'});
       my @files=sort(readdir(DIR));
       foreach my $filename (@files) {
    if ($filename eq '.' or $filename eq '..') { next; }
    $result.="<option>$filename</option>\n";
       }
       closedir(DIR);
       $result.="</select>";
       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);
     if (!$symb) {return '';}      if (!$symb) {return '';}
     my $sequence_selector=&getSequenceDropDown($r,$symb);      my $sequence_selector=&getSequenceDropDown($r,$symb);
       my $default_form_data=&defaultFormData($symb,$url);
       my $grading_menu_button=&show_grading_menu_form($symb,$url);
       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="symb" value="$symb" />    <input type="hidden" name="command" value="scantron_process" />
   <input type="hidden" name="url" value="$url" />    $default_form_data
   <input type="hidden" name="command" value="scantron_configphase" />  
   <table width="100%" border="0">    <table width="100%" border="0">
     <tr>      <tr>
       <td bgcolor="#777777">        <td bgcolor="#777777">
Line 2823  sub scantron_selectphase { Line 2862  sub scantron_selectphase {
           </tr>            </tr>
           <tr bgcolor="#ffffe6">            <tr bgcolor="#ffffe6">
             <td>              <td>
  <!-- FIXME I need to present a list of files from a specfic directory that has been configured, or any existing delay queues -->   Filename of scoring office file: $file_selector
  Filename of scoring office file:      </td>
  <select name="selectfile">            </tr>
     <option value="filname1">filename1</option>            <tr bgcolor="#ffffe6">
     <option value="filname2">filename2</option>              <td>
  </select>                Format of data file: $format_selector
     </td>      </td>
           </tr>            </tr>
         </table>          </table>
Line 2837  sub scantron_selectphase { Line 2876  sub scantron_selectphase {
   </table>    </table>
   <input type="submit" value="Submit" />    <input type="submit" value="Submit" />
 </form>  </form>
   $grading_menu_button
 SCANTRONFORM  SCANTRONFORM
   
     return $result;      return $result;
 }  }
   
 sub scantron_configphase {  sub get_scantron_config {
     my ($r) = @_;      my ($which) = @_;
     my $sequence=$ENV{'form.selectpage'};      my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
     my $result;      my %config;
     $result.="got page $sequence";      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::lonxml::debug=1;
     &Apache::lonhomework::showhash(%ENV);      &Apache::lonhomework::showhash(%record);
     $Apache::lonxml::debug=0;      $Apache::lonxml::debug=0;
     #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,      return %record;
     return $result;  }
   
   sub scantron_add_delay {
   }
   
   sub scantron_find_student {
 }  }
   
 sub scantron_process_students {  sub scantron_process_students {
       my ($r) = @_;
       my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'});
       my ($symb,$url)=&get_symb_and_url($r);
       if (!$symb) {return '';}
       my $default_form_data=&defaultFormData($symb,$url);
   
       my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
       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">
     <input type="hidden" name="command" value="scantron_configphase" />
     $default_form_data
   SCANTRONFORM
       $r->print($result);
   
       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 3088  GRADINGMENUJS Line 3230  GRADINGMENUJS
  'Upload scores from file</td></tr>'."\n";   'Upload scores from file</td></tr>'."\n";
   
     $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.      $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
  '<input type="radio" name="command" value="scantron_selectphase" /> '.   '<input type="radio" name="command" value="scantron_selectphase" '.
    ($saveCmd eq 'scantron_selectphase' ? 'checked="on"' : '').' /> '.
         'Grade scantron forms</td></tr>'."\n";          'Grade scantron forms</td></tr>'."\n";
   
     if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {      if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {
Line 3221  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.80  
changed lines
  Added in v.1.82


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