Diff for /loncom/homework/grades.pm between versions 1.57 and 1.69

version 1.57, 2002/10/17 14:35:34 version 1.69, 2003/02/27 22:39:11
Line 31 Line 31
 # 8/20 Gerd Kortemeyer  # 8/20 Gerd Kortemeyer
 # Year 2002  # Year 2002
 # June-August H.K. Ng  # June-August H.K. Ng
   # Year 2003
   # February H.K. Ng
 #  #
   
 package Apache::grades;  package Apache::grades;
Line 39  use Apache::style; Line 41  use Apache::style;
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon;  use Apache::loncommon;
   use Apache::lonnavmaps;
 use Apache::lonhomework;  use Apache::lonhomework;
 use Apache::loncoursedata;  use Apache::loncoursedata;
 use Apache::lonmsg qw(:user_normal_msg);  use Apache::lonmsg qw(:user_normal_msg);
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
   
 # ----- These first few routines are general use routines.-----  # ----- These first few routines are general use routines.----
 #  #
 # --- 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 {
Line 269  sub verifyreceipt { Line 272  sub verifyreceipt {
     return $string.&show_grading_menu_form($symb,$url);      return $string.&show_grading_menu_form($symb,$url);
 }  }
   
   #
   # Pick student and page/sequence for manual grading
   
   
 #--- This is called by a number of programs.  #--- This is called by a number of programs.
 #--- Called from the Grading Menu - View/Grade an individual student  #--- Called from the Grading Menu - View/Grade an individual student
 #--- Also called directly when one clicks on the subm button   #--- Also called directly when one clicks on the subm button 
Line 293  sub listStudents { Line 300  sub listStudents {
     }      }
     $result.='</table>';      $result.='</table>';
   
     my $viewgrade;      my $viewgrade = $ENV{'form.handgrade'} eq 'yes' ? 'View/Grade' : 'View';
     if ($ENV{'form.handgrade'} eq 'yes') {  
  $viewgrade = 'View/Grade';  
     } else {  
  $viewgrade = 'View';  
     }  
   
     $result='<h3><font color="#339933">&nbsp;'.      $result='<h3><font color="#339933">&nbsp;'.
  $viewgrade.   $viewgrade.
Line 339  LISTJAVASCRIPT Line 341  LISTJAVASCRIPT
     my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';      my $checklastsub = $ENV{'form.handgrade'} eq 'yes' ? '' : 'checked';
   
     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" > no '."\n".   '&nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" /> no '."\n".
  '<input type="radio" name="vProb" value="yes" checked > yes <br />'."\n".   '<input type="radio" name="vProb" value="yes" checked /> one student '."\n".
    '<input type="radio" name="vProb" value="all" /> all students <br />'."\n".
  '&nbsp;<b>Submissions: </b>'."\n";   '&nbsp;<b>Submissions: </b>'."\n";
     if ($ENV{'form.handgrade'} eq 'yes') {      if ($ENV{'form.handgrade'} eq 'yes') {
  $gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n";   $gradeTable.='<input type="radio" name="lastSub" value="hdgrade" '.$checkhdgrade.' /> handgrade only'."\n";
Line 671  sub sub_page_js { Line 674  sub sub_page_js {
     pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");      pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
     pWin.document.write("<td>Subject</td>");      pWin.document.write("<td>Subject</td>");
     pWin.document.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"></td>");      pWin.document.write("<td align=\\"center\\"><input name=\\"subchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
     pWin.document.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+" \\"size=\\"60\\" maxlength=\\"80\\"></td></tr>");      pWin.document.write("<td><input name=\\"msgsub\\" type=\\"text\\" value=\\""+msg+"\\"size=\\"60\\" maxlength=\\"80\\"></td></tr>");
 }  }
   
 function displaySavedMsg(ctr,msg,shwsel) {  function displaySavedMsg(ctr,msg,shwsel) {
     pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");      pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
     pWin.document.write("<td align=\\"center\\">"+ctr+"</td>");      pWin.document.write("<td align=\\"center\\">"+ctr+"</td>");
     pWin.document.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"></td>");      pWin.document.write("<td align=\\"center\\"><input name=\\"msgn"+ctr+"\\" type=\\"checkbox\\"" +shwsel+"></td>");
     pWin.document.write("<td><input name=\\"msg"+ctr+"\\" type=\\"text\\" value=\\""+msg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");      pWin.document.write("<td><input name=\\"msg"+ctr+"\\" type=\\"text\\" value=\\""+msg+"\\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");
 }  }
   
   function newMsg(newmsg,shwsel) {    function newMsg(newmsg,shwsel) {
     pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");      pWin.document.write("<tr bgcolor=\\"#ffffdd\\">");
     pWin.document.write("<td align=\\"center\\">New</td>");      pWin.document.write("<td align=\\"center\\">New</td>");
     pWin.document.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>");      pWin.document.write("<td align=\\"center\\"><input name=\\"newmsgchk\\" type=\\"checkbox\\"" +shwsel+"></td>");
     pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" value=\\""+newmsg+" \\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");      pWin.document.write("<td><input name=\\"newmsg\\" type=\\"text\\" onchange=\\"javascript:this.form.newmsgchk.checked=true\\" value=\\""+newmsg+"\\" size=\\"60\\" maxlength=\\"80\\"></td></tr>");
 }  }
   
   function msgTail() {    function msgTail() {
Line 795  SUBJAVASCRIPT Line 798  SUBJAVASCRIPT
 }  }
   
   
   sub show_problem {
       my ($request,$symb,$uname,$udom,$removeform) = @_;
       my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
         $ENV{'request.course.id'});
       if ($removeform) {
    $rendered=~s|<form(.*?)>||g;
    $rendered=~s|</form>||g;
    $rendered=~s|name="submit"|name="would_have_been_submit"|g;
       }
       my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
      $ENV{'request.course.id'});
       if ($removeform) {
    $companswer=~s|<form(.*?)>||g;
    $companswer=~s|</form>||g;
    $rendered=~s|name="submit"|name="would_have_been_submit"|g;
       }
       my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">';
       $result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">';
       $result.='<b> View of the problem - '.$ENV{'form.fullname'}.
    '</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />';
       $result.='<b>Correct answer:</b><br />'.$companswer;
       $result.='</td></tr></table>';
       $result.='</td></tr></table><br />';
       $request->print($result);
   }
   
 # --------------------------- show submissions of a student, option to grade   # --------------------------- show submissions of a student, option to grade 
 sub submission {  sub submission {
     my ($request,$counter,$total) = @_;      my ($request,$counter,$total) = @_;
Line 809  sub submission { Line 838  sub submission {
     my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));      my $symb=($ENV{'form.symb'} ne '' ? $ENV{'form.symb'} : (&Apache::lonnet::symbread($url)));
     if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }      if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
     my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');      my $last = ($ENV{'form.lastSub'} eq 'last' ? 'last' : '');
     $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';  #    $ENV{'form.vProb'} = $ENV{'form.vProb'} ne '' ? $ENV{'form.vProb'} : 'yes';
   
     # header info      # header info
     if ($counter == 0) {      if ($counter == 0) {
Line 819  sub submission { Line 848  sub submission {
   
  # 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.
  if ($ENV{'form.vProb'} eq 'yes') {   if ($ENV{'form.vProb'} eq 'yes' or !$ENV{'form.vProb'}) {
     my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,      &show_problem($request,$symb,$uname,$udom,0);
       $ENV{'request.course.id'});  
     my $companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,  
    $ENV{'request.course.id'});  
     my $result.='<table border="0" width="100%"><tr><td bgcolor="#777777">';  
     $result.='<table border="0" width="100%"><tr><td bgcolor="#e6ffff">';  
     $result.='<b> View of the problem - '.$ENV{'form.fullname'}.  
  '</b></td></tr><tr><td bgcolor="#ffffff">'.$rendered.'<br />';  
     $result.='<b>Correct answer:</b><br />'.$companswer;  
     $result.='</td></tr></table>';  
     $result.='</td></tr></table><br />';  
     $request->print($result);  
  }   }
   
  # kwclr is the only variable that is guaranteed to be non blank    # kwclr is the only variable that is guaranteed to be non blank 
Line 894  KEYWORDS Line 912  KEYWORDS
         }          }
     }      }
   
       if ($ENV{'form.vProb'} eq 'all') {
    $request->print('<br /><br /><br />');
    &show_problem($request,$symb,$uname,$udom,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 1000  KEYWORDS Line 1023  KEYWORDS
     my ($ressub,$subval) = split(/:/,$_,2);      my ($ressub,$subval) = split(/:/,$_,2);
     $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;'.
                                   ($record{"resource.$partid.$respid.uploadedurl"}?
                                   '<a href="'.
                                   &Apache::lonnet::tokenwrapper($record{"resource.$partid.$respid.uploadedurl"}).
      '"><img src="/adm/lonIcons/unknown.gif" border=0"> File uploaded by student</a> <font color="red" size="1">Like all files provided by users, this file may contain virusses</font><br />':'').
                                   '<b>Answer: </b>'.
  &keywords_highlight($subval).'</td></tr>'."\n"   &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' && 
Line 1088  KEYWORDS Line 1116  KEYWORDS
     'onChange="javascript:clearRadBox(this.form.RADVAL'.$counter.'_'.$partid.      'onChange="javascript:clearRadBox(this.form.RADVAL'.$counter.'_'.$partid.
     ',this.form.GD_BOX'.$counter.'_'.$partid.      ',this.form.GD_BOX'.$counter.'_'.$partid.
     ',this.form.GD_SEL'.$counter.'_'.$partid.      ',this.form.GD_SEL'.$counter.'_'.$partid.
     ',this.form.stores'.$counter.'_'.$partid.')" />'."\n".      ',this.form.stores'.$counter.'_'.$partid.')" >'."\n";
     '<option selected="on"> </option>'.   if ($record{'resource.'.$partid.'.solved'} eq 'excused') {
     '<option>excused</option></select>'."&nbsp&nbsp\n";      $result.='<option> </option>'.
    '<option selected="on">excused</option></select>';
    } else {
       $result.='<option selected="on"> </option>'.
    '<option>excused</option></select>';
    }
    $result.="&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>'."\n";   $result.='</td></tr></table>'."\n";
  $request->print($result);   $request->print($result);
Line 1146  sub get_last_submission { Line 1180  sub get_last_submission {
  for ($version=1;$version<=$returnhash{'version'};$version++) {   for ($version=1;$version<=$returnhash{'version'};$version++) {
     foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {      foreach (sort(split(/\:/,$returnhash{$version.':keys'}))) {
  $lasthash{$_}=$returnhash{$version.':'.$_};   $lasthash{$_}=$returnhash{$version.':'.$_};
  if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {  # if ($returnhash{$version.':'.$_} =~ /(SUBMITTED|DRAFT)$/) {
    $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));     $timestamp = scalar(localtime($returnhash{$version.':timestamp'}));
        }   #       } 
     }      }
  }   }
  foreach ((keys %lasthash)) {   foreach ((keys %lasthash)) {
Line 1172  sub keywords_highlight { Line 1206  sub keywords_highlight {
     (my $styleoff = $styleon) =~ s/\</\<\//;      (my $styleoff = $styleon) =~ s/\</\<\//;
     my @keylist   = split(/[,\s+]/,$ENV{'form.keywords'});      my @keylist   = split(/[,\s+]/,$ENV{'form.keywords'});
     foreach (@keylist) {      foreach (@keylist) {
  $string =~ s/\b$_(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi;   $string =~ s/\b\Q$_\E(\b|\.)/\<font color\=$ENV{'form.kwclr'} $size\>$styleon$_$styleoff\<\/font\>/gi;
     }      }
     # This is not really the right place to do this, but I cannot find a      # This is not really the right place to do this, but I cannot find a
     # better one at this time.  So here we go - the m in the s:::mg causes      # better one at this time.  So here we go - the m in the s:::mg causes
Line 1199  sub processHandGrade { Line 1233  sub processHandGrade {
   
     my $includemsg = $ENV{'form.includemsg'.$ctr};      my $includemsg = $ENV{'form.includemsg'.$ctr};
     my ($subject,$message,$msgstatus) = ('','','');      my ($subject,$message,$msgstatus) = ('','','');
     if ($includemsg =~ /savemsg|new$ctr/) {      if ($includemsg =~ /savemsg|newmsg\Q$ctr\E/) {
  $subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);   $subject = $ENV{'form.msgsub'} if ($includemsg =~ /^msgsub/);
  my (@msgnum) = split(/,/,$includemsg);   my (@msgnum) = split(/,/,$includemsg);
  foreach (@msgnum) {   foreach (@msgnum) {
Line 1349  sub saveHandGrade { Line 1383  sub saveHandGrade {
     my %newrecord;      my %newrecord;
     foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {      foreach (split(/:/,$ENV{'form.partlist'.$newflg})) {
  if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {   if ($ENV{'form.GD_SEL'.$newflg.'_'.$_} eq 'excused') {
     $newrecord{'resource.'.$_.'.solved'} = 'excused'       if ($record{'resource.'.$_.'.solved'} ne 'excused') {
  if ($record{'resource.'.$_.'.solved'} ne 'excused');   $newrecord{'resource.'.$_.'.solved'} = 'excused';
    if (exists($record{'resource.'.$_.'.awarded'})) {
       $newrecord{'resource.'.$_.'.awarded'} = '';
    }
       }
  } else {   } else {
     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.'_'.$_} : 
Line 1626  sub viewgrades { Line 1664  sub viewgrades {
     $weight{$partid}.' (problem weight)</td>'."\n";      $weight{$partid}.' (problem weight)</td>'."\n";
  $result.= '</td><td><select name="SELVAL_'.$partid.'"'.   $result.= '</td><td><select name="SELVAL_'.$partid.'"'.
     'onChange="javascript:writeRadText(\''.$partid.'\','.      'onChange="javascript:writeRadText(\''.$partid.'\','.
  $weight{$partid}.')" /> '.   $weight{$partid}.')"> '.
     '<option selected="on"> </option>'.      '<option selected="on"> </option>'.
     '<option>excused</option></select></td></tr>'."\n";      '<option>excused</option></select></td></tr>'."\n";
  $ctsparts++;   $ctsparts++;
Line 1694  sub viewstudentgrade { Line 1732  sub viewstudentgrade {
  '<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.   '<a href="javascript:viewOneStudent(\''.$uname.'\',\''.$udom.
  '\')"; TARGET=_self>'.$fullname.'</a>'.   '\')"; TARGET=_self>'.$fullname.'</a>'.
  '</td><td>'.$uname.'</td><td align="middle">'.$udom.'</td>'."\n";   '</td><td>'.$uname.'</td><td align="middle">'.$udom.'</td>'."\n";
     foreach my $part (@$parts) {      foreach my $apart (@$parts) {
  my ($part,$type) = &split_part_type($part);   my ($part,$type) = &split_part_type($apart);
  my $score=$record{"resource.$part.$type"};   my $score=$record{"resource.$part.$type"};
  if ($type eq 'awarded') {   if ($type eq 'awarded') {
     my $pts = $score eq '' ? '' : $score*$$weight{$part};      my $pts = $score eq '' ? '' : $score*$$weight{$part};
Line 2162  sub gradingmenu { Line 2200  sub gradingmenu {
     $result.=&view_edit_entire_class_form($symb,$url).'<br />';      $result.=&view_edit_entire_class_form($symb,$url).'<br />';
     $result.=&upcsvScores_form($symb,$url).'<br />';      $result.=&upcsvScores_form($symb,$url).'<br />';
     $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />';      $result.=&viewGradeaStu_form($symb,$url,$resptype,$hdgrade).'<br />';
       $result.=&gradeByPage_form($symb,$url,$resptype,$hdgrade).'<br />';
     $result.=&verifyReceipt_form($symb,$url)       $result.=&verifyReceipt_form($symb,$url) 
  if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb));   if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb));
     
Line 2233  sub viewGradeaStu_form { Line 2272  sub viewGradeaStu_form {
     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>';      $result.='&nbsp;<b>';
     if ($handgrade eq 'yes') {      $result.=($handgrade eq 'yes' ? 'View/Grade' : 'View').' an Individual Student\'s Submission</b></td></tr>'."\n";
  $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 2274  sub viewGradeaStu_form { Line 2308  sub viewGradeaStu_form {
     return $result;      return $result;
 }  }
   
   #--- Handgrading problems by page/sequence for each student ---
   sub gradeByPage_form {
       my ($symb,$url,$response,$handgrade) = @_;
       my ($classlist,$sections) = &getclasslist('all','0');
       my $result.='<table width=100% border=0><tr><td bgcolor=#777777>'."\n";
       $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
       $result.='&nbsp;<b>';
       $result.='Handgrade an Individual Student\'s by Page/Sequence</b></td></tr>'."\n";
       $result.='<tr bgcolor=#ffffe6><td>'."\n";
       $result.='<form action="/adm/grades" method="post">'."\n".
    '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
    '<input type="hidden" name="url" value="'.$url.'" />'."\n".
    '<input type="hidden" name="response" value="'.$response.'" />'."\n".
    '<input type="hidden" name="handgrade" value="'.$handgrade.'" />'."\n".
    '<input type="hidden" name="showgrading" value="yes" />'."\n".
    '<input type="hidden" name="command" value="pickStudentPage" />'."\n";
   
       $result.='&nbsp;<b>Select section:</b> <select name="section">'."\n";
       if (ref($sections)) {
    foreach (sort (@$sections)) {$result.='<option>'.$_.'</option>'."\n";}
       }
       $result.= '<option selected="on">all</select>'."\n";
   
       $result.='<br />&nbsp;<input type="button" onClick="submit();" value="';
       $result.='View/Grade'.'" />'."\n".'</form>'."\n";
       $result.='</td></tr></table>'."\n";
       $result.='</td></tr></table>'."\n";
       return $result;
   }
   
   
   sub pickStudentPage {
       my ($request) = shift;
   
       $request->print(<<LISTJAVASCRIPT);
   <script type="text/javascript" language="javascript">
   
   function checkPickOne(formname) {
       var user = radioSelection(formname.pickOne);
       if (user == null) {
    alert("Please select the student you wish to grade.");
    return;
       }
       formname.submit();
   }
   
   function radioSelection(radioButton) {
       var selection=null;
       for (var i=0; i<radioButton.length; i++) {
           if (radioButton[i].checked) {
               selection=radioButton[i].value;
               return selection;
           }
       }
       return selection;
   }
   </script>
   LISTJAVASCRIPT
   
       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 $result='<h3><font color="#339933">&nbsp;'.
    'Manual Grading by Page or Sequence</font></h3>';
   
       my ($pagepath,$pagename,$type,$mapId) = ($symb =~ /(.*\/)(.*?\.(page|sequence))___(\d+)___/); 
       my $curtitle = &Apache::lonnet::metadata($pagepath.$pagename,'title');
   
       $result.='<form action="/adm/grades" method="post" name="displayPage">'."<br>\n";
       $result.='&nbsp;<b>Problems from:</b> <select name="page">'."\n";
       my ($titles,$symbx) = &getSymbMap();
   #    shift @$titles; # skip the top level sequence
       foreach (@$titles) {
    my ($minder,$showtitle) = ($_ =~ /(\d+)\.(.*)/);
    my $check_select = ($showtitle eq $curtitle ? 'selected="on"' : '');
    $result.='<option value="'.$_.'" '.$check_select.'>'.$showtitle.'</option>'."\n";
       }
       $result.= '</select>'."<br>\n";
   
   #    $result.='&nbsp;<b>View Problems: </b><input type="radio" name="vProb" value="no" checked /> no '."\n".
   # '<input type="radio" name="vProb" value="yes" /> yes '."<br>\n";
   #    $result.='&nbsp;<b>Submission Details: </b>'.
   # '<input type="radio" name="lastSub" value="last" checked /> last sub only'."\n".
   # '<input type="radio" name="lastSub" value="all" /> all details'."\n";
       $result.='<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
    '<input type="hidden" name="command"  value="displayPage" />'."\n".
    '<input type="hidden" name="url"  value="'.$url.'" />'."\n".
    '<input type="hidden" name="symb" value="'.$symb.'" />'."<br><br>\n";
       $request->print($result);
   
       my $studentTable.='&nbsp;<b>Select a Student you wish to grade</b><br>'.
    '<table border="0"><tr><td bgcolor="#777777">'.
    '<table border="0"><tr bgcolor="#e6ffff">'.
    '<td><b>&nbsp;Fullname <font color="#999999">(username)</font></b></td>'.
    '<td><b>&nbsp;Fullname <font color="#999999">(username)</font></b></td>'.
    '<td><b>&nbsp;Fullname <font color="#999999">(username)</font></b></td>'.
    '<td><b>&nbsp;Fullname <font color="#999999">(username)</font></b></td></tr>';
    
       my (undef,undef,$fullname) = &getclasslist($getsec,'0');
       my $ptr = 1;
       foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
    my ($uname,$udom) = split(/:/,$student);
    $studentTable.=($ptr%4 == 1 ? '<tr bgcolor="#ffffe6"><td>' : '</td><td>');
    $studentTable.='<input type="radio" name="pickOne" value="'.$student.'" /> '.$$fullname{$student}.
       '<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font>'."\n";
    $studentTable.=($ptr%4 == 0 ? '</td></tr>' : '');
    $ptr++;
       }
       $studentTable.='</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;' if ($ptr%4 == 2);
       $studentTable.='</td><td>&nbsp;</td><td>&nbsp;' if ($ptr%4 == 3);
       $studentTable.='</td><td>&nbsp;' if ($ptr%4 == 0);
       $studentTable.='</td></tr></table></td></tr></table>'."\n";
       $studentTable.='<br />&nbsp;<input type="button" onClick="javascript:checkPickOne(this.form);" value="Submit" /></form>'."\n";
   
       $studentTable.=&show_grading_menu_form($symb,$url);
       $request->print($studentTable);
   
       return '';
   }
   
   sub getSymbMap {
       my $navmap = Apache::lonnavmaps::navmap-> new(
     $ENV{'request.course.fn'}.'.db',
     $ENV{'request.course.fn'}.'_parms.db',1, 1);
   
       my $res = $navmap->firstResource(); # temp resource to access constants
       $navmap->init();
   
       # End navmap using boilerplate
   
       my $iterator = $navmap->getIterator(undef, undef, undef, 1);
       my $depth = 1;
       $iterator->next(); # ignore first BEGIN_MAP
       my $curRes = $iterator->next();
   
       my %symbx = ();
       my @titles = ();
       my $minder=0;
       while ($depth > 0) {
           if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
           if ($curRes == $iterator->END_MAP()) { $depth--; }
   
           if (ref($curRes) && $curRes->is_map()) {
               my $title = $curRes->compTitle();
       push @titles,$minder.'.'.$title; # minder, just in case two titles are identical
       $symbx{$minder.'.'.$title} = $curRes->symb();
       $minder++;
          }
           $curRes = $iterator->next();
       }
   
       $navmap->untieHashes();
       return \@titles,\%symbx;
   }
   
   sub displayPage {
       my ($request) = shift;
   
       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 $pageTitle = $ENV{'form.page'};
       my (undef,undef,$fullname) = &getclasslist($getsec,'0');
       my ($uname,$udom) = split(/:/,$ENV{'form.pickOne'});
       my ($idx,$showtitle) = ($pageTitle =~ /(\d+)\.(.*)/);
   
       my $result='<h3><font color="#339933">&nbsp;'.$showtitle.'</font></h3>';
       $result.='<h3>&nbsp;Student: '.$$fullname{$ENV{'form.pickOne'}}.
    '<font color="#999999"> ('.$uname.($udom eq $cdom ? '':':'.$udom).')</font></h3>'."\n";
   
       my ($pg_titles,$pg_symbx) = &getSymbMap();
   
       my $navmap = Apache::lonnavmaps::navmap-> new(
     $ENV{'request.course.fn'}.'.db',
     $ENV{'request.course.fn'}.'_parms.db',1, 1);
   
       my ($mapUrl, $id, $resUrl) = split(/___/, $$pg_symbx{$ENV{'form.page'}});
       my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
   
       my $iterator = $navmap->getIterator($map->map_start(),
    $map->map_finish());
   
       my $depth = 1;
       $iterator->next(); # skip the first BEGIN_MAP
       my $curRes = $iterator->next(); # for "current resource"
       my %symbx = ();
       my @titles = ();
       my %parts = ();
       my $ctr=0;
       my $minder=0;
       while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
           if($curRes == $iterator->BEGIN_MAP) { $depth++; }
           if($curRes == $iterator->END_MAP) { $depth++; }
   
           if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
       my $parts = $curRes->parts();
               my $title = $curRes->compTitle();
       push @titles,$minder.'.'.$title; # minder, just in case two titles are identical
       if (scalar(@{$parts}) > 1) { shift @{$parts}; }
       for my $part (@$parts) {
    $result.='title='.$title.'part='.$part.':<br>';
       }
       $parts{$minder.'.'.$title} = join '::',@$parts;
   
               $symbx{$minder.'.'.$title} = $curRes->symb();
       $minder++;
   
          }
           $curRes = $iterator->next();
    $ctr++;
       }
   
       $navmap->init();
       $request->print($result);
   
       my $studentTable.=
    '<table border="0"><tr><td bgcolor="#777777">'.
    '<table border="0"><tr bgcolor="#e6ffff">'.
    '<td><b>&nbsp;No&nbsp;</b></td>'.
    '<td><b>&nbsp;Title</b></td>'.
    '<td><b>&nbsp;Answer</b></td>'.
    '<td><b>&nbsp;Grade</b></td></tr>';
       my $question=1;
       foreach (@titles) {
    my ($minder,$showtitle) = ($_ =~ /(\d+)\.(.*)/);
    $studentTable.='<tr bgcolor="#ffffe6"><td align="center" valign="top" >'.$question.'</td>';
    $studentTable.='<td valign="top">&nbsp;'.$showtitle.'&nbsp;</td>';
    $studentTable.='<td>&nbsp;'.
       &Apache::loncommon::get_student_answers($symbx{$_},$uname,$udom,$ENV{'request.course.id'}).'</td>';
   
    my (undef,undef,$requesturl)=split(/___/,$symbx{$_});
    $requesturl=&Apache::lonnet::clutter($requesturl);
    my $subresult=&Apache::lonnet::ssi($requesturl,
      ('grade_target' => 'analyze'),
      ('grade_domain' => $udom),
      ('grade_user' => $uname),
      ('grade_symb' => $symbx{$_}),
      ('grade_courseid' => $ENV{'request.course.id'}));
    (undef,$subresult)=split(/_HASH_REF__/,$subresult,2);
    my %analyze=&Apache::lonnet::str2hash($subresult);
   
    $studentTable.='<td>&nbsp;';
    while (my($key,$value) = each (%analyze)){
       $studentTable.='key='.$key.'->value='.$value.'<br>';
    }
    $studentTable.='</td></tr>';
    $question++;
   
       }
   
       $studentTable.='</table></td></tr></table>';
   #    $result.='<form action="/adm/grades" method="post" name="displayPage">'."<br>\n";
   #    $result.='</form>'."\n";
   
       $request->print($studentTable);
   
   
       return '';
   }
   
 #--- Form to input a receipt number ---  #--- Form to input a receipt number ---
 sub verifyReceipt_form {  sub verifyReceipt_form {
     my ($symb,$url) = @_;      my ($symb,$url) = @_;
Line 2361  sub handler { Line 2657  sub handler {
     } else {      } else {
  $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 '');      ($ENV{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
     &submission($request,0,0) if ($ENV{'form.student'} ne '');  # if ($command eq 'submission') {
   #    &listStudents($request) if ($ENV{'form.student'} eq '');
   #    &submission($request,0,0) if ($ENV{'form.student'} ne '');
    } elsif ($command eq 'pickStudentPage') {
       &pickStudentPage($request);
    } elsif ($command eq 'displayPage') {
       &displayPage($request);
  } elsif ($command eq 'processGroup') {   } elsif ($command eq 'processGroup') {
     &processGroup($request);      &processGroup($request);
  } elsif ($command eq 'gradingmenu') {   } elsif ($command eq 'gradingmenu') {

Removed from v.1.57  
changed lines
  Added in v.1.69


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