Diff for /loncom/homework/grades.pm between versions 1.44 and 1.46

version 1.44, 2002/08/02 21:10:03 version 1.46, 2002/08/06 20:46:30
Line 103  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 224  sub student_gradeStatus { Line 213  sub student_gradeStatus {
     return %partstatus;      return %partstatus;
 }  }
   
   # hidden form and javascript that calls the form
   # Use by verifyscript and viewgrades
   # Shows a student's view of problem and submission
   sub jscriptNform {
       my ($url,$symb) = @_;
       my $jscript='<script type="text/javascript" language="javascript">'."\n".
    '    function viewOneStudent(user,domain) {'."\n".
    ' document.onestudent.student.value = user;'."\n".
    ' document.onestudent.userdom.value = domain;'."\n".
    ' document.onestudent.submit();'."\n".
    '    }'."\n".
    '</script>'."\n";
       $jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n".
    '<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".
    '<input type="hidden" name="url"     value="'.$url.'" />'."\n".
    '<input type="hidden" name="command" value="submission" />'."\n".
    '<input type="hidden" name="student" value="" />'."\n".
    '<input type="hidden" name="userdom" value="" />'."\n".
    '</form>'."\n";
       return $jscript;
   }
   
 #------------------ End of general use routines --------------------  #------------------ End of general use routines --------------------
 #-------------------------------------------------------------------  #-------------------------------------------------------------------
   
 #------------------------------------ Receipt Verification Routines  #------------------------------------ Receipt Verification Routines
   #
 #--- Check whether a receipt number is valid.---  #--- Check whether a receipt number is valid.---
 sub verifyreceipt {  sub verifyreceipt {
     my $request  = shift;      my $request  = shift;
Line 243  sub verifyreceipt { Line 254  sub verifyreceipt {
  $symb    = &Apache::lonnet::symbread($url);   $symb    = &Apache::lonnet::symbread($url);
     }      }
   
     my $jscript='<script type="text/javascript" language="javascript">'."\n".      my $title.='<h3><font color="#339933">Verifying Submission Receipt '.
  '    function viewOneStudent(user,domain) {'."\n".   $receipt.'</h3></font>'."\n".
  ' document.onestudent.student.value = user;'."\n".  
  ' document.onestudent.userdom.value = domain;'."\n".  
  ' document.onestudent.submit();'."\n".  
  '    }'."\n".  
  '</script>'."\n";  
     $jscript.= '<form action="/adm/grades" method="post" name="onestudent">'."\n".  
  '<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".  
  '<input type="hidden" name="url"     value="'.$url.'" />'."\n".  
  '<input type="hidden" name="command" value="submission" />'."\n".  
  '<input type="hidden" name="student" value="" />'."\n".  
  '<input type="hidden" name="userdom" value="" />'."\n".  
  '</form>'."\n";  
   
     my $title.='<h2><font color="#339933">Verifying Submission Receipt '.  
  $receipt.'</h2></font>'."\n".  
  '<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br><br>'."\n";   '<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br><br>'."\n";
   
     my ($string,$contents,$matches) = ('','',0);      my ($string,$contents,$matches) = ('','',0);
Line 281  sub verifyreceipt { Line 277  sub verifyreceipt {
     if ($matches == 0) {      if ($matches == 0) {
  $string = $title.'No match found for the above receipt.';   $string = $title.'No match found for the above receipt.';
     } else {      } else {
  $string = $jscript.$title.   $string = &jscriptNform($url,$symb).$title.
     'The above receipt matches the following student'.      'The above receipt matches the following student'.
     ($matches <= 1 ? '.' : 's.')."\n".      ($matches <= 1 ? '.' : 's.')."\n".
     '<table border="0"><tr><td bgcolor="#777777">'."\n".      '<table border="0"><tr><td bgcolor="#777777">'."\n".
Line 301  sub verifyreceipt { Line 297  sub verifyreceipt {
 #    on the problem page.  #    on the problem page.
 sub listStudents {  sub listStudents {
     my ($request) = shift;      my ($request) = shift;
       $request->print(<<LISTJAVASCRIPT);
   <script type="text/javascript" language="javascript">
     function checkSelect(checkBox) {
       var ctr=0;
       var sense="";
       if (checkBox.length > 1) {
          for (var i=0; i<checkBox.length; i++) {
     if (checkBox[i].checked) {
        ctr++;
     }
          }
          sense = "a student or group of students";
       } else {
          if (checkBox.checked) {
      ctr = 1;
          }
          sense = "the student";
       }
       if (ctr == 0) {
          alert("Please select "+sense+" before clicking on the View/Grade button.");
          return false;
       }
       document.gradesub.submit();
     }
   </script>
   LISTJAVASCRIPT
   
     my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};      my $cdom      = $ENV{"course.$ENV{'request.course.id'}.domain"};
     my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};      my $cnum      = $ENV{"course.$ENV{'request.course.id'}.num"};
     my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};      my $getsec    = $ENV{'form.section'} eq '' ? 'all' : $ENV{'form.section'};
     my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};      my $submitonly= $ENV{'form.submitonly'} eq '' ? 'all' : $ENV{'form.submitonly'};
   
     my $result='<h2><font color="#339933">&nbsp;'.      my $result='<h3><font color="#339933">&nbsp;'.
  'View Submissions for a Student or a Group of Students</font></h2>';   'View/Grade Submissions for a Student or a Group of Students</font></h3>';
     $result.='<table border="0">';      $result.='<table border="0">';
     $result.='<tr><td colspan=3><font size=+1>'.      $result.='<tr><td colspan=3><font size=+1>'.
  '<b>Resource: </b>'.$ENV{'form.url'}.'</font></td></tr>';   '<b>Resource: </b>'.$ENV{'form.url'}.'</font></td></tr>';
Line 322  sub listStudents { Line 345  sub listStudents {
     $result.='</table>';      $result.='</table>';
     $request->print($result);      $request->print($result);
   
     $request->print(<<ENDTABLEST);      my $checkhdgrade = $ENV{'form.handgrade'} eq 'yes' ? 'checked' : '';
 <form action="/adm/grades" method="post">      my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
 &nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" checked> no   
 <input type="radio" name="vProb" value="yes"> yes <br />  
 &nbsp;<b>Submissions: </b>  
 <input type="radio" name="lastSub" value="hdgrade" checked /> handgrade only  
 <input type="radio" name="lastSub" value="lastonly" /> last sub only  
 <input type="radio" name="lastSub" value="last" /> last sub & parts info  
 <input type="radio" name="lastSub" value="all" /> all details  
 <input type="hidden" name="section" value="$getsec" />  
 <input type="hidden" name="submitonly" value="$submitonly" />  
 <input type="hidden" name="response" value="$ENV{'form.response'}" />  
 <input type="hidden" name="handgrade" value="$ENV{'form.handgrade'}" /><br />  
 <input type="hidden" name="showgrading" value="$ENV{'form.showgrading'}" /><br />  
 <input type="submit" name="submit" value="View/Grade" />  
 ENDTABLEST  
     if ($ENV{'form.url'}) {  
  $request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'."\n");  
     }  
     if ($ENV{'form.symb'}) {  
  $request->print('<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n");  
     }  
     $request->print('<input type="hidden" name="command" value="processGroup" />'."\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".
    '<input type="radio" name="vProb" value="yes"> yes <br />'."\n".
    '&nbsp;<b>Submissions: </b>'."\n".
    '<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n".
    '<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="all" /> all details'."\n".
    '<input type="hidden" name="section"     value="'.$getsec.'" />'."\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="showgrading" value="'.$ENV{'form.showgrading'}.'" /><br />'."\n".
    '<input type="hidden" name="url"  value="'.$ENV{'form.url'}.'" />'."\n".
    '<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n".
    'To view/grade 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".
    ' on the check boxes for the group of students.<br />'."\n".
    '<input type="hidden" name="command" value="processGroup" />'."\n".
    '<input type="button" '."\n".
    'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".
    'value="View/Grade" />'."\n";
    
     my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');      my ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist($getsec,'0');
           
     $result='<table border="0"><tr><td bgcolor="#777777">'.      $gradeTable.='<table border="0"><tr><td bgcolor="#777777">'.
  '<table border="0"><tr bgcolor="#e6ffff">'.   '<table border="0"><tr bgcolor="#e6ffff">'.
  '<td><b>&nbsp;Select&nbsp;</b></td><td><b>&nbsp;Fullname&nbsp;</b></td>'.   '<td><b>&nbsp;Select&nbsp;</b></td><td><b>&nbsp;Fullname&nbsp;</b></td>'.
  '<td><b>&nbsp;Username&nbsp;</b></td><td><b>&nbsp;Domain&nbsp;</b></td>';   '<td><b>&nbsp;Username&nbsp;</b></td><td><b>&nbsp;Domain&nbsp;</b></td>';
     foreach (sort(@$partlist)) {      foreach (sort(@$partlist)) {
  $result.='<td><b>&nbsp;Part '.(split(/_/))[0].' Status&nbsp;</b></td>';   $gradeTable.='<td><b>&nbsp;Part '.(split(/_/))[0].' Status&nbsp;</b></td>';
     }      }
     $request->print($result.'</tr>'."\n");      $gradeTable.='</tr>'."\n";
   
       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($ENV{'form.url'},
Line 367  ENDTABLEST Line 393  ENDTABLEST
     my ($foo,$partid,$foo1) = split(/\./,$_);      my ($foo,$partid,$foo1) = split(/\./,$_);
     if ($status{'resource.'.$partid.'.submitted_by'} ne '') {      if ($status{'resource.'.$partid.'.submitted_by'} ne '') {
  $statusflg = '';   $statusflg = '';
  $request->print('<input type="hidden" name="'.   $gradeTable.='<input type="hidden" name="'.
  $student.':submitted_by" value="'.      $student.':submitted_by" value="'.
  $status{'resource.'.$partid.'.submitted_by'}.'" />');      $status{'resource.'.$partid.'.submitted_by'}.'" />';
     }      }
  }   }
  next if ($statusflg eq '' && $submitonly eq 'yes');   next if ($statusflg eq '' && $submitonly eq 'yes');
   
    $ctr++;
  if ( $Apache::grades::viewgrades eq 'F' ) {   if ( $Apache::grades::viewgrades eq 'F' ) {
     $result='<tr bgcolor="#ffffe6">'.      $gradeTable.='<tr bgcolor="#ffffe6">'.
  '<td align="center"><input type=checkbox name="stuinfo" value="'.   '<td align="center"><input type=checkbox name="stuinfo" value="'.
  $student.':'.$$fullname{$student}.'"></td>'."\n".   $student.':'.$$fullname{$student}.'"></td>'."\n".
  '<td>&nbsp;'.$$fullname{$student}.'&nbsp;</td>'."\n".   '<td>&nbsp;'.$$fullname{$student}.'&nbsp;</td>'."\n".
Line 384  ENDTABLEST Line 411  ENDTABLEST
           
     foreach (sort keys(%status)) {      foreach (sort keys(%status)) {
  next if (/^resource.*?submitted_by$/);   next if (/^resource.*?submitted_by$/);
  $result.='<td align="middle">&nbsp;'.$status{$_}.'&nbsp;</td>'."\n";   $gradeTable.='<td align="middle">&nbsp;'.$status{$_}.'&nbsp;</td>'."\n";
     }      }
     $request->print($result.'</tr>'."\n");      $gradeTable.='</tr>'."\n";
  }   }
     }      }
     $request->print('</table></td></tr></table>');      $gradeTable.='</table></td></tr></table>'.
     $request->print('<input type="submit" name="submit" value="View/Grade" /><form />');   '<input type="button" '.
    'onClick="javascript:checkSelect(this.form.stuinfo);" '.
    'value="View/Grade" /><form />'."\n";
       if ($ctr == 0) {
    $gradeTable='<br />&nbsp;<font color="red">'.
       '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/;
       }
       $request->print($gradeTable);
     return '';      return '';
 }  }
   
Line 402  sub processGroup { Line 439  sub processGroup {
     my @stuchecked = (ref($ENV{'form.stuinfo'}) ? @{$ENV{'form.stuinfo'}}      my @stuchecked = (ref($ENV{'form.stuinfo'}) ? @{$ENV{'form.stuinfo'}}
       : ($ENV{'form.stuinfo'}));        : ($ENV{'form.stuinfo'}));
     my $total      = scalar(@stuchecked)-1;      my $total      = scalar(@stuchecked)-1;
     if ($stuchecked[0] eq '') {  
  &userError($request,'No student was selected for viewing/grading.');  
  return;  
     }  
     foreach (@stuchecked) {      foreach (@stuchecked) {
  my ($uname,$udom,$fullname) = split(/:/);   my ($uname,$udom,$fullname) = split(/:/);
  $ENV{'form.student'}        = $uname;   $ENV{'form.student'}        = $uname;
Line 489  sub sub_page_js { Line 523  sub sub_page_js {
     return;      return;
   }    }
   
   //=================== Check that a point is assigned for all the parts  ==============
     function checksubmit(val,total,parttot) {
        document.SCORE.gradeOpt.value = val;
        if (val == "Save & Next") {
    for (i=0;i<=total;i++) {
      for (j=0;j<parttot;j++) {
         var partid = eval("document.SCORE.partid"+i+"_"+j+".value");
         var selopt = eval("document.SCORE.GD_SEL"+i+"_"+partid);
         if (selopt[0].selected) {
    var points = eval("document.SCORE.GD_BOX"+i+"_"+partid+".value");
    if (points == "") {
        var name = eval("document.SCORE.name"+i+".value");
        alert("Please assign a score for "+name+", part "+partid+".");
        return false;
    }
         }
   
     }
          }
   
        }
        document.SCORE.submit();
    }
   
 //===================== Show list of keywords ====================  //===================== Show list of keywords ====================
   function keywords(keyform) {    function keywords(keyform) {
     var keywds = keyform.value;      var keywds = keyform.value;
Line 519  sub sub_page_js { Line 577  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 766  sub submission { Line 824  sub submission {
     # header info      # header info
     if ($counter == 0) {      if ($counter == 0) {
  &sub_page_js($request);   &sub_page_js($request);
  $request->print('<h2>&nbsp;<font color="#339933">Submission Record</font></h2>'.   $request->print('<h3>&nbsp;<font color="#339933">Submission Record</font></h3>'."\n".
  '<font size=+1>&nbsp;<b>Resource: </b>'.$url.'</font>');   '<font size=+1>&nbsp;<b>Resource: </b>'.$url.'</font>'."\n");
   
  # option to display problem, only once else it cause problems    # option to display problem, only once else it cause problems 
         # with the form later since the problem has a form.          # with the form later since the problem has a form.
Line 778  sub submission { Line 836  sub submission {
    $ENV{'request.course.id'});     $ENV{'request.course.id'});
     my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">';      my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">';
     $result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">';      $result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">';
     $result.='<b> View of the problem for '.$ENV{'form.fullname'}.      $result.='<b> View of the problem - '.$ENV{'form.fullname'}.
  '</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />';   '</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />';
     $result.='<b>Correct answer:</b><br />'.$companswer;      $result.='<b>Correct answer:</b><br />'.$companswer;
     $result.='</td></tr></table>';      $result.='</td></tr></table>';
Line 851  KEYWORDS Line 909  KEYWORDS
   
     # Display student info      # Display student info
     $request->print(($counter == 0 ? '' : '<br />'));      $request->print(($counter == 0 ? '' : '<br />'));
     my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'.      my $result='<table border="0" width=100%><tr><td bgcolor="#777777">'."\n".
  '<table border="0" width=100%><tr bgcolor="#edffff"><td>';   '<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 />';   '<font color="#999999">&nbsp; &nbsp;Domain: '.$udom.'</font><br />'."\n";
       $result.='<input type="hidden" name="name'.$counter.
    '" value="'.$ENV{'form.fullname'}.'" />'."\n";
   
     # If this is handgraded, then check for collaborators      # If this is handgraded, then check for collaborators
     my $col_flag = 0;      my @col_fullnames;
     if ($ENV{'form.handgrade'} eq 'yes') {      if ($ENV{'form.handgrade'} eq 'yes') {
  my @col_list;   my @col_list;
  ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');   ($classlist,$seclist,$ids,$stusec,$fullname) = &getclasslist('all','0');
Line 883  KEYWORDS Line 942  KEYWORDS
  push @badcollaborators,$collaborator;   push @badcollaborators,$collaborator;
  next;   next;
     }      }
     $col_flag++;  
     push @col_list, $collaborator;      push @col_list, $collaborator;
       my ($lastname,$givenn) = split(/,/,$$fullname{$collaborator.':'.$udom});
       push @col_fullnames, $givenn.' '.$lastname;
     $result.=$$fullname{$collaborator.':'.$udom}.'&nbsp; &nbsp; &nbsp;';      $result.=$$fullname{$collaborator.':'.$udom}.'&nbsp; &nbsp; &nbsp;';
  }   }
  $result.='<br />'."\n";   $result.='<br />'."\n";
Line 924  KEYWORDS Line 984  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).'';
     if ($$timestamp eq '') {      if ($$timestamp eq '') {
  $lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0].'</td></tr>';   $lastsubonly.='<tr><td bgcolor="#ffffe6">'.$$string[0].'</td></tr>'."\n";
     } else {      } else {
  for my $part (sort keys(%$handgrade)) {   for my $part (sort keys(%$handgrade)) {
     foreach (@$string) {      foreach (@$string) {
Line 939  KEYWORDS Line 999  KEYWORDS
     $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;<b>Answer: </b>'.   ' )</font>&nbsp; &nbsp;<b>Answer: </b>'.
  &keywords_highlight($subval).'</td></tr>'   &keywords_highlight($subval).'</td></tr>'."\n"
  if ($ENV{'form.lastSub'} eq 'lastonly' ||    if ($ENV{'form.lastSub'} eq 'lastonly' || 
     ($ENV{'form.lastSub'} eq 'hdgrade' &&       ($ENV{'form.lastSub'} eq 'hdgrade' && 
      $$handgrade{$part} =~ /:yes$/));       $$handgrade{$part} =~ /:yes$/));
Line 947  KEYWORDS Line 1007  KEYWORDS
     }      }
  }   }
     }      }
     $lastsubonly.='</td></tr><tr><td bgcolor="#ffffff">'."\n";      $lastsubonly.='</td></tr>'."\n";
     $request->print($lastsubonly);      $request->print($lastsubonly);
  }   }
     } else {      } else {
Line 959  KEYWORDS Line 1019  KEYWORDS
           
     # return if view submission with no grading option      # return if view submission with no grading option
     if ($ENV{'form.showgrading'} eq '') {      if ($ENV{'form.showgrading'} eq '') {
  $request->print('</td></tr></table></td></tr></table></form>');   $request->print('</td></tr></table></td></tr></table></form>'."\n");
  return;   return;
     }      }
   
     # Grading options      # Grading options
     $result='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n".      $result='<input type="hidden" name="newmsg'.$counter.'" value="" />'."\n".
  '<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".   '<input type="hidden" name="includemsg'.$counter.'" value="" />'."\n".
  '<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'.$udom.'" />'."\n";   '<input type="hidden" name="unamedom'.$counter.'" value="'.$uname.':'
     $result.='&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.   .$udom.'" />'."\n";
  ',\''.$ENV{'form.fullname'}.'\')"; TARGET=_self>'.      my ($lastname,$givenn) = split(/,/,$ENV{'form.fullname'});
  'Compose Message to student'.($col_flag > 1 ? 's' : '').'</a>'.      my $msgfor = $givenn.' '.$lastname;
       if (scalar(@col_fullnames) > 0) {
    my $lastone = pop @col_fullnames;
    $msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
       }
       $result.='<tr><td bgcolor="#ffffff">'."\n".
    '&nbsp;<a href="javascript:msgCenter(document.SCORE,'.$counter.
    ',\''.$msgfor.'\')"; TARGET=_self>'.
    'Compose Message to student'.(scalar(@col_fullnames) >= 1 ? 's' : '').'</a>'.
  '<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);
Line 1022  KEYWORDS Line 1090  KEYWORDS
     '<option selected="on"> </option>'.      '<option selected="on"> </option>'.
     '<option>excused</option></select>'."&nbsp&nbsp\n";      '<option>excused</option></select>'."&nbsp&nbsp\n";
  $result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="0" />';   $result.='<input type="hidden" name="stores'.$counter.'_'.$partid.'" value="0" />';
  $result.='</td></tr></table>';   $result.='</td></tr></table>'."\n";
  $request->print($result);   $request->print($result);
     }      }
     $request->print('<input type="hidden" name="partlist'.$counter.'" value="'.(join ":",@partlist).'" />'."\n");      $result='<input type="hidden" name="partlist'.$counter.
     $request->print('</td></tr></table></td></tr></table>'."\n");   '" value="'.(join ":",@partlist).'" />'."\n";
       my $ctr = 0;
       while ($ctr < scalar(@partlist)) {
    $result.='<input type="hidden" name="partid'.$counter.'_'.$ctr.'" value="'.
       $partlist[$ctr].'" />'."\n";
    $ctr++;
       }
       $request->print($result.'</td></tr></table></td></tr></table>'."\n");
   
     # print end of form      # print end of form
     if ($counter == $total) {      if ($counter == $total) {
  my $endform.='<table border="0"><tr><td><input type="submit" name="gradeOpt" value="Save & Next" />';   my $endform='<table border="0"><tr><td>'.
  my $ntstu ='<select name="NTSTU">'.      '<input type="hidden" name="gradeOpt" value="" />'."\n";
     '<option>1</option><option>2</option>'.   if ($ENV{'form.handgrade'} eq 'yes') {
     '<option>3</option><option>5</option>'.      $endform.='<input type="button" value="Save & Next" '.
     '<option>7</option><option>10</option></select>'."\n";   'onClick="javascript:checksubmit(\'Save & Next\','.
  my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');   $total.','.scalar(@partlist).');" TARGET=_self> &nbsp;'."\n";
  $ntstu =~ s/<option>$nsel</<option selected="on">$nsel</;      my $ntstu ='<select name="NTSTU">'.
  $endform.=$ntstu.'student(s) &nbsp;&nbsp;'.   '<option>1</option><option>2</option>'.
     '<input type="submit" name="gradeOpt" value="Next" />&nbsp'.   '<option>3</option><option>5</option>'.
     '<input type="submit" name="gradeOpt" value="Previous" />&nbsp'.   '<option>7</option><option>10</option></select>'."\n";
     '(Next and Previous do not save the scores.)'.      my $nsel = ($ENV{'form.NTSTU'} ne '' ? $ENV{'form.NTSTU'} : '1');
     '</td><tr></table></form>';      $ntstu =~ s/<option>$nsel</<option selected="on">$nsel</;
       $endform.=$ntstu.'student(s) &nbsp;&nbsp;';
    } else {
       $endform.='<input type="hidden" name="NTSTU" value="1" />'."\n";
    }
    $endform.='<input type="button" value="Next" '.
       'onClick="javascript:checksubmit(\'Next\');" TARGET=_self> &nbsp;'."\n".
       '<input type="button" value="Previous" '.
       'onClick="javascript:checksubmit(\'Previous\');" TARGET=_self> &nbsp;';
    $endform.='(Next and Previous do not save the scores.)'."\n" 
       if ($ENV{'form.handgrade'} eq 'yes');
    $endform.='</td><tr></table></form>';
  $request->print($endform);   $request->print($endform);
     }      }
     return '';      return '';
Line 1049  KEYWORDS Line 1135  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 1102  sub processHandGrade { Line 1187  sub processHandGrade {
  my $ctr = 0;   my $ctr = 0;
  while ($ctr < $ngrade) {   while ($ctr < $ngrade) {
     my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});      my ($uname,$udom) = split(/:/,$ENV{'form.unamedom'.$ctr});
     my ($errorflg) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);      my ($errorflag) = &saveHandGrade($request,$url,$symb,$uname,$udom,$ctr);
     return '' if ($errorflg eq 'error');  
   
     my $includemsg = $ENV{'form.includemsg'.$ctr};      my $includemsg = $ENV{'form.includemsg'.$ctr};
     my ($subject,$message,$msgstatus) = ('','','');      my ($subject,$message,$msgstatus) = ('','','');
Line 1263  sub saveHandGrade { Line 1347  sub saveHandGrade {
     my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?       my $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? 
        $ENV{'form.GD_BOX'.$newflg.'_'.$_} :          $ENV{'form.GD_BOX'.$newflg.'_'.$_} : 
        $ENV{'form.RADVAL'.$newflg.'_'.$_});         $ENV{'form.RADVAL'.$newflg.'_'.$_});
     if ($pts eq '') {  
  &userError($request,'No point was assigned for part '.$_.  
    ' and for username '.$stuname.'.');  
  return 'error';  
     }  
     my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 :       my $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : 
  $ENV{'form.WGT'.$newflg.'_'.$_};   $ENV{'form.WGT'.$newflg.'_'.$_};
     my $partial= $pts/$wgt;      my $partial= $pts/$wgt;
Line 1304  sub viewgrades_js { Line 1383  sub viewgrades_js {
   
     $request->print(<<VIEWJAVASCRIPT);      $request->print(<<VIEWJAVASCRIPT);
 <script type="text/javascript" language="javascript">  <script type="text/javascript" language="javascript">
     function viewOneStudent(user,domain) {     function writePoint(partid,weight,point) {
  document.onestudent.student.value = user;  
  document.onestudent.userdom.value = domain;  
  document.onestudent.submit();  
     }  
   
     function writePoint(partid,weight,point) {  
  var radioButton = eval("document.classgrade.RADVAL_"+partid);   var radioButton = eval("document.classgrade.RADVAL_"+partid);
  var textbox = eval("document.classgrade.TEXTVAL_"+partid);   var textbox = eval("document.classgrade.TEXTVAL_"+partid);
  if (point == "textval") {   if (point == "textval") {
Line 1480  sub viewgrades { Line 1553  sub viewgrades {
     &viewgrades_js($request);      &viewgrades_js($request);
   
     my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'});       my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'}); 
     my $result='<h2><font color="#339933">Manual Grading</font></h2>';      my $result='<h3><font color="#339933">Manual Grading</font></h3>';
   
     $result.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font>'."\n";      $result.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font>'."\n";
   
     #view individual student submission form - called using Javascript viewOneStudent      #view individual student submission form - called using Javascript viewOneStudent
     $result.= '<form action="/adm/grades" method="post" name="onestudent">'."\n".      $result.=&jscriptNform($url,$symb);
  '<input type="hidden" name="symb"    value="'.$symb.'" />'."\n".  
  '<input type="hidden" name="url"     value="'.$url.'" />'."\n".  
  '<input type="hidden" name="command" value="submission" />'."\n".  
  '<input type="hidden" name="student" value="" />'."\n".  
  '<input type="hidden" name="userdom" value="" />'."\n".  
  '</form>'."\n";  
   
     #beginning of class grading form      #beginning of class grading form
     $result.= '<form action="/adm/grades" method="post" name="classgrade">'."\n".      $result.= '<form action="/adm/grades" method="post" name="classgrade">'."\n".
Line 1499  sub viewgrades { Line 1566  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.='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 '.   '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 '.   'each student in the table below. <font color="red">A part that has already '.
Line 1512  sub viewgrades { Line 1578  sub viewgrades {
     my %weight = ();      my %weight = ();
     my $ctsparts = 0;      my $ctsparts = 0;
     $result.='<table border="0">';      $result.='<table border="0">';
       my %seen = ();
     for (sort keys(%$handgrade)) {      for (sort keys(%$handgrade)) {
  my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});  
  my ($partid,$respid) = split (/_/);   my ($partid,$respid) = split (/_/);
    next if $seen{$partid};
    $seen{$partid}++;
    my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
  my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb);   my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb);
  $weight{$partid} = $wgt eq '' ? '1' : $wgt;   $weight{$partid} = $wgt eq '' ? '1' : $wgt;
   
Line 1547  sub viewgrades { Line 1616  sub viewgrades {
     $result.='</table><input type="hidden" name="totalparts" value="'.$ctsparts.'" />';      $result.='</table><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" '.
 # 'onClick="submit();" TARGET=_self />'."\n";   'onClick="javascript:submit();" TARGET=_self />'."\n";
     $result.= '<input type="submit" name="submit"  value="Submit Changes" />'."\n";  
   
     #table listing all the students in a section/class      #table listing all the students in a section/class
     #header of table      #header of table
Line 1586  sub viewgrades { Line 1654  sub viewgrades {
     }      }
     $result.='</table></td></tr></table>';      $result.='</table></td></tr></table>';
     $result.='<input type="hidden" name="total" value="'.$ctr.'" />'."\n";      $result.='<input type="hidden" name="total" value="'.$ctr.'" />'."\n";
     $result.='<input type="submit" name="submit" value="Submit Changes" /></form>';      $result.='<input type="button" value="Submit Changes" '.
    'onClick="javascript:submit();" TARGET=_self /></form>'."\n";
     $result.=&show_grading_menu_form($symb,$url);      $result.=&show_grading_menu_form($symb,$url);
     return $result;      return $result;
 }  }
Line 1638  sub editgrades { Line 1707  sub editgrades {
   
     my $symb=$ENV{'form.symb'};      my $symb=$ENV{'form.symb'};
     my $url =$ENV{'form.url'};      my $url =$ENV{'form.url'};
     my $title='<h2><font color="#339933">Current Grade Status</font></h2>';      my $title='<h3><font color="#339933">Current Grade Status</font></h3>';
     $title.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br />'."\n";      $title.='<font size=+1><b>Resource: </b>'.$ENV{'form.url'}.'</font><br />'."\n";
     $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n";      $title.='<font size=+1><b>Section: </b>'.$ENV{'form.section'}.'</font>'."\n";
     $title.= &show_grading_menu_form ($symb,$url);      $title.= &show_grading_menu_form ($symb,$url);
Line 1810  ENDPICK Line 1879  ENDPICK
   
 sub csvuploadmap_header {  sub csvuploadmap_header {
     my ($request,$symb,$url,$datatoken,$distotal)= @_;      my ($request,$symb,$url,$datatoken,$distotal)= @_;
     my $result;  
     my $javascript;      my $javascript;
     if ($ENV{'form.upfile_associate'} eq 'reverse') {      if ($ENV{'form.upfile_associate'} eq 'reverse') {
  $javascript=&csvupload_javascript_reverse_associate();   $javascript=&csvupload_javascript_reverse_associate();
     } else {      } else {
  $javascript=&csvupload_javascript_forward_associate();   $javascript=&csvupload_javascript_forward_associate();
     }      }
   
       my $result='<table border="0">';
       $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
       my ($partlist,$handgrade) = &response_type($url);
       my ($resptype,$hdgrade)=('','no');
       for (sort keys(%$handgrade)) {
    my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_});
    $resptype = $responsetype;
    $hdgrade = $handgrade 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(<<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">
 <h3>Uploading Class Grades for resource $url</h3>  <h3><font color="#339933">Uploading Class Grades</font></h3>
   $result
 <hr>  <hr>
 <h3>Identify fields</h3>  <h3>Identify fields</h3>
 Total number of records found in file: $distotal <hr />  Total number of records found in file: $distotal <hr />
Line 1887  sub csvuploadmap { Line 1970  sub csvuploadmap {
     my ($i,$keyfields);      my ($i,$keyfields);
     if (@records) {      if (@records) {
  my @fields=&csvupload_fields($url);   my @fields=&csvupload_fields($url);
   
  if ($ENV{'form.upfile_associate'} eq 'reverse') {   if ($ENV{'form.upfile_associate'} eq 'reverse') {
     &Apache::loncommon::csv_print_samples($request,\@records);      &Apache::loncommon::csv_print_samples($request,\@records);
     $i=&Apache::loncommon::csv_print_select_table($request,\@records,      $i=&Apache::loncommon::csv_print_select_table($request,\@records,
Line 1926  sub csvuploadassign { Line 2010  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 1987  sub gradingmenu { Line 2069  sub gradingmenu {
     my ($request) = @_;      my ($request) = @_;
     my ($symb,$url)=&get_symb_and_url($request);      my ($symb,$url)=&get_symb_and_url($request);
     if (!$symb) {return '';}      if (!$symb) {return '';}
     my $result='<h2>&nbsp;<font color="#339933">Select a Grading Method</font></h2>';      my $result='<h3>&nbsp;<font color="#339933">Select a Grading Method</font></h3>';
     $result.='<table border="0">';      $result.='<table border="0">';
     $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';      $result.='<tr><td colspan=3><font size=+1><b>Resource: </b>'.$url.'</font></td></tr>';
     my ($partlist,$handgrade) = &response_type($url);      my ($partlist,$handgrade) = &response_type($url);
Line 2027  sub view_edit_entire_class_form { Line 2109  sub view_edit_entire_class_form {
  $result.= '<option>'.$_.'</option>'."\n";   $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="View/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 2037  sub view_edit_entire_class_form { Line 2119  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 2048  sub upcsvScores_form { Line 2140  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 2082  sub viewGradeaStu_form { Line 2174  sub viewGradeaStu_form {
  '<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 />'       $result.='&nbsp;(Section "no" implies the students were not assigned a section.)<br />' 
  if (grep /no/,@$sections);   if (grep /no/,@$sections);
          
     $result.='<br />&nbsp;<input type="submit" name="submit" value="View/Grade" />'."\n".      $result.='<br />&nbsp;<input type="button" onClick="submit();" value="View/Grade" />'."\n".
  '</form>'."\n";   '</form>'."\n";
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
     $result.='</td></tr></table>'."\n";      $result.='</td></tr></table>'."\n";
Line 2093  sub viewGradeaStu_form { Line 2185  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 2155  sub handler { Line 2257  sub handler {
       'grade_courseid' => $tcrsid,        'grade_courseid' => $tcrsid,
       'grade_symb' => $tsymb)));        'grade_symb' => $tsymb)));
     } else {      } else {
  $request->print('<h2>Not authorized: '.$token.'</h2>');   $request->print('<h3>Not authorized: '.$token.'</h3>');
     }                 }           
  } else {   } else {
     $request->print('<h2>Not a valid DocID: '.$token.'</h2>');      $request->print('<h3>Not a valid DocID: '.$token.'</h3>');
  }   }
     } else {      } else {
  $request->print(&Apache::lonxml::tokeninputfield());   $request->print(&Apache::lonxml::tokeninputfield());
     }      }
  }   }
     } 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 '');

Removed from v.1.44  
changed lines
  Added in v.1.46


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