Diff for /loncom/homework/grades.pm between versions 1.119 and 1.122

version 1.119, 2003/07/18 20:14:35 version 1.122, 2003/07/22 18:59:57
Line 123  sub showResourceInfo { Line 123  sub showResourceInfo {
     my $result ='<table border="0">'.      my $result ='<table border="0">'.
  '<tr><td colspan=3><font size=+1><b>Current Resource: </b>'.$probTitle.'</font></td></tr>'."\n";   '<tr><td colspan=3><font size=+1><b>Current Resource: </b>'.$probTitle.'</font></td></tr>'."\n";
     my ($partlist,$handgrade) = &response_type($url);      my ($partlist,$handgrade) = &response_type($url);
     my ($resptype,$hdgrade)=('','no');      my %resptype = (); #,$hdgrade)=('','no');
       my $hdgrade='no';
     for (sort keys(%$handgrade)) {      for (sort keys(%$handgrade)) {
  my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});   my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
  $resptype = $responsetype;   my $partID = (split(/_/))[0];
    $resptype{$partID} = $responsetype;
  $hdgrade = $handgrade if ($handgrade eq 'yes');   $hdgrade = $handgrade if ($handgrade eq 'yes');
  $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.   $result.='<tr><td><b>Part </b>'.$partID.'</td>'.
     '<td><b>Type: </b>'.$responsetype.'</td></tr>';      '<td><b>Type: </b>'.$responsetype.'</td></tr>';
 #    '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>';  #    '<td><b>Handgrade: </b>'.$handgrade.'</td></tr>';
     }      }
     $result.='</table>'."\n";      $result.='</table>'."\n";
     return $result,$resptype,$hdgrade,$partlist,$handgrade;      return $result,\%resptype,$hdgrade,$partlist,$handgrade;
 }  }
   
 #--- Clean response type for display  #--- Clean response type for display
 #--- Currently filters option response type only.  #--- Currently filters option response type only.
 sub cleanRecord {  sub cleanRecord {
     my ($answer,$response) = @_;      my ($answer,$response,$symb) = @_;
     if ($response eq 'option') {      if ($response eq 'option') {
  my (@IDs,@ans);   my (@IDs,@ans);
  foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {   foreach (split(/\&/,&Apache::lonnet::unescape($answer))) {
Line 155  sub cleanRecord { Line 157  sub cleanRecord {
     (join '</td><td>'.$grayFont,@IDs).'</font></td></tr>'.      (join '</td><td>'.$grayFont,@IDs).'</font></td></tr>'.
     '</table>';      '</table>';
     }      }
       if ($response eq 'essay') {
    if (! exists ($ENV{'form.'.$symb})) {
       my (%keyhash) = &Apache::lonnet::dump('nohist_handgrade',
     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
   
       my $loginuser = $ENV{'user.name'}.':'.$ENV{'user.domain'};
       $ENV{'form.keywords'} = $keyhash{$symb.'_keywords'} ne '' ? $keyhash{$symb.'_keywords'} : '';
       $ENV{'form.kwclr'}    = $keyhash{$loginuser.'_kwclr'} ne '' ? $keyhash{$loginuser.'_kwclr'} : 'red';
       $ENV{'form.kwsize'}   = $keyhash{$loginuser.'_kwsize'} ne '' ? $keyhash{$loginuser.'_kwsize'} : '0';
       $ENV{'form.kwstyle'}  = $keyhash{$loginuser.'_kwstyle'} ne '' ? $keyhash{$loginuser.'_kwstyle'} : '';
       $ENV{'form.'.$symb} = 1; # so that we don't have to read it from disk for multiple sub of the same prob.
    }
    return &keywords_highlight($answer);
       }
     return $answer;      return $answer;
 }  }
   
Line 197  COMMONJSFUNCTIONS Line 214  COMMONJSFUNCTIONS
 #--- section, ids and fullnames for each user.  #--- section, ids and fullnames for each user.
 sub getclasslist {  sub getclasslist {
     my ($getsec,$filterlist) = @_;      my ($getsec,$filterlist) = @_;
       $getsec = $getsec eq '' ? 'all' : $getsec;
     my $classlist=&Apache::loncoursedata::get_classlist();      my $classlist=&Apache::loncoursedata::get_classlist();
     # Bail out if we were unable to get the classlist      # Bail out if we were unable to get the classlist
     return if (! defined($classlist));      return if (! defined($classlist));
Line 430  sub listStudents { Line 448  sub listStudents {
     my $result='<h3><font color="#339933">&nbsp;'.$viewgrade.      my $result='<h3><font color="#339933">&nbsp;'.$viewgrade.
  ' Submissions for a Student or a Group of Students</font></h3>';   ' Submissions for a Student or a Group of Students</font></h3>';
   
     my ($table,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});      my ($table,undef,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});
     $result.=$table;      $result.=$table;
   
     $request->print(<<LISTJAVASCRIPT);      $request->print(<<LISTJAVASCRIPT);
Line 485  LISTJAVASCRIPT Line 503  LISTJAVASCRIPT
   
     $gradeTable.='<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last sub only'."\n".      $gradeTable.='<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last sub only'."\n".
  '<input type="radio" name="lastSub" value="last" /> last sub & parts info'."\n".   '<input type="radio" name="lastSub" value="last" /> last sub & parts info'."\n".
    '<input type="radio" name="lastSub" value="datesub" /> by dates and submissions'."\n".
  '<input type="radio" name="lastSub" value="all" /> all details'."\n".   '<input type="radio" name="lastSub" value="all" /> all details'."\n".
  '<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".   '<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="response"    value="'.$ENV{'form.response'}.'" />'."\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".
  '<input type="hidden" name="saveState"   value="'.$ENV{'form.saveState'}.'" />'."\n".   '<input type="hidden" name="saveState"   value="'.$ENV{'form.saveState'}.'" />'."\n".
Line 707  sub sub_page_js { Line 725  sub sub_page_js {
     }      }
   
     function checkSolved(formname,id) {      function checkSolved(formname,id) {
  if (eval("formname.solved"+id+".value") == "correct_by_student") {   if (eval("formname.solved"+id+".value") == "correct_by_student" && formname.overRideScore.value == 'no') {
     var reply = confirm("This problem has been graded correct by the computer. Do you want to change the score?");      var reply = confirm("This problem has been graded correct by the computer. Do you want to change the score?");
     if (!reply) {return "noupdate";}      if (!reply) {return "noupdate";}
       formname.overRideScore.value = 'yes';
  }   }
  return "update";   return "update";
     }      }
Line 720  sub sub_page_js { Line 739  sub sub_page_js {
  return;   return;
     }      }
   
 //=========== Check that a point is assigned for all the parts (essay grading only) ============  //=========== Check that a point is assigned for all the parts  ============
     function checksubmit(formname,val,total,parttot) {      function checksubmit(formname,val,total,parttot) {
  document.SCORE.gradeOpt.value = val;   formname.gradeOpt.value = val;
  if (val == "Save & Next") {   if (val == "Save & Next") {
     for (i=0;i<=total;i++) {      for (i=0;i<=total;i++) {
  for (j=0;j<parttot;j++) {   for (j=0;j<parttot;j++) {
Line 744  sub sub_page_js { Line 763  sub sub_page_js {
     }      }
           
  }   }
    if (val == "Grade Student") {
       formname.showgrading.value = "yes";
       if (formname.Status.value == "") {
    formname.Status.value = "Active";
       }
       formname.studentNo.value = total;
    }
  formname.submit();   formname.submit();
     }      }
   
Line 797  sub sub_page_kw_js { Line 823  sub sub_page_kw_js {
 <script type="text/javascript" language="javascript">  <script type="text/javascript" language="javascript">
   
 //===================== Show list of keywords ====================  //===================== Show list of keywords ====================
   function keywords(keyform) {    function keywords(formname) {
     var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",keyform.value);      var nret = prompt("Keywords list, separated by a space. Add/delete to list if desired.",formname.keywords.value);
     if (nret==null) return;      if (nret==null) return;
     keyform.value = nret;      formname.keywords.value = nret;
   
     document.SCORE.refresh.value = "on";      formname.refresh.value = "on";
     if (document.SCORE.keywords.value != "") {      if (formname.keywords.value != "") {
  document.SCORE.submit();   formname.submit();
     }      }
     return;      return;
   }    }
Line 1160  sub submission { Line 1186  sub submission {
   
     (my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;      (my $url=$ENV{'form.url'})=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
     my ($uname,$udom)     = ($ENV{'form.student'},$ENV{'form.userdom'});      my ($uname,$udom)     = ($ENV{'form.student'},$ENV{'form.userdom'});
       $udom = ($udom eq '' ? $ENV{'user.domain'} : $udom); #has form.userdom changed for a student?
     my $usec = &Apache::lonnet::getsection($udom,$uname,$ENV{'request.course.id'});      my $usec = &Apache::lonnet::getsection($udom,$uname,$ENV{'request.course.id'});
     $ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq '';      $ENV{'form.fullname'} = &get_fullname ($uname,$udom) if $ENV{'form.fullname'} eq '';
   
Line 1173  sub submission { Line 1200  sub submission {
  return;   return;
     }      }
   
       $ENV{'form.lastSub'} = ($ENV{'form.lastSub'} eq '' ? 'datesub' : $ENV{'form.lastSub'});
     my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');      my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
       my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL').
    '/check.gif" height="16" border="0" />';
   
     # header info      # header info
     if ($counter == 0) {      if ($counter == 0) {
Line 1186  sub submission { Line 1216  sub submission {
  '<font size=+1>&nbsp;<b>Resource: </b>'.$ENV{'form.probTitle'}.'</font>'."\n");   '<font size=+1>&nbsp;<b>Resource: </b>'.$ENV{'form.probTitle'}.'</font>'."\n");
   
  if ($ENV{'form.handgrade'} eq 'no') {   if ($ENV{'form.handgrade'} eq 'no') {
     my $checkIcon = '<img src="'.$request->dir_config('lonIconsURL').  
  '/check.gif" height="16" border="0" />';  
     my $checkMark='<br /><br />&nbsp;<b>Note:</b> Part(s) graded correct by the computer is marked with a '.      my $checkMark='<br /><br />&nbsp;<b>Note:</b> Part(s) graded correct by the computer is marked with a '.
  $checkIcon.' symbol.'."\n";   $checkIcon.' symbol.'."\n";
     $request->print($checkMark);      $request->print($checkMark);
Line 1217  sub submission { Line 1245  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'};
   
  $request->print('<form action="/adm/grades" method="post" name="SCORE">'."\n".   $request->print('<form action="/adm/grades" method="post" name="SCORE">'."\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".
  '<input type="hidden" name="Status"     value="'.$ENV{'form.Status'}.'" />'."\n".   '<input type="hidden" name="Status"     value="'.$ENV{'form.Status'}.'" />'."\n".
    '<input type="hidden" name="overRideScore" value="'.$overRideScore.'" />'."\n".
  '<input type="hidden" name="probTitle"  value="'.$ENV{'form.probTitle'}.'" />'."\n".   '<input type="hidden" name="probTitle"  value="'.$ENV{'form.probTitle'}.'" />'."\n".
  '<input type="hidden" name="refresh"    value="off" />'."\n".   '<input type="hidden" name="refresh"    value="off" />'."\n".
    '<input type="hidden" name="studentNo"  value="" />'."\n".
    '<input type="hidden" name="gradeOpt"   value="" />'."\n".
  '<input type="hidden" name="symb"       value="'.$symb.'" />'."\n".   '<input type="hidden" name="symb"       value="'.$symb.'" />'."\n".
  '<input type="hidden" name="url"        value="'.$url.'" />'."\n".   '<input type="hidden" name="url"        value="'.$url.'" />'."\n".
  '<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" />'."\n".   '<input type="hidden" name="showgrading" value="'.$ENV{'form.showgrading'}.'" />'."\n".
Line 1231  sub submission { Line 1263  sub submission {
  '<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".   '<input type="hidden" name="section"    value="'.$ENV{'form.section'}.'">'."\n".
  '<input type="hidden" name="submitonly" value="'.$ENV{'form.submitonly'}.'">'."\n".   '<input type="hidden" name="submitonly" value="'.$ENV{'form.submitonly'}.'">'."\n".
  '<input type="hidden" name="response"   value="'.$ENV{'form.response'}.'">'."\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="keywords"   value="'.$ENV{'form.keywords'}.'" />'."\n".   '<input type="hidden" name="keywords"   value="'.$ENV{'form.keywords'}.'" />'."\n".
  '<input type="hidden" name="kwclr"      value="'.$ENV{'form.kwclr'}.'" />'."\n".   '<input type="hidden" name="kwclr"      value="'.$ENV{'form.kwclr'}.'" />'."\n".
Line 1259  sub submission { Line 1290  sub submission {
 #  #
     $request->print(<<KEYWORDS);      $request->print(<<KEYWORDS);
 &nbsp;<b>Keyword Options:</b>&nbsp;  &nbsp;<b>Keyword Options:</b>&nbsp;
 <a href="javascript:keywords(document.SCORE.keywords)"; TARGET=_self>List</a>&nbsp; &nbsp;  <a href="javascript:keywords(document.SCORE)"; TARGET=_self>List</a>&nbsp; &nbsp;
 <a href="#" onMouseDown="javascript:getSel(); return false"  <a href="#" onMouseDown="javascript:getSel(); return false"
  CLASS="page">Paste Selection to List</a>&nbsp; &nbsp;   CLASS="page">Paste Selection to List</a>&nbsp; &nbsp;
 <a href="javascript:kwhighlight()"; TARGET=_self>Highlight Attribute</a><br /><br />  <a href="javascript:kwhighlight()"; TARGET=_self>Highlight Attribute</a><br /><br />
Line 1279  KEYWORDS Line 1310  KEYWORDS
  $request->print('<br /><br /><br />') if ($counter > 0);   $request->print('<br /><br /><br />') if ($counter > 0);
  $request->print(&show_problem($request,$symb,$uname,$udom,1,1));   $request->print(&show_problem($request,$symb,$uname,$udom,1,1));
     }      }
   
     my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);      my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$udom,$uname);
     my ($partlist,$handgrade) = &response_type($url);      my ($partlist,$handgrade) = &response_type($url);
   
Line 1379  KEYWORDS Line 1409  KEYWORDS
     if (!exists($record{'resource.'.$partid.'.'.$respid.'.submission'})) {      if (!exists($record{'resource.'.$partid.'.'.$respid.'.submission'})) {
  $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.   $lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
     $partid.'</b> <font color="#999999">( ID '.$respid.      $partid.'</b> <font color="#999999">( ID '.$respid.
     ' )</font>&nbsp; &nbsp;Nothing submitted<br /><br />';      ' )</font>&nbsp; &nbsp;Nothing submitted - no attempts<br /><br />';
      } else {       } else {
  foreach (@$string) {   foreach (@$string) {
     my ($partid,$respid) = /^resource\.(\w+)\.(\w+)\.submission/;      my ($partid,$respid) = /^resource\.(\w+)\.(\w+)\.submission/;
Line 1406  KEYWORDS Line 1436  KEYWORDS
      'this file may contain virusses</font><br />':'').       'this file may contain virusses</font><br />':'').
      '<b>Submitted Answer: </b>'.($responsetype =~ /^(essay|option)$/ ?        '<b>Submitted Answer: </b>'.($responsetype =~ /^(essay|option)$/ ? 
   '<blockquote>' : '').    '<blockquote>' : '').
      &cleanRecord(&keywords_highlight($subval),$responsetype).  #     &cleanRecord(&keywords_highlight($subval),$responsetype).
        &cleanRecord($subval,$responsetype,$symb).
      ($responsetype =~ /^(essay|option)$/ ? '</blockquote><br />' :        ($responsetype =~ /^(essay|option)$/ ? '</blockquote><br />' : 
       '<br /><br />').$similar."\n"        '<br /><br />').$similar."\n"
      if ($ENV{'form.lastSub'} eq 'lastonly' ||        if ($ENV{'form.lastSub'} eq 'lastonly' || 
Line 1420  KEYWORDS Line 1451  KEYWORDS
     $lastsubonly.='</td></tr><tr bgcolor="#ffffff"><td>'."\n";      $lastsubonly.='</td></tr><tr bgcolor="#ffffff"><td>'."\n";
     $request->print($lastsubonly);      $request->print($lastsubonly);
  }   }
     } else {      } elsif ($ENV{'form.lastSub'} eq 'datesub') {
    my (undef,$responseType,undef,$parts) = &showResourceInfo($url);
    $request->print(&displaySubByDates(\$symb,\%record,$parts,$responseType,$checkIcon));
       } elsif ($ENV{'form.lastSub'} =~ /^(last|all)$/) {
  $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,   $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
  $ENV{'request.course.id'},   $ENV{'request.course.id'},
  $last,'.submission',   $last,'.submission',
  'Apache::grades::keywords_highlight'));   'Apache::grades::keywords_highlight'));
     }      }
   
       $request->print('<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'
    .$udom.'" />'."\n");
           
     # return if view submission with no grading option      # return if view submission with no grading option
     if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) {      if ($ENV{'form.showgrading'} eq '' || (!&canmodify($usec))) {
  $request->print('</td></tr></table></td></tr></table></form>'."\n");   my $toGrade.='<input type="button" value="Grade Student" '.
  $request->print(&show_grading_menu_form($symb,$url))       'onClick="javascript:checksubmit(this.form,\'Grade Student\',\''
       .$counter.'\');" TARGET=_self> &nbsp;'."\n" if (&canmodify($usec));
    $toGrade.='</td></tr></table></td></tr></table></form>'."\n";
    $toGrade.=&show_grading_menu_form($symb,$url) 
     if (($ENV{'form.command'} eq 'submission') ||       if (($ENV{'form.command'} eq 'submission') || 
  ($ENV{'form.command'} eq 'processGroup' && $counter == $total));   ($ENV{'form.command'} eq 'processGroup' && $counter == $total));
    $request = print($toGrade);
  return;   return;
     }      }
   
     $result='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n".      # essay grading message center
  '<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".  
  '<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'  
  .$udom.'" />'."\n";  
     # essay grading options  
     if ($ENV{'form.handgrade'} eq 'yes') {      if ($ENV{'form.handgrade'} eq 'yes') {
  my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});   my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
  my $msgfor = $givenn.' '.$lastname;   my $msgfor = $givenn.' '.$lastname;
Line 1450  KEYWORDS Line 1487  KEYWORDS
  }   }
  $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript   $msgfor =~ s/\'/\\'/g; #' stupid emacs - no! javascript
 # $result.='<tr><td bgcolor="#ffffff">'."\n".  # $result.='<tr><td bgcolor="#ffffff">'."\n".
    $result='<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
       '<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n";
  $result.='&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.   $result.='&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.
     ',\''.$msgfor.'\')"; TARGET=_self>'.      ',\''.$msgfor.'\')"; TARGET=_self>'.
     'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a> &nbsp;'.      'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a> &nbsp;'.
Line 1457  KEYWORDS Line 1496  KEYWORDS
     '/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".      '/mailbkgrd.gif" width="14" height="10" name="mailicon'.$counter.'" />'."\n".
     '<br />&nbsp;(Message will be sent when you click on Save & Next below.)'."\n"       '<br />&nbsp;(Message will be sent when you click on Save & Next below.)'."\n" 
     if ($ENV{'form.handgrade'} eq 'yes');      if ($ENV{'form.handgrade'} eq 'yes');
    $request->print($result);
     }      }
     $request->print($result);  
   
     my %seen = ();      my %seen = ();
     my @partlist;      my @partlist;
Line 1483  KEYWORDS Line 1522  KEYWORDS
   
     # print end of form      # print end of form
     if ($counter == $total) {      if ($counter == $total) {
  my $endform='<table border="0"><tr><td>'.   my $endform='<table border="0"><tr><td>'."\n";
     '<input type="hidden" name="gradeOpt" value="" />'."\n";  
  $endform.='<input type="button" value="Save & Next" '.   $endform.='<input type="button" value="Save & Next" '.
     'onClick="javascript:checksubmit(this.form,\'Save & Next\','.      'onClick="javascript:checksubmit(this.form,\'Save & Next\','.
     $total.','.scalar(@partlist).');" TARGET=_self> &nbsp;'."\n";      $total.','.scalar(@partlist).');" TARGET=_self> &nbsp;'."\n";
Line 1554  sub processHandGrade { Line 1592  sub processHandGrade {
     my $button = $ENV{'form.gradeOpt'};      my $button = $ENV{'form.gradeOpt'};
     my $ngrade = $ENV{'form.NCT'};      my $ngrade = $ENV{'form.NCT'};
     my $ntstu  = $ENV{'form.NTSTU'};      my $ntstu  = $ENV{'form.NTSTU'};
   
     if ($button eq 'Save & Next') {      if ($button eq 'Save & Next') {
  my $ctr = 0;   my $ctr = 0;
  while ($ctr < $ngrade) {   while ($ctr < $ngrade) {
Line 1648  sub processHandGrade { Line 1685  sub processHandGrade {
      $ENV{'course.'.$ENV{'request.course.id'}.'.num'});       $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
     }      }
     # Called by Save & Refresh from Highlight Attribute Window      # Called by Save & Refresh from Highlight Attribute Window
 #    my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'0');  
     my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');      my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
     if ($ENV{'form.refresh'} eq 'on') {      if ($ENV{'form.refresh'} eq 'on') {
  my ($ctr,$total) = (0,0);   my ($ctr,$total) = (0,0);
Line 1668  sub processHandGrade { Line 1704  sub processHandGrade {
  return '';   return '';
     }      }
   
   # Go directly to grade student - from submission or link from chart page
       if ($button eq 'Grade Student') {
    (undef,undef,$ENV{'form.handgrade'},undef,undef) = &showResourceInfo($url);
    my $processUser = $ENV{'form.unamedom'.$ENV{'form.studentNo'}};
    ($ENV{'form.student'},$ENV{'form.userdom'}) = split(/:/,$processUser);
    $ENV{'form.fullname'} = $$fullname{$processUser};
    &submission($request,0,0);
    return '';
       }
   
     # Get the next/previous one or group of students      # Get the next/previous one or group of students
     my $firststu = $ENV{'form.unamedom0'};      my $firststu = $ENV{'form.unamedom0'};
     my $laststu = $ENV{'form.unamedom'.($ngrade-1)};      my $laststu = $ENV{'form.unamedom'.($ngrade-1)};
Line 1768  sub saveHandGrade { Line 1814  sub saveHandGrade {
     }      }
     $newrecord{'resource.'.$_.'.submitted_by'} = $submitter       $newrecord{'resource.'.$_.'.submitted_by'} = $submitter 
  if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));   if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
     $newrecord{'resource.'.$_.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";      $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
  }   }
     }      }
   
Line 2047  sub viewgrades { Line 2093  sub viewgrades {
     my (@parts) = sort(&getpartlist($url));      my (@parts) = sort(&getpartlist($url));
     foreach my $part (@parts) {      foreach my $part (@parts) {
  my $display=&Apache::lonnet::metadata($url,$part.'.display');   my $display=&Apache::lonnet::metadata($url,$part.'.display');
  next if ($display =~ /Number of Attempts/);   $display =~ s/^Number of Attempts/Tries/; # makes the column narrower
  if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }   if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
  if ($display =~ /^Partial Credit Factor/) {   if ($display =~ /^Partial Credit Factor/) {
     my ($partid) = &split_part_type($part);      my ($partid) = &split_part_type($part);
Line 2119  sub viewstudentgrade { Line 2165  sub viewstudentgrade {
  if ($status eq 'excused');   if ($status eq 'excused');
     $result.=$optsel;      $result.=$optsel;
     $result.="</select></td>\n";      $result.="</select></td>\n";
 # } else {   } else {
 #    $result.='<input type="hidden" name="'.      $result.='<input type="hidden" name="'.
 # 'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.   'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
 #    "\n";      "\n";
 #    $result.='<td align="middle"><input type="text" name="'.      $result.='<td align="middle"><input type="text" name="'.
 # 'GD_'.$student.'_'.$part.'_'.$type.'" '.   'GD_'.$student.'_'.$part.'_'.$type.'" '.
 # 'value="'.$score.'" size="4" /></td>'."\n";   'value="'.$score.'" size="4" /></td>'."\n";
  }   }
     }      }
     $result.='</tr>';      $result.='</tr>';
Line 2249  sub editgrades { Line 2295  sub editgrades {
  my $awarded   = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type};   my $awarded   = $ENV{'form.GD_'.$user.'_'.$part.'_'.$type};
  if ($awarded ne '' && $awarded ne $old_aw) {   if ($awarded ne '' && $awarded ne $old_aw) {
     $newrecord{'resource.'.$part.'.'.$type}= $awarded;      $newrecord{'resource.'.$part.'.'.$type}= $awarded;
     $newrecord{'resource.'.$part.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";      $newrecord{'resource.'.$part.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
     $updateflag=1;      $updateflag=1;
  }   }
  $line .= '<td align="center">'.$old_aw.'&nbsp;</td>'.   $line .= '<td align="center">'.$old_aw.'&nbsp;</td>'.
Line 2378  sub csvuploadmap_header { Line 2424  sub csvuploadmap_header {
  $javascript=&csvupload_javascript_forward_associate();   $javascript=&csvupload_javascript_forward_associate();
     }      }
   
     my ($result,$resptype,$hdgrade,$partlist,$handgrade) = &showResourceInfo($url,$ENV{'form.probTitle'});      my ($result) = &showResourceInfo($url,$ENV{'form.probTitle'});
   
     $request->print(<<ENDPICK);      $request->print(<<ENDPICK);
 <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">  <form method="post" enctype="multipart/form-data" action="/adm/grades" name="gradesupload">
Line 2590  sub csvuploadassign { Line 2636  sub csvuploadassign {
 #  #
 #-------------------------------------------------------------------  #-------------------------------------------------------------------
 #  #
 #-------------- Next few routines handles grading by page/sequence  #-------------- Next few routines handle grading by page/sequence
 #  #
 #--- Select a page/sequence and a student to grade  #--- Select a page/sequence and a student to grade
 sub pickStudentPage {  sub pickStudentPage {
Line 2649  LISTJAVASCRIPT Line 2695  LISTJAVASCRIPT
   
     $result.='&nbsp;<b>Submission Details: </b>'.      $result.='&nbsp;<b>Submission Details: </b>'.
  '<input type="radio" name="lastSub" value="none" /> none'."\n".   '<input type="radio" name="lastSub" value="none" /> none'."\n".
  '<input type="radio" name="lastSub" value="datesub" checked /> dates and submissions'."\n".   '<input type="radio" name="lastSub" value="datesub" checked /> by dates and submissions'."\n".
  '<input type="radio" name="lastSub" value="all" /> all details'."\n";   '<input type="radio" name="lastSub" value="all" /> all details'."\n";
   
     $result.='<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".      $result.='<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
Line 2779  sub displayPage { Line 2825  sub displayPage {
         if($curRes == $iterator->BEGIN_MAP) { $depth++; }          if($curRes == $iterator->BEGIN_MAP) { $depth++; }
         if($curRes == $iterator->END_MAP) { $depth--; }          if($curRes == $iterator->END_MAP) { $depth--; }
   
         if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {  #        if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
           if (ref($curRes) && $curRes->is_problem()) {
     my $parts = $curRes->parts();      my $parts = $curRes->parts();
             my $title = $curRes->compTitle();              my $title = $curRes->compTitle();
     my $symbx = $curRes->symb();      my $symbx = $curRes->symb();
Line 2809  sub displayPage { Line 2856  sub displayPage {
     foreach my $partid (@{$parts}) {      foreach my $partid (@{$parts}) {
  $responseType{$partid} = $curRes->responseType($partid);   $responseType{$partid} = $curRes->responseType($partid);
     }      }
     $studentTable.= &displaySubByDates(\%record,$parts,\%responseType,$checkIcon);      $studentTable.= &displaySubByDates(\$symbx,\%record,$parts,\%responseType,$checkIcon);
  }   }
     } elsif ($ENV{'form.lastSub'} eq 'all') {      } elsif ($ENV{'form.lastSub'} eq 'all') {
  my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');   my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
Line 2844  sub displayPage { Line 2891  sub displayPage {
 }  }
   
 sub displaySubByDates {  sub displaySubByDates {
     my ($record,$parts,$responseType,$checkIcon) = @_;      my ($symbx,$record,$parts,$responseType,$checkIcon) = @_;
     my $studentTable='<table border="0" width="100%"><tr><td bgcolor="#777777">'.      my $studentTable='<table border="0" width="100%"><tr><td bgcolor="#777777">'.
  '<table border="0" width="100%"><tr bgcolor="#e6ffff">'.   '<table border="0" width="100%"><tr bgcolor="#e6ffff">'.
  '<td><b>Date/Time</b></td>'.   '<td><b>Date/Time</b></td>'.
Line 2853  sub displaySubByDates { Line 2900  sub displaySubByDates {
     my ($version);      my ($version);
     my %mark;      my %mark;
     $mark{'correct_by_student'} = $checkIcon;      $mark{'correct_by_student'} = $checkIcon;
       return '<br />&nbsp;<font color="red">Nothing submitted - no attempts</font><br />' 
    if (!exists($$record{'1:timestamp'}));
     for ($version=1;$version<=$$record{'version'};$version++) {      for ($version=1;$version<=$$record{'version'};$version++) {
  my $timestamp = scalar(localtime($$record{$version.':timestamp'}));   my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
  $studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>';   $studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>';
Line 2860  sub displaySubByDates { Line 2909  sub displaySubByDates {
  my @displaySub = ();   my @displaySub = ();
  foreach my $partid (@{$parts}) {   foreach my $partid (@{$parts}) {
     my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;      my @matchKey = grep /^resource\.$partid\..*?\.submission$/,@versionKeys;
     next if ($$record{"$version:resource.$partid.solved"} eq '');  #    next if ($$record{"$version:resource.$partid.solved"} eq '');
     $displaySub[0].=(exists $$record{$version.':'.$matchKey[0]}) ?       $displaySub[0].=(exists $$record{$version.':'.$matchKey[0]}) ? 
  '<b>Part&nbsp;'.$partid.'&nbsp;'.   '<b>Part&nbsp;'.$partid.'&nbsp;'.
  ($$record{"$version:resource.$partid.tries"} eq '' ? 'Trial&nbsp;not&nbsp;counted' :   ($$record{"$version:resource.$partid.tries"} eq '' ? 'Trial&nbsp;not&nbsp;counted' :
  'Trial&nbsp;'.$$record{"$version:resource.$partid.tries"}).'</b>&nbsp; '.   'Trial&nbsp;'.$$record{"$version:resource.$partid.tries"}).'</b>&nbsp; '.
  &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid}).'<br />' : '';   &cleanRecord($$record{$version.':'.$matchKey[0]},$$responseType{$partid},$$symbx).'<br />' : '';
     $displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ?      $displaySub[1].=(exists $$record{"$version:resource.$partid.award"}) ?
  '<b>Part&nbsp;'.$partid.'</b> &nbsp;'.   '<b>Part&nbsp;'.$partid.'</b> &nbsp;'.
  lc($$record{"$version:resource.$partid.award"}).' '.   lc($$record{"$version:resource.$partid.award"}).' '.
  $mark{$$record{"$version:resource.$partid.solved"}}.'<br />' : '';   $mark{$$record{"$version:resource.$partid.solved"}}.'<br />' : '';
 #    $$record{"$version:resource.$partid.solved"}.'<br />' : '';  
     $displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ?      $displaySub[2].=(exists $$record{"$version:resource.$partid.regrader"}) ?
  $$record{"$version:resource.$partid.regrader"}.' (<b>Part:</b> '.$partid.')' : '';   $$record{"$version:resource.$partid.regrader"}.' (<b>Part:</b> '.$partid.')' : '';
  }   }
Line 3385  sub gradingmenu { Line 3433  sub gradingmenu {
 GRADINGMENUJS  GRADINGMENUJS
     &commonJSfunctions($request);      &commonJSfunctions($request);
     my $result='<h3>&nbsp;<font color="#339933">Manual Grading/View Submission</font></h3>';      my $result='<h3>&nbsp;<font color="#339933">Manual Grading/View Submission</font></h3>';
     my ($table,$resptype,$hdgrade) = &showResourceInfo($url,$probTitle);      my ($table,undef,$hdgrade) = &showResourceInfo($url,$probTitle);
     $result.=$table;      $result.=$table;
     my (undef,$sections) = &getclasslist('all','0');      my (undef,$sections) = &getclasslist('all','0');
     my $savedState = &savedState();      my $savedState = &savedState();
Line 3397  GRADINGMENUJS Line 3445  GRADINGMENUJS
     $result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n".      $result.='<form action="/adm/grades" method="post" name="gradingMenu">'."\n".
  '<input type="hidden" name="symb"        value="'.$symb.'" />'."\n".   '<input type="hidden" name="symb"        value="'.$symb.'" />'."\n".
  '<input type="hidden" name="url"         value="'.$url.'" />'."\n".   '<input type="hidden" name="url"         value="'.$url.'" />'."\n".
  '<input type="hidden" name="response"    value="'.$resptype.'" />'."\n".  
  '<input type="hidden" name="handgrade"   value="'.$hdgrade.'" />'."\n".   '<input type="hidden" name="handgrade"   value="'.$hdgrade.'" />'."\n".
  '<input type="hidden" name="probTitle"   value="'.$probTitle.'" />'."\n".   '<input type="hidden" name="probTitle"   value="'.$probTitle.'" />'."\n".
  '<input type="hidden" name="command"     value="" />'."\n".   '<input type="hidden" name="command"     value="" />'."\n".

Removed from v.1.119  
changed lines
  Added in v.1.122


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