Diff for /loncom/homework/grades.pm between versions 1.160 and 1.162

version 1.160, 2003/11/21 21:31:34 version 1.162, 2003/11/25 21:44:45
Line 3379  sub scantron_uploads { Line 3379  sub scantron_uploads {
     my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};      my $cdom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
     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::locommon::propath($cdom,$cname));      &Apache::loncommon::propath($cdom,$cname));
     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 3416  sub scantron_selectphase { Line 3416  sub scantron_selectphase {
     #FIXME allow instructor to be able to download the scantron file      #FIXME allow instructor to be able to download the scantron file
     # and to upload it,      # and to upload it,
     $result.= <<SCANTRONFORM;      $result.= <<SCANTRONFORM;
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantro_process">      <table width="100%" border="0">
   <input type="hidden" name="command" value="scantron_validate" />  
   $default_form_data  
   <table width="100%" border="0">  
     <tr>      <tr>
       <td bgcolor="#777777">        <td bgcolor="#777777">
          <form method="post" enctype="multipart/form-data" action="/adm/grades" name="scantro_process">
          <input type="hidden" name="command" value="scantron_validate" />
           $default_form_data
         <table width="100%" border="0">          <table width="100%" border="0">
           <tr bgcolor="#e6ffff">            <tr bgcolor="#e6ffff">
             <td>              <td>
Line 3450  sub scantron_selectphase { Line 3450  sub scantron_selectphase {
                 <input type="text" name="scantron_maxbubble" />                  <input type="text" name="scantron_maxbubble" />
     </td>      </td>
           </tr>            </tr>
             <tr bgcolor="#ffffe6">
               <td>
                 <input type="submit" value="Validate Scantron Records" />
               </td>
             </tr>
           </table>
          </form>
         </td>
       </tr>
   SCANTRONFORM
      
       $r->print($result);
   
       if (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'}) ||
           &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) {
   
           $r->print(<<SCANTRONFORM);
       <tr>
         <td bgcolor="#777777">
           <table width="100%" border="0">
             <tr bgcolor="#e6ffff">
               <td>
                 Specify a Scantron data file to upload.
               </td>
             </tr>
             <tr bgcolor="#ffffe6">
               <td>
   SCANTRONFORM
           &scantron_upload_scantron_data($r);
   
           $r->print(<<SCANTRONFORM);
               </td>
             </tr>
         </table>          </table>
       </td>        </td>
     </tr>      </tr>
   SCANTRONFORM
       }
   
       $r->print(<<SCANTRONFORM);
   </table>    </table>
   <input type="submit" value="Validate Scantron Records" />  
 </form>  </form>
 $grading_menu_button  $grading_menu_button
 SCANTRONFORM  SCANTRONFORM
   
     return $result;      return
 }  }
   
 sub get_scantron_config {  sub get_scantron_config {
Line 3634  sub scantron_filter { Line 3670  sub scantron_filter {
     return 0;      return 0;
 }  }
   
 #FIXME I think I am doing this in the wrong order, I think it would be  
 #better to make a several passes analyzing all of the lines in the  
 #file for common errors wrong/invalid PID/username duplicated  
 #PID/username, missing bubbles, double bubbles, missing/invalid CODE  
 #and then get the instructor to fix all of these errors, then grade  
 #the corrected one, I'll still need to catch error conditions, but  
 #maybe most will taken care even before we start  
   
 sub scantron_validate_file {  
     my ($r) = @_;  
 }  
   
 sub scantron_process_corrections {  sub scantron_process_corrections {
     my ($r) = @_;      my ($r) = @_;
     my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});      my %scantron_config=&get_scantron_config($ENV{'form.scantron_format'});
Line 3755  sub scantron_getfile { Line 3779  sub scantron_getfile {
     my $lines;      my $lines;
     $lines=&Apache::lonnet::getfile('/uploaded/'.$cdom.'/'.$cname.'/'.      $lines=&Apache::lonnet::getfile('/uploaded/'.$cdom.'/'.$cname.'/'.
        'scantron_orig_'.$ENV{'form.scantron_selectfile'});         'scantron_orig_'.$ENV{'form.scantron_selectfile'});
     if ($lines eq '-1') {  
  #FIXME need to actually replicate file to course space  
  #FIXME when replicating strip CRLF to LF or CR to LF  
     }  
     my %scanlines;      my %scanlines;
     $scanlines{'orig'}=[(split("\n",$lines,-1))];      $scanlines{'orig'}=[(split("\n",$lines,-1))];
     my $temp=$scanlines{'orig'};      my $temp=$scanlines{'orig'};
Line 3898  sub scantron_get_correction { Line 3918  sub scantron_get_correction {
 #to show both the current line and the previous one and allow skipping  #to show both the current line and the previous one and allow skipping
 #the previous one or the current one  #the previous one or the current one
   
     $r->print("<p>An error was detected ($error) ");      $r->print("<p><b>An error was detected ($error)</b>");
     if ( defined($$scan_record{'scantron.PaperID'}) ) {      if ( defined($$scan_record{'scantron.PaperID'}) ) {
  $r->print(" for PaperID <tt>".   $r->print(" for PaperID <tt>".
   $$scan_record{'scantron.PaperID'}."</tt> \n");    $$scan_record{'scantron.PaperID'}."</tt> \n");
Line 4075  SCANTRONFORM Line 4095  SCANTRONFORM
   ($uname,$udom)=('','');    ($uname,$udom)=('','');
   $i++;    $i++;
   my $line=&scantron_get_line($scanlines,$i);    my $line=&scantron_get_line($scanlines,$i);
 # $r->print('<pre>line is'.$line.'</pre>');  
   if ($line=~/^[\s\cz]*$/) { next; }    if ($line=~/^[\s\cz]*$/) { next; }
   my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,    my $scan_record=&scantron_parse_scanline($line,$i,\%scantron_config,
   $scan_data);    $scan_data);
Line 4090  SCANTRONFORM Line 4109  SCANTRONFORM
   'Student '.$uname.' has multiple sheets',2);    'Student '.$uname.' has multiple sheets',2);
      next;       next;
   }    }
 # $r->print('<pre>doing studnet'.$uname.'</pre>');  
   ($uname,$udom)=split(/:/,$uname);    ($uname,$udom)=split(/:/,$uname);
   &Apache::lonnet::delenv('form.counter');    &Apache::lonnet::delenv('form.counter');
   &Apache::lonnet::appenv(%$scan_record);    &Apache::lonnet::appenv(%$scan_record);
 #    &Apache::lonhomework::showhash(%ENV);  
 #    $Apache::lonxml::debug=1;   my $i=0;
 # &Apache::lonxml::debug("line is $line");  
    
     my $i=0;  
  foreach my $resource (@resources) {   foreach my $resource (@resources) {
     $i++;      $i++;
     my $result=&Apache::lonnet::ssi($resource->src(),      my $result=&Apache::lonnet::ssi($resource->src(),
Line 4108  SCANTRONFORM Line 4123  SCANTRONFORM
   'grade_domain'  =>$udom,    'grade_domain'  =>$udom,
   'grade_courseid'=>$ENV{'request.course.id'},    'grade_courseid'=>$ENV{'request.course.id'},
   'grade_symb'    =>$resource->symb()));    'grade_symb'    =>$resource->symb()));
 #    my %score=&Apache::lonnet::restore($resource->symb(),  
 #       $ENV{'request.course.id'},  
 #       $udom,$uname);  
 #    foreach my $part ($resource->{PARTS}) {  
 # if ($score{'resource.'.$part.'.solved'} =~ /^correct/) {  
 #    $studentcorrect++;  
 #    $totalcorrect++;  
 # } else {  
 #    $studentincorrect++;  
 #    $totalincorrect++;  
 # }  
 #    }  
 #    $r->print('<pre>'.  
 #      $resource->symb().'-'.  
 #      $resource->src().'-'.'</pre>result is'.$result);  
 #    &Apache::lonhomework::showhash(%score);  
  #    if ($i eq 3) {last;}  
  }   }
  $completedstudents{$uname}={'line'=>$line};   $completedstudents{$uname}={'line'=>$line};
     } continue {      } continue {
Line 4132  SCANTRONFORM Line 4130  SCANTRONFORM
  &Apache::lonnet::delenv('scantron\.');   &Apache::lonnet::delenv('scantron\.');
  &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,   &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
  'last student');   'last student');
  #last;  
  #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  
  #}  
     }      }
     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);      &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
     my $lasttime = &Time::HiRes::time()-$start;      my $lasttime = &Time::HiRes::time()-$start;
     $r->print("<p>took $lasttime</p>");      $r->print("<p>took $lasttime</p>");
   
     #$Apache::lonxml::debug=0;  
     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  
     # if delay queue exists 2 submits one to process delayed students one  
     #     to ignore delayed students, possibly saving the delay queue for later  
       
     $navmap->untieHashes();      $navmap->untieHashes();
     $r->print("<p>Done</p>");      $r->print("<p>Done</p>");
     $r->print(&show_grading_menu_form($symb,$url));      $r->print(&show_grading_menu_form($symb,$url));
Line 4171  sub scantron_upload_scantron_data { Line 4148  sub scantron_upload_scantron_data {
   'domainid');    'domainid');
     my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'},      my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'},
    'domainid');     'domainid');
       my $default_form_data=&defaultFormData(&get_symb_and_url($r));
     $r->print(<<UPLOAD);      $r->print(<<UPLOAD);
 <script type="text/javascript" language="javascript">  <script type="text/javascript" language="javascript">
     function checkUpload(formname) {      function checkUpload(formname) {
Line 4183  sub scantron_upload_scantron_data { Line 4161  sub scantron_upload_scantron_data {
 </script>  </script>
   
 <form enctype='multipart/form-data' action='/adm/grades' name='rules' method='post'>  <form enctype='multipart/form-data' action='/adm/grades' name='rules' method='post'>
   $default_form_data
 Course: <input name='courseid' type='text' />  Course: <input name='courseid' type='text' />
 Domain: $domsel $select_link  Domain: $domsel $select_link
 <br />  <br />
Line 4197  UPLOAD Line 4176  UPLOAD
   
 sub scantron_upload_scantron_data_save {  sub scantron_upload_scantron_data_save {
     my($r)=@_;      my($r)=@_;
     $r->print("Doing upload to ".$ENV{'form.courseid'});      if (!&Apache::lonnet::allowed('usc',$ENV{'form.domainid'}) &&
    !&Apache::lonnet::allowed('usc',
       $ENV{'form.domainid'}.'_'.$ENV{'form.courseid'})) {
    $r->print("You are not allowed to upload Scantron data to the requested course.<br />");
    $r->print(&show_grading_menu_form(&get_symb_and_url($r)));
    return '';
       }
       $r->print("Doing upload to ".$ENV{'form.courseid'}." <br />");
     my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'},      my $home=&Apache::lonnet::homeserver($ENV{'form.courseid'},
  $ENV{'form.domainid'});   $ENV{'form.domainid'});
     my $fname=$ENV{'form.upfile.filename'};      my $fname=$ENV{'form.upfile.filename'};
Line 4215  sub scantron_upload_scantron_data_save { Line 4201  sub scantron_upload_scantron_data_save {
     # See if there is anything left      # See if there is anything left
     unless ($fname) { return 'error: no uploaded file'; }      unless ($fname) { return 'error: no uploaded file'; }
     $fname='scantron_orig_'.$fname;      $fname='scantron_orig_'.$fname;
     &Apache::lonnet::logthis("fname is $fname");  
     $r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},      $r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},
     $ENV{'form.domainid'},      $ENV{'form.domainid'},
     $home,'upfile',$fname));      $home,'upfile',$fname));
       $r->print(&show_grading_menu_form(&get_symb_and_url($r)));
     return '';      return '';
 }  }
   
Line 4505  sub handler { Line 4491  sub handler {
  } elsif ($command eq 'scantron_process' && $perm{'mgr'}) {   } elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
     $request->print(&scantron_process_students($request));      $request->print(&scantron_process_students($request));
   } elsif ($command eq 'scantronupload' &&     } elsif ($command eq 'scantronupload' && 
   &Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) {    (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})||
      $request->print(&scantron_upload_scantron_data($request));    &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
         $request->print(&scantron_upload_scantron_data($request)); 
   } elsif ($command eq 'scantronupload_save' &&    } elsif ($command eq 'scantronupload_save' &&
   &Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})) {    (&Apache::lonnet::allowed('usc',$ENV{'request.role.domain'})||
     &Apache::lonnet::allowed('usc',$ENV{'request.course.id'}))) {
      $request->print(&scantron_upload_scantron_data_save($request));       $request->print(&scantron_upload_scantron_data_save($request));
     } elsif ($command eq 'scantrondownload' &&
    &Apache::lonnet::allowed('usc',$ENV{'request.course.id'})) {
        $request->print(&scantron_download_scantron_data($request));
  } elsif ($command) {   } elsif ($command) {
     $request->print("Access Denied ($command)");      $request->print("Access Denied ($command)");
  }   }

Removed from v.1.160  
changed lines
  Added in v.1.162


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