Diff for /loncom/homework/grades.pm between versions 1.45 and 1.52

version 1.45, 2002/08/05 20:49:54 version 1.52, 2002/09/21 00:08:17
Line 45  use Apache::Constants qw(:common); Line 45  use Apache::Constants qw(:common);
   
 # ----- These first few routines are general use routines.-----  # ----- These first few routines are general use routines.-----
 #  #
   
 sub print_hash {  
     my ($request, $hash) = @_;  
     $request->print('<table border=1><tr><td>Key</td><td>Value</td></tr>');  
     for (sort keys (%$hash)) {  
  $request->print('<tr><td>'.$_.'</td><td>'.$$hash{$_}.'&nbsp;</td></tr>');  
     }  
     $request->print('</table>');  
     return '';  
 }  
   
 # --- Retrieve the parts that matches stores_\d+ from the metadata file.---  # --- Retrieve the parts that matches stores_\d+ from the metadata file.---
 sub getpartlist {  sub getpartlist {
     my ($url) = @_;      my ($url) = @_;
Line 114  sub response_type { Line 103  sub response_type {
     return \@partlist,\%handgrade;      return \@partlist,\%handgrade;
 }  }
   
 #--- Prints a message on screen if a user did something wrong  
 #--- Operator error ---  
 sub userError {  
     my ($request, $reason, $step) = @_;  
     $request->print('<h3><font color="red">LON-CAPA User Error</font></h3><br />'."\n");  
     $request->print('<b>Reason: </b>'.$reason.'<br /><br />'."\n");  
     $request->print('<b>Step: </b>'.($step ne '' ? $step : 'Use your browser back button to correct')  
     .'<br /><br />'."\n");  
     return '';  
 }  
   
 #--- Dumps the class list with usernames,list of sections,  #--- Dumps the class list with usernames,list of sections,
 #--- section, ids and fullnames for each user.  #--- section, ids and fullnames for each user.
 sub getclasslist {  sub getclasslist {
Line 133  sub getclasslist { Line 111  sub getclasslist {
     my %classlist=&Apache::lonnet::dump('classlist',      my %classlist=&Apache::lonnet::dump('classlist',
  $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
  $ENV{'course.'.$ENV{'request.course.id'}.'.num'});   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
       my ($tmp) = keys(%classlist);
       # Bail out if we were unable to get the classlist
       return if ($tmp =~ /^(con_lost|error|no_such_host)/i);
   
     # codes to check for fields in the classlist      # codes to check for fields in the classlist
     # should contain end:start:id:section:fullname      # should contain end:start:id:section:fullname
     for (keys %classlist) {      for (keys %classlist) {
Line 310  sub verifyreceipt { Line 292  sub verifyreceipt {
     $contents.      $contents.
     '</table></td></tr></table>'."\n";      '</table></td></tr></table>'."\n";
     }      }
     return $string.&show_grading_menu_form ($symb,$url);      return $string.&show_grading_menu_form($symb,$url);
 }  }
   
 #--- This is called by a number of programs.  #--- This is called by a number of programs.
Line 319  sub verifyreceipt { Line 301  sub verifyreceipt {
 #    on the problem page.  #    on the problem page.
 sub listStudents {  sub listStudents {
     my ($request) = shift;      my ($request) = shift;
   
       my ($symb,$url) = &get_symb_and_url();
       my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};
       my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};
       my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
       my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};
   
       my $result;
       my ($partlist,$handgrade) = &response_type($url);
       for (sort keys(%$handgrade)) {
    my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
    $ENV{'form.handgrade'} = 'yes' if ($handgrade eq 'yes');
    $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.
       '<td><b>Type: </b>'.$responsetype.'</td>'.
       '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';
       }
       $result.='</table>';
   
       my $viewgrade;
       if ($ENV{'form.handgrade'} eq 'yes') {
    $viewgrade = 'View/Grade';
       } else {
    $viewgrade = 'View';
       }
   
       $result='<h3><font color="#339933">&nbsp;'.
    $viewgrade.
       ' Submissions for a Student or a Group of Students</font></h3>'.
    '<table border="0"><tr><td colspan=3><font size=+1>'.
       '<b>Resource: </b>'.$url.'</font></td></tr>'.$result;
   
     $request->print(<<LISTJAVASCRIPT);      $request->print(<<LISTJAVASCRIPT);
 <script type="text/javascript" language="javascript">  <script type="text/javascript" language="javascript">
   function checkSelect(checkBox) {    function checkSelect(checkBox) {
     var ctr=0;      var ctr=0;
       var sense="";
     if (checkBox.length > 1) {      if (checkBox.length > 1) {
        for (var i=0; i<checkBox.length; i++) {         for (var i=0; i<checkBox.length; i++) {
   if (checkBox[i].checked) {    if (checkBox[i].checked) {
      ctr++;       ctr++;
   }    }
        }         }
          sense = "a student or group of students";
     } else {      } else {
        if (checkBox.checked) {         if (checkBox.checked) {
    ctr = 1;     ctr = 1;
        }         }
          sense = "the student";
     }      }
     if (ctr == 0) {      if (ctr == 0) {
        alert("You did not select any student.");         alert("Please select "+sense+" before clicking on the $viewgrade button.");
        return false;         return false;
     }      }
     document.gradesub.submit();      document.gradesub.submit();
Line 343  sub listStudents { Line 359  sub listStudents {
 </script>  </script>
 LISTJAVASCRIPT  LISTJAVASCRIPT
   
     my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};  
     my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};  
     my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};  
     my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};  
   
     my $result='<h3><font color="#339933">&nbsp;'.  
  'View/Grade Submissions for a Student or a Group of Students</font></h3>';  
     $result.='<table border="0">';  
     $result.='<tr><td colspan=3><font size=+1>'.  
  '<b>Resource: </b>'.$ENV{'form.url'}.'</font></td></tr>';  
     my ($partlist,$handgrade) = &response_type($ENV{'form.url'});  
     for (sort keys(%$handgrade)) {  
  my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});  
  $ENV{'form.handgrade'} = 'yes' if ($handgrade eq 'yes');  
  $result.='<tr><td><b>Part </b>'.(split(/_/))[0].'</td>'.  
     '<td><b>Type: </b>'.$responsetype.'</td>'.  
     '<td><b>Handgrade: </b>'.$handgrade.'</font></td></tr>';  
     }  
     $result.='</table>';  
     $request->print($result);      $request->print($result);
   
     my $checkhdgrade = $ENV{'form.handgrade'} eq 'yes' ? 'checked' : '';      my $checkhdgrade = $ENV{'form.handgrade'} eq 'yes' ? 'checked' : '';
Line 370  LISTJAVASCRIPT Line 367  LISTJAVASCRIPT
     my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n".      my $gradeTable='<form action="/adm/grades" method="post" name="gradesub">'."\n".
  '&nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" checked> no '."\n".   '&nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" checked> no '."\n".
  '<input type="radio" name="vProb" value="yes"> yes <br />'."\n".   '<input type="radio" name="vProb" value="yes"> yes <br />'."\n".
  '&nbsp;<b>Submissions: </b>'."\n".   '&nbsp;<b>Submissions: </b>'."\n";
  '<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n".      if ($ENV{'form.handgrade'} eq 'yes') {
  '<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last sub only'."\n".   $gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade 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="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".
Line 380  LISTJAVASCRIPT Line 379  LISTJAVASCRIPT
  '<input type="hidden" name="response"    value="'.$ENV{'form.response'}.'" />'."\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="url"  value="'.$ENV{'form.url'}.'" />'."\n".   '<input type="hidden" name="url"  value="'.$url.'" />'."\n".
  '<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n".   '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
  'To view/grade a submission, click on the check box next to the student\'s name. Then '."\n".   'To '.lc($viewgrade).' a submission, click on the check box next to the student\'s name. Then '."\n".
  'click on the View/Grade button. To view the submissions for a group of students, click'."\n".   'click on the '.$viewgrade.' button. To view the submissions for a group of students, click'."\n".
  ' on the check boxes for the group of students.<br />'."\n".   ' on the check boxes for the group of students.<br />'."\n".
  '<input type="hidden" name="command" value="processGroup" />'."\n".   '<input type="hidden" name="command" value="processGroup" />'."\n".
  '<input type="button" '."\n".   '<input type="button" '."\n".
  'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".   'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".
  'value="View/Grade" />'."\n";   'value="'.$viewgrade.'" />'."\n";
     
     my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');      my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');
           
Line 404  LISTJAVASCRIPT Line 403  LISTJAVASCRIPT
     my $ctr = 0;      my $ctr = 0;
     foreach my $student (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {      foreach my $student (sort {$$fullname{$a} cmp $$fullname{$b} } keys %$fullname) {
  my ($uname,$udom) = split(/:/,$student);   my ($uname,$udom) = split(/:/,$student);
  my (%status) = &student_gradeStatus($ENV{'form.url'},   my (%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
     $ENV{'form.symb'},$udom,$uname,$partlist);  
  my $statusflg = '';   my $statusflg = '';
  foreach (keys(%status)) {   foreach (keys(%status)) {
     $statusflg = 1 if ($status{$_} ne 'nothing');      $statusflg = 1 if ($status{$_} ne 'nothing');
Line 438  LISTJAVASCRIPT Line 436  LISTJAVASCRIPT
     $gradeTable.='</table></td></tr></table>'.      $gradeTable.='</table></td></tr></table>'.
  '<input type="button" '.   '<input type="button" '.
  'onClick="javascript:checkSelect(this.form.stuinfo);" '.   'onClick="javascript:checkSelect(this.form.stuinfo);" '.
  'value="View/Grade" /><form />'."\n";   'value="'.$viewgrade.'" /></form>'."\n";
     if ($ctr == 0) {      if ($ctr == 0) {
  $gradeTable='<br />&nbsp;<font color="red">'.   $gradeTable='<br />&nbsp;<font color="red">'.
     'No submission found for this resource.</font><br />';      'No submission found for this resource.</font><br />';
  $gradeTable.=&show_grading_menu_form ($ENV{'form.symb'},$ENV{'form.url'});      } elsif ($ctr == 1) {
    $gradeTable =~ s/type=checkbox/type=checkbox checked/;
     }      }
       $gradeTable.=&show_grading_menu_form($symb,$url);
     $request->print($gradeTable);      $request->print($gradeTable);
     return '';      return '';
 }  }
Line 552  sub sub_page_js { Line 552  sub sub_page_js {
  var points = eval("document.SCORE.GD_BOX"+i+"_"+partid+".value");   var points = eval("document.SCORE.GD_BOX"+i+"_"+partid+".value");
  if (points == "") {   if (points == "") {
      var name = eval("document.SCORE.name"+i+".value");       var name = eval("document.SCORE.name"+i+".value");
      alert("You did not assign any point for "+name+", part "+partid+".");       alert("Please assign a score for "+name+", part "+partid+".");
      return false;       return false;
  }   }
       }        }
Line 594  sub sub_page_js { Line 594  sub sub_page_js {
     else return;      else return;
     var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");      var cleantxt = txt.replace(new RegExp('([\\f\\n\\r\\t\\v ])+', 'g')," ");
     if (cleantxt=="") {      if (cleantxt=="") {
  alert("Select a word or group of words from document and then click this link.");   alert("Please select a word or group of words from document and then click this link.");
  return;   return;
     }      }
     var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt);      var nret = prompt("Add selection to keyword list? Edit if desired.",cleantxt);
Line 929  KEYWORDS Line 929  KEYWORDS
     my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".      my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".
  '<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";   '<table border="0" width=100%><tr bgcolor="#edffff"><td>'."\n";
   
 #    $result.='<table border="0"><tr bgcolor="#ffffff"><td><b>Fullname: </b>'.$ENV{'form.fullname'}.  
     $result.='<b>Fullname: </b>'.$ENV{'form.fullname'}.      $result.='<b>Fullname: </b>'.$ENV{'form.fullname'}.
  '<font color="#999999">&nbsp; &nbsp;Username: '.$uname.'</font>'.   '<font color="#999999">&nbsp; &nbsp;Username: '.$uname.'</font>'.
  '<font color="#999999">&nbsp; &nbsp;Domain: '.$udom.'</font><br />'."\n";   '<font color="#999999">&nbsp; &nbsp;Domain: '.$udom.'</font><br />'."\n";
Line 1002  KEYWORDS Line 1001  KEYWORDS
     $request->print($submitby);      $request->print($submitby);
  } else {   } else {
     my ($string,$timestamp)=      my ($string,$timestamp)=
  &get_last_submission ($symb,$uname,$udom,$ENV{'request.course.id'});   &get_last_submission (%record);
     my $lastsubonly.=''.      my $lastsubonly.=''.
  ($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.   ($$timestamp eq '' ? '' : '<b>Date Submitted:</b> '.
  $$timestamp).'';   $$timestamp).'';
Line 1146  KEYWORDS Line 1145  KEYWORDS
  $endform.='(Next and Previous do not save the scores.)'."\n"    $endform.='(Next and Previous do not save the scores.)'."\n" 
     if ($ENV{'form.handgrade'} eq 'yes');      if ($ENV{'form.handgrade'} eq 'yes');
  $endform.='</td><tr></table></form>';   $endform.='</td><tr></table></form>';
    $endform.=&show_grading_menu_form($symb,$url);
  $request->print($endform);   $request->print($endform);
     }      }
     return '';      return '';
Line 1153  KEYWORDS Line 1153  KEYWORDS
   
 #--- Retrieve the last submission for all the parts  #--- Retrieve the last submission for all the parts
 sub get_last_submission {  sub get_last_submission {
     my ($symb,$username,$domain,$course)=@_;      my (%returnhash)=@_;
     if ($symb) {      my (@string,$timestamp);
  my (@string,$timestamp);      if ($returnhash{'version'}) {
  my (%returnhash)=&Apache::lonnet::restore($symb,$course,$domain,$username);   my %lasthash=();
  if ($returnhash{'version'}) {   my ($version);
     my %lasthash=();   for ($version=1;$version<=$returnhash{'version'};$version++) {
     my ($version);      foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
     for ($version=1;$version<=$returnhash{'version'};$version++) {   $lasthash{$_}=$returnhash{$version.':'.$_};
  foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {   if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
     $lasthash{$_}=$returnhash{$version.':'.$_};     $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
  }         } 
     }      }
     foreach ((keys %lasthash)) {   }
  if ($_ =~ /\.submission$/) {   foreach ((keys %lasthash)) {
     my ($partid,$foo) = split(/submission$/,$_);      if ($_ =~ /\.submission$/) {
     my $draft  = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?   my ($partid,$foo) = split(/submission$/,$_);
  '<font color="red">Draft Copy</font> ' : '';   my $draft  = $lasthash{$partid.'awarddetail'} eq 'DRAFT' ?
     push @string, (join(':',$_,$draft.$lasthash{$_}));      '<font color="red">Draft Copy</font> ' : '';
  }   push @string, (join(':',$_,$draft.$lasthash{$_}));
  if ($_ =~ /timestamp/) {$timestamp = scalar(localtime($lasthash{$_}))};  
     }      }
  }   }
  @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;  
  return \@string,\$timestamp;  
     }      }
       @string = $string[0] eq '' ? 'Nothing submitted - no attempts.' : @string;
       return \@string,\$timestamp;
 }  }
   
 #--- High light keywords, with style choosen by user.  #--- High light keywords, with style choosen by user.
Line 1585  sub viewgrades { Line 1584  sub viewgrades {
  '<input type="hidden" name="url"     value="'.$url.'" />'."\n".   '<input type="hidden" name="url"     value="'.$url.'" />'."\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";   '<input type="hidden" name="section" value="'.$ENV{'form.section'}.'" />'."\n";
     $result.='To assign the same score for all the students use the radio buttons or '.      $result.='<h3>Assign Common Grade To ';
  'text box below. To assign scores individually fill in the score boxes for '.      if ($ENV{'form.section'} eq 'all') {
  'each student in the table below. <font color="red">A part that has already '.   $result.='Class </h3>';
  'been graded does not get changed using the radio buttons or text box. '.      } elsif ($ENV{'form.section'} eq 'no') {
  'If needed, it has to be changed individually.</font>';   $result.='Students in no Section </h3>';
       } else {
    $result.='Students in Section '.$ENV{'form.section'}.'</h3>';
       }
       $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
    '<table border=0><tr bgcolor="#ffffdd"><td>';
   #    $result.='To assign the same score for all the students use the radio buttons or '.
   # 'text box below. To assign scores individually fill in the score boxes for '.
   # 'each student in the table below. <font color="red">A part that has already '.
   # 'been graded does not get changed using the radio buttons or text box. '.
   # 'If needed, it has to be changed individually.</font>';
   #    $result.='</td></tr><tr><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.
     #handles different parts of a problem      #handles different parts of a problem
     my ($partlist,$handgrade) = &response_type($ENV{'form.url'});      my ($partlist,$handgrade) = &response_type($ENV{'form.url'});
Line 1632  sub viewgrades { Line 1641  sub viewgrades {
     '<option>excused</option></select></td></tr>'."\n";      '<option>excused</option></select></td></tr>'."\n";
  $ctsparts++;   $ctsparts++;
     }      }
     $result.='</table><input type="hidden" name="totalparts" value="'.$ctsparts.'" />';      $result.='</table>'.'</td></tr></table>'.'</td></tr></table>'."\n".
    '<input type="hidden" name="totalparts" value="'.$ctsparts.'" />';
     $result.='<input type="button" value="Reset" '.      $result.='<input type="button" value="Reset" '.
  'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self> &nbsp; &nbsp;';   'onClick="javascript:resetEntry('.$ctsparts.');" TARGET=_self> &nbsp; &nbsp;';
     $result.='<input type="button" value="Submit Changes" '.      $result.='<input type="button" value="Submit Changes" '.
Line 1640  sub viewgrades { Line 1650  sub viewgrades {
   
     #table listing all the students in a section/class      #table listing all the students in a section/class
     #header of table      #header of table
       $result.= '<h3>Assign Grade to Specific Students in ';
       if ($ENV{'form.section'} eq 'all') {
    $result.='the Class </h3>';
       } elsif ($ENV{'form.section'} eq 'no') {
    $result.='no Section </h3>';
       } else {
    $result.='Section '.$ENV{'form.section'}.'</h3>';
       }
     $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".      $result.= '<table border=0><tr><td bgcolor="#777777">'."\n".
  '<table border=0><tr bgcolor="#deffff">'.   '<table border=0><tr bgcolor="#deffff">'.
  '<td><b>Fullname</b></td><td><b>Username</b></td><td><b>Domain</b></td>'."\n";   '<td><b>Fullname</b></td><td><b>Username</b></td><td><b>Domain</b></td>'."\n";
Line 2029  sub csvuploadassign { Line 2047  sub csvuploadassign {
     }      }
     $request->print('<h3>Assigning Grades</h3>');      $request->print('<h3>Assigning Grades</h3>');
     my $courseid=$ENV{'request.course.id'};      my $courseid=$ENV{'request.course.id'};
 #  my $cdom=$ENV{"course.$courseid.domain"};  
 #  my $cnum=$ENV{"course.$courseid.num"};  
     my ($classlist) = &getclasslist('all','1');      my ($classlist) = &getclasslist('all','1');
     my @skipped;      my @skipped;
     my $countdone=0;      my $countdone=0;
Line 2119  sub view_edit_entire_class_form { Line 2135  sub view_edit_entire_class_form {
     my ($classlist,$sections) = &getclasslist('all','0');      my ($classlist,$sections) = &getclasslist('all','0');
     my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";      my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
     $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";      $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
     $result.='&nbsp;<b>View/Grade Entire Section/Class</b></td></tr>'."\n";      $result.='&nbsp;<b>Grade Entire Section or Class</b></td></tr>'."\n";
     $result.='<tr bgcolor=#ffffe6><td>'."\n";      $result.='<tr bgcolor=#ffffe6><td>'."\n";
     $result.='<form action="/adm/grades" method="post">'."\n".      $result.='<form action="/adm/grades" method="post">'."\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="command" value="viewgrades" />'."\n";   '<input type="hidden" name="command" value="viewgrades" />'."\n";
     $result.='&nbsp;<b>Select section:</b> <select name="section">'."\n";      $result.='&nbsp;<b>Select section:</b> <select name="section">'."\n";
     foreach (sort (@$sections)) {      if (ref($sections)) {
  $result.= '<option>'.$_.'</option>'."\n";   foreach (sort (@$sections)) {
       $result.= '<option>'.$_.'</option>'."\n";
    }
     }      }
     $result.='<option selected="on">all</select>'."<br />\n";      $result.='<option selected="on">all</select>'."<br />\n";
     $result.='&nbsp;<input type="submit" name="submit" value="View/Grade" /></form>'."\n";      $result.='&nbsp;<input type="button" onClick="submit();" value="Grade" /></form>'."\n";
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
     return $result;      return $result;
Line 2140  sub view_edit_entire_class_form { Line 2158  sub view_edit_entire_class_form {
 sub upcsvScores_form {  sub upcsvScores_form {
     my ($symb,$url) = @_;      my ($symb,$url) = @_;
     if (!$symb) {return '';}      if (!$symb) {return '';}
     my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";      my $result = '<script type="text/javascript" language="javascript">'."\n".
    '  function checkUpload(formname) {'."\n".
    '    if (formname.upfile.value == "") {'."\n".
    '       alert("Please use the browse button to select a file from your local directory.");'."\n".
    '       return false;'."\n".
    '    }'."\n".
    '    formname.submit();'."\n".
    '  }'."\n".
    '</script>'."\n";
   
       $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
     $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";      $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
     $result.='&nbsp;<b>Specify a file containing the class scores for above resource</b></td></tr>'."\n";      $result.='&nbsp;<b>Specify a file containing the class scores for above resource</b></td></tr>'."\n";
     $result.='<tr bgcolor=#ffffe6><td>'."\n";      $result.='<tr bgcolor=#ffffe6><td>'."\n";
Line 2151  sub upcsvScores_form { Line 2179  sub upcsvScores_form {
 <input type="hidden" name="url" value="$url" />  <input type="hidden" name="url" value="$url" />
 <input type="hidden" name="command" value="csvuploadmap" />  <input type="hidden" name="command" value="csvuploadmap" />
 $upfile_select  $upfile_select
 <br />&nbsp;<input type="submit" name="submit" value="Upload Grades" />  <br />&nbsp;<input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Grades" />
 </form>  </form>
 ENDUPFORM  ENDUPFORM
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
Line 2165  sub viewGradeaStu_form { Line 2193  sub viewGradeaStu_form {
     my ($classlist,$sections) = &getclasslist('all','0');      my ($classlist,$sections) = &getclasslist('all','0');
     my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";      my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
     $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";      $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
     $result.='&nbsp;<b>View/Grade an Individual Student\'s Submission</b></td></tr>'."\n";      $result.='&nbsp;<b>';
       if ($handgrade eq 'yes') {
    $result.="View/Grade ";
       } else {
    $result.="View ";
       }
       $result.='an Individual Student\'s Submission</b></td></tr>'."\n";
     $result.='<tr bgcolor=#ffffe6><td>'."\n";      $result.='<tr bgcolor=#ffffe6><td>'."\n";
     $result.='<form action="/adm/grades" method="post">'."\n".      $result.='<form action="/adm/grades" method="post">'."\n".
  '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".   '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
Line 2176  sub viewGradeaStu_form { Line 2210  sub viewGradeaStu_form {
  '<input type="hidden" name="command" value="submission" />'."\n";   '<input type="hidden" name="command" value="submission" />'."\n";
   
     $result.='&nbsp;<b>Select section:</b> <select name="section">'."\n";      $result.='&nbsp;<b>Select section:</b> <select name="section">'."\n";
     foreach (sort (@$sections)) {      if (ref($sections)) {
  $result.= '<option>'.$_.'</option>'."\n";   foreach (sort (@$sections)) {$result.='<option>'.$_.'</option>'."\n";}
     }      }
     $result.= '<option selected="on">all</select>'."\n";      $result.= '<option selected="on">all</select>'."\n";
     $result.='&nbsp;&nbsp;<b>Display students who has: </b>'.      $result.='&nbsp;&nbsp;<b>Display students who has: </b>'.
  '<input type="radio" name="submitonly" value="yes" checked> submitted'.   '<input type="radio" name="submitonly" value="yes" checked> submitted'.
  '<input type="radio" name="submitonly" value="all"> everybody <br />';   '<input type="radio" name="submitonly" value="all"> everybody <br />';
     $result.='&nbsp;(Section "no" implies the students were not assigned a section.)<br />'       if (ref($sections)) {
  if (grep /no/,@$sections);   $result.='&nbsp;(Section "no" implies the students were not assigned a section.)<br />' 
           if (grep /no/,@$sections);
     $result.='<br />&nbsp;<input type="submit" name="submit" value="View/Grade" />'."\n".      }
  '</form>'."\n";  
   
       $result.='<br />&nbsp;<input type="button" onClick="submit();" value="';
       if ($handgrade eq 'yes') {
    $result.="View/Grade";
       } else {
    $result.="View";
       }
       $result.='" />'."\n".'</form>'."\n";
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
     return $result;      return $result;
Line 2196  sub viewGradeaStu_form { Line 2238  sub viewGradeaStu_form {
 #--- Form to input a receipt number ---  #--- Form to input a receipt number ---
 sub verifyReceipt_form {  sub verifyReceipt_form {
     my ($symb,$url) = @_;      my ($symb,$url) = @_;
     my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};      my $result = '<script type="text/javascript" language="javascript">'."\n".
     my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};   '  function checkEntry(formname) {'."\n".
    '    var receipt = formname.receipt.value;'."\n".
    '    if (isNaN(receipt) || receipt == "") {'."\n".
    '       alert("Please enter a receipt number given by a student in the box.");'."\n".
    '       return false;'."\n".
    '    }'."\n".
    '    formname.submit();'."\n".
    '  }'."\n".
    '</script>'."\n";
   
     my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});      my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
   
     my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";      $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
     $result.='<table width=100% border=0><tr><td bgcolor=#e6ffff>'."\n";      $result.='<table width=100% border=0><tr><td bgcolor=#e6ffff>'."\n";
     $result.='&nbsp;<b>Verify a Submission Receipt Issued by this Server</td></tr>'."\n";      $result.='&nbsp;<b>Verify a Submission Receipt Issued by this Server</td></tr>'."\n";
     $result.='<tr bgcolor=#ffffe6><td>'."\n";      $result.='<tr bgcolor=#ffffe6><td>'."\n";
     $result.='<form action="/adm/grades" method="post">'."\n";      $result.='<form action="/adm/grades" method="post" name="verifyform">'."\n";
     $result.='&nbsp;<tt>'.$hostver.'-<input type="text" name="receipt" size="4"></tt><br />'."\n";      $result.='&nbsp;<tt>'.$hostver.'-<input type="text" name="receipt" size="4"></tt><br />'."\n";
     $result.='&nbsp;<input type="submit" name="submit" value="Verify Receipt">'."\n";      $result.='&nbsp;<input type="button" onClick="javascript:checkEntry(this.form);"'.
    ' value="Verify Receipt">'."\n";
     $result.='<input type="hidden" name="command" value="verify">'."\n";      $result.='<input type="hidden" name="command" value="verify">'."\n";
     if ($ENV{'form.url'}) {      if ($ENV{'form.url'}) {
  $result.='<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />';   $result.='<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />';
Line 2268  sub handler { Line 2320  sub handler {
     }      }
  }   }
     } else {      } else {
  #&Apache::lonhomework::showhashsubset(\%ENV,'^form');  
  $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});   $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
  if ($command eq 'submission') {   if ($command eq 'submission') {
     &listStudents($request) if ($ENV{'form.student'} eq '');      &listStudents($request) if ($ENV{'form.student'} eq '');
Line 2318  sub send_header { Line 2369  sub send_header {
 #remotewindow=open('','homeworkremote');  #remotewindow=open('','homeworkremote');
 #remotewindow.close();  #remotewindow.close();
 #</script>");   #</script>"); 
     $request->print('<body bgcolor="#FFFFFF">');      $request->print(&Apache::loncommon::bodytag('Grading'));
 }  }
   
 sub send_footer {  sub send_footer {

Removed from v.1.45  
changed lines
  Added in v.1.52


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