Diff for /loncom/homework/grades.pm between versions 1.428.2.1 and 1.432

version 1.428.2.1, 2007/08/24 07:15:27 version 1.432, 2007/08/21 22:21:54
Line 45  use LONCAPA; Line 45  use LONCAPA;
   
 use POSIX qw(floor);  use POSIX qw(floor);
   
 my %perm;  my %perm=();
   
 # ----- These first few routines are general use routines.----  # ----- These first few routines are general use routines.----
 #  #
Line 194  sub showResourceInfo { Line 194  sub showResourceInfo {
     return $result,$responseType,$hdgrade,$partlist,$handgrade;      return $result,$responseType,$hdgrade,$partlist,$handgrade;
 }  }
   
 sub reset_caches {  
     &reset_analyze_cache();  
     &reset_perm();  
 }  
   
 {  
     my %analyze_cache;  
   
     sub reset_analyze_cache {  sub get_order {
  undef(%analyze_cache);      my ($partid,$respid,$symb,$uname,$udom)=@_;
     }      my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
       $url=&Apache::lonnet::clutter($url);
     sub get_analyze {      my $subresult=&Apache::lonnet::ssi($url,
  my ($symb,$uname,$udom)=@_;         ('grade_target' => 'analyze'),
  my $key = "$symb\0$uname\0$udom";         ('grade_domain' => $udom),
  return $analyze_cache{$key} if (exists($analyze_cache{$key}));         ('grade_symb' => $symb),
          ('grade_courseid' => 
  my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);          $env{'request.course.id'}),
  $url=&Apache::lonnet::clutter($url);         ('grade_username' => $uname));
  my $subresult=&Apache::lonnet::ssi($url,      (undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
    ('grade_target' => 'analyze'),      my %analyze=&Apache::lonnet::str2hash($subresult);
    ('grade_domain' => $udom),      return ($analyze{"$partid.$respid.shown"});
    ('grade_symb' => $symb),  
    ('grade_courseid' =>   
     $env{'request.course.id'}),  
    ('grade_username' => $uname));  
  (undef,$subresult)=split(/_HASH_REF__/,$subresult,2);  
  my %analyze=&Apache::lonnet::str2hash($subresult);  
  return $analyze_cache{$key} = \%analyze;  
     }  
   
     sub get_order {  
  my ($partid,$respid,$symb,$uname,$udom)=@_;  
  my $analyze = &get_analyze($symb,$uname,$udom);  
  return $analyze->{"$partid.$respid.shown"};  
     }  
   
     sub get_radiobutton_correct_foil {  
  my ($partid,$respid,$symb,$uname,$udom)=@_;  
  my $analyze = &get_analyze($symb,$uname,$udom);  
  foreach my $foil (@{&get_order($partid,$respid,$symb,$uname,$udom)}) {  
     if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') {  
  return $foil;  
     }  
  }  
     }  
 }  }
   
 #--- Clean response type for display  #--- Clean response type for display
 #--- Currently filters option/rank/radiobutton/match/essay/Task  #--- Currently filters option/rank/radiobutton/match/essay/Task
 #        response types only.  #        response types only.
Line 290  sub cleanRecord { Line 258  sub cleanRecord {
     } elsif ($response eq 'radiobutton') {      } elsif ($response eq 'radiobutton') {
  my %answer=&Apache::lonnet::str2hash($answer);   my %answer=&Apache::lonnet::str2hash($answer);
  my ($toprow,$bottomrow);   my ($toprow,$bottomrow);
  my $correct =    my $correct=($order->[0])+1;
     &get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom);   for (my $i=1;$i<=$#$order;$i++) {
  foreach my $foil (@$order) {      my $foil=$order->[$i];
     if (exists($answer{$foil})) {      if (exists($answer{$foil})) {
  if ($foil eq $correct) {   if ($i == $correct) {
     $toprow.='<td><b>true</b></td>';      $toprow.='<td><b>true</b></td>';
  } else {   } else {
     $toprow.='<td><i>true</i></td>';      $toprow.='<td><i>true</i></td>';
Line 755  LISTJAVASCRIPT Line 723  LISTJAVASCRIPT
   
     my $saveStatus = $env{'form.Status'} eq '' ? 'Active' : $env{'form.Status'};      my $saveStatus = $env{'form.Status'} eq '' ? 'Active' : $env{'form.Status'};
     $env{'form.Status'} = $saveStatus;      $env{'form.Status'} = $saveStatus;
   
     $gradeTable.='<label><input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last submission only </label>'."\n".      $gradeTable.='<label><input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last submission only </label>'."\n".
  '<label><input type="radio" name="lastSub" value="last" /> last submission & parts info </label>'."\n".   '<label><input type="radio" name="lastSub" value="last" /> last submission & parts info </label>'."\n".
  '<label><input type="radio" name="lastSub" value="datesub" /> by dates and submissions </label>'."\n".   '<label><input type="radio" name="lastSub" value="datesub" /> by dates and submissions </label>'."\n".
Line 766  LISTJAVASCRIPT Line 733  LISTJAVASCRIPT
         '<option value=".25">Quarter Points</option>'.          '<option value=".25">Quarter Points</option>'.
         '<option value=".1">Tenths of a Point</option>'.          '<option value=".1">Tenths of a Point</option>'.
         '</select>'.          '</select>'.
           &build_section_inputs().
  '<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".  
  '<input type="hidden" name="submitonly"  value="'.$submitonly.'" />'."\n".   '<input type="hidden" name="submitonly"  value="'.$submitonly.'" />'."\n".
  '<input type="hidden" name="handgrade"   value="'.$env{'form.handgrade'}.'" /><br />'."\n".   '<input type="hidden" name="handgrade"   value="'.$env{'form.handgrade'}.'" /><br />'."\n".
  '<input type="hidden" name="showgrading" value="'.$env{'form.showgrading'}.'" /><br />'."\n".   '<input type="hidden" name="showgrading" value="'.$env{'form.showgrading'}.'" /><br />'."\n".
Line 1693  sub download_all_link { Line 1659  sub download_all_link {
     return      return
 }  }
   
   sub build_section_inputs {
       my $section_inputs;
       if ($env{'form.section'} eq '') {
           $section_inputs .= '<input type="hidden" name="section" value="all" />'."\n";
       } else {
           my @sections = &Apache::loncommon::get_env_multiple('form.section');
           foreach my $section(@sections) {
               $section_inputs .= '<input type="hidden" name="section" value="'.$section.'" />'."\n";
           }
       }
       return $section_inputs;
   }
   
 # --------------------------- show submissions of a student, option to grade   # --------------------------- show submissions of a student, option to grade 
 sub submission {  sub submission {
     my ($request,$counter,$total) = @_;      my ($request,$counter,$total) = @_;
Line 1773  sub submission { Line 1752  sub submission {
     $env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';      $env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
  }   }
  my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'};   my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'};
   
  $request->print('<form action="/adm/grades" method="post" name="SCORE" enctype="multipart/form-data">'."\n".   $request->print('<form action="/adm/grades" method="post" name="SCORE" enctype="multipart/form-data">'."\n".
  '<input type="hidden" name="command"    value="handgrade" />'."\n".   '<input type="hidden" name="command"    value="handgrade" />'."\n".
  '<input type="hidden" name="saveState"  value="'.$env{'form.saveState'}.'" />'."\n".   '<input type="hidden" name="saveState"  value="'.$env{'form.saveState'}.'" />'."\n".
Line 1788  sub submission { Line 1766  sub submission {
  '<input type="hidden" name="vProb"      value="'.$env{'form.vProb'}.'" />'."\n".   '<input type="hidden" name="vProb"      value="'.$env{'form.vProb'}.'" />'."\n".
  '<input type="hidden" name="vAns"       value="'.$env{'form.vAns'}.'" />'."\n".   '<input type="hidden" name="vAns"       value="'.$env{'form.vAns'}.'" />'."\n".
  '<input type="hidden" name="lastSub"    value="'.$env{'form.lastSub'}.'" />'."\n".   '<input type="hidden" name="lastSub"    value="'.$env{'form.lastSub'}.'" />'."\n".
  '<input type="hidden" name="section"    value="'.$env{'form.section'}.'" />'."\n".   &build_section_inputs().
  '<input type="hidden" name="submitonly" value="'.$env{'form.submitonly'}.'" />'."\n".   '<input type="hidden" name="submitonly" value="'.$env{'form.submitonly'}.'" />'."\n".
  '<input type="hidden" name="handgrade"  value="'.$env{'form.handgrade'}.'" />'."\n".   '<input type="hidden" name="handgrade"  value="'.$env{'form.handgrade'}.'" />'."\n".
  '<input type="hidden" name="NCT"'.   '<input type="hidden" name="NCT"'.
Line 2997  sub viewgrades { Line 2975  sub viewgrades {
     $result.= '<form action="/adm/grades" method="post" name="classgrade">'."\n".      $result.= '<form action="/adm/grades" method="post" name="classgrade">'."\n".
  '<input type="hidden" name="symb"    value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".   '<input type="hidden" name="symb"    value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
  '<input type="hidden" name="command" value="editgrades" />'."\n".   '<input type="hidden" name="command" value="editgrades" />'."\n".
  '<input type="hidden" name="section" value="'.$env{'form.section'}.'" />'."\n".   &build_section_inputs().
  '<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."\n".   '<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."\n".
  '<input type="hidden" name="Status" value="'.$env{'form.Status'}.'" />'."\n".   '<input type="hidden" name="Status" value="'.$env{'form.Status'}.'" />'."\n".
  '<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n";   '<input type="hidden" name="probTitle" value="'.$env{'form.probTitle'}.'" />'."\n";
   
     my $sectionClass;      my $sectionClass;
       my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
     if ($env{'form.section'} eq 'all') {      if ($env{'form.section'} eq 'all') {
  $sectionClass='Class </h3>';   $sectionClass='Class </h3>';
     } elsif ($env{'form.section'} eq 'none') {      } elsif ($env{'form.section'} eq 'none') {
  $sectionClass='Students in no Section </h3>';   $sectionClass=&mt('Students in no Section').'</h3>';
     } else {      } else {
  $sectionClass='Students in Section '.$env{'form.section'}.'</h3>';   $sectionClass=&mt('Students in Section(s) [_1]',$section_display).'</h3>';
     }      }
     $result.='<h3>Assign Common Grade To '.$sectionClass;      $result.='<h3>'.&mt('Assign Common Grade To [_1]',$sectionClass);
     $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".      $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
  '<table border=0><tr bgcolor="#ffffdd"><td>';   '<table border=0><tr bgcolor="#ffffdd"><td>';
     #radio buttons/text box for assigning points for a section or class.      #radio buttons/text box for assigning points for a section or class.
Line 3897  LISTJAVASCRIPT Line 3876  LISTJAVASCRIPT
  '<label><input type="radio" name="lastSub" value="none" /> none</label>'."\n".   '<label><input type="radio" name="lastSub" value="none" /> none</label>'."\n".
  '<label><input type="radio" name="lastSub" value="datesub" checked="checked" /> by dates and submissions</label>'."\n".   '<label><input type="radio" name="lastSub" value="datesub" checked="checked" /> by dates and submissions</label>'."\n".
  '<label><input type="radio" name="lastSub" value="all" /> all details</label>'."\n";   '<label><input type="radio" name="lastSub" value="all" /> all details</label>'."\n";
       
     $result.='<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".      $result.=&build_section_inputs();
  '<input type="hidden" name="Status"  value="'.$env{'form.Status'}.'" />'."\n".      $result.='<input type="hidden" name="Status"  value="'.$env{'form.Status'}.'" />'."\n".
  '<input type="hidden" name="command" value="displayPage" />'."\n".   '<input type="hidden" name="command" value="displayPage" />'."\n".
  '<input type="hidden" name="symb"    value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".   '<input type="hidden" name="symb"    value="'.&Apache::lonenc::check_encrypt($symb).'" />'."\n".
  '<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."<br />\n";   '<input type="hidden" name="saveState" value="'.$env{'form.saveState'}.'" />'."<br />\n";
Line 6964  GRADINGMENUJS Line 6943  GRADINGMENUJS
   
     $result.='<table width="100%" border="0">';      $result.='<table width="100%" border="0">';
     $result.='<tr bgcolor="#ffffe6" valign="top"><td>'."\n".      $result.='<tr bgcolor="#ffffe6" valign="top"><td>'."\n".
  '&nbsp;'.&mt('Select Section').': <select name="section">'."\n";   '&nbsp;'.&mt('Select Section').': <select name="section" multiple="multiple" size="3">'."\n";
     if (ref($sections)) {      if (ref($sections)) {
  foreach (sort (@$sections)) {   foreach (sort (@$sections)) {
     $result.='<option value="'.$_.'" '.      $result.='<option value="'.$_.'" '.
Line 7532  ENDHEADER Line 7511  ENDHEADER
 sub handler {  sub handler {
     my $request=$_[0];      my $request=$_[0];
   
     &reset_caches();      &reset_perm();
     if ($env{'browser.mathml'}) {      if ($env{'browser.mathml'}) {
  &Apache::loncommon::content_type($request,'text/xml');   &Apache::loncommon::content_type($request,'text/xml');
     } else {      } else {
Line 7645  sub handler { Line 7624  sub handler {
  }   }
     }      }
     $request->print(&Apache::loncommon::end_page());      $request->print(&Apache::loncommon::end_page());
     &reset_caches();  
     return '';      return '';
 }  }
   

Removed from v.1.428.2.1  
changed lines
  Added in v.1.432


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