Diff for /loncom/homework/grades.pm between versions 1.56 and 1.62

version 1.56, 2002/10/16 19:23:48 version 1.62, 2002/11/27 16:39:37
Line 339  LISTJAVASCRIPT Line 339  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" checked> no '."\n".   '&nbsp;<b>View Problem: </b><input type="radio" name="vProb" value="no" /> no '."\n".
  '<input type="radio" name="vProb" value="yes"> 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 351  LISTJAVASCRIPT Line 352  LISTJAVASCRIPT
  '<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".   '<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
  '<input type="hidden" name="submitonly"  value="'.$submitonly.'" />'."\n".   '<input type="hidden" name="submitonly"  value="'.$submitonly.'" />'."\n".
  '<input type="hidden" name="response"    value="'.$ENV{'form.response'}.'" />'."\n".   '<input type="hidden" name="response"    value="'.$ENV{'form.response'}.'" />'."\n".
  '<input type="hidden" name="handgrade"   value="'.$ENV{'form.handgrade'}.'" /><br />'."\n".   '<input type="hidden" name="handgrade": #falue="'.$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="'.$url.'" />'."\n".   '<input type="hidden" name="url"  value="'.$url.'" />'."\n".
  '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".   '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
Line 671  sub sub_page_js { Line 672  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 796  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 836  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 820  sub submission { Line 847  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') {
     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 910  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 916  KEYWORDS Line 937  KEYWORDS
  ($classlist,undef,$fullname) = &getclasslist('all','0');   ($classlist,undef,$fullname) = &getclasslist('all','0');
  for (keys (%$handgrade)) {   for (keys (%$handgrade)) {
     my $ncol = &Apache::lonnet::EXT('resource.'.$_.      my $ncol = &Apache::lonnet::EXT('resource.'.$_.
     '.maxcollaborators',$symb,$udom,$uname);      '.maxcollaborators',
     if ($ncol > 0) {                                              $symb,$udom,$uname);
  s/\_/\./g;      next if ($ncol <= 0);
  if ($record{'resource.'.$_.'.collaborators'} ne '') {              s/\_/\./g;
     my (@collaborators) = split(/,?\s+/,              next if ($record{'resource.'.$_.'.collaborators'} eq '');
  $record{'resource.'.$_.'.collaborators'});              my (@collaborators) = split(/,?\s+/,
     my (@badcollaborators);                                     $record{'resource.'.$_.'.collaborators'});
     if (scalar(@collaborators) != 0) {              my (@badcollaborators);
  $result.='<b>Collaborators: </b>';              if (scalar(@collaborators) != 0) {
  foreach my $collaborator (@collaborators) {                  $result.='<b>Collaborators: </b>';
     $collaborator = $collaborator =~ /\@|:/ ?                   foreach my $collaborator (@collaborators) {
  (split(/@|:/,$collaborator))[0] : $collaborator;                      my ($co_name,$co_dom) = split /\@|:/,$collaborator;
     next if ($collaborator eq $uname);                      $co_dom = $udom if (! defined($co_dom));
     if (!grep /^$collaborator:/i,keys %$classlist) {                      next if ($co_name eq $uname && $co_dom eq $udom);
  push @badcollaborators,$collaborator;                      # Doing this grep allows 'fuzzy' specification
  next;                      my @Matches = grep /^$co_name:$co_dom/i,
     }                      keys %$classlist;
     push @col_list, $collaborator;                      if (! scalar(@Matches)) {
     my ($lastname,$givenn) = split(/,/,$$fullname{$collaborator.':'.$udom});                          push @badcollaborators,$collaborator;
     push @col_fullnames, $givenn.' '.$lastname;                          next;
     $result.=$$fullname{$collaborator.':'.$udom}.'&nbsp; &nbsp; &nbsp;';                      }
  }                      push @col_list, @Matches;
  $result.='<br />'."\n";                      foreach (@Matches) {
  $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'.                          my ($lastname,$givenn) = split(/,/,$$fullname{$_});
     'This student has submitted '.                          push @col_fullnames, $givenn.' '.$lastname;
     (scalar (@badcollaborators) > 1 ? '' : 'an').                          $result.=$$fullname{$_}.'&nbsp; &nbsp; &nbsp;';
     ' invalid collaborator'.(scalar (@badcollaborators) > 1 ? 's. ' : '. ').                      }
     (join ', ',@badcollaborators).'</td></tr></table>'                   }
     if (scalar(@badcollaborators) > 0);                  $result.='<br />'."\n";
                   if (scalar(@badcollaborators) > 0) {
  $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>'.                      $result.='<table border="0"><tr bgcolor="#ffbbbb"><td>';
     'This student has submitted too many collaborators. Maximum is '.                      $result.='This student has submitted ';
     $ncol.'.</td></tr></table>' if (scalar(@collaborators) > $ncol);                      if (scalar(@badcollaborators) == 1) {
  $result.='<input type="hidden" name="collaborator'.$counter.                          $result .= 'an invalid collaborator';
     '" value="'.(join ':',@col_list).'" />'."\n";                      } else {
     }                          $result .= 'invalid collaborators';
  }                      }
     }                      $result .= ': '.join(', ',@badcollaborators);
                       
                   }
                   if (scalar(@collaborators > $ncol)) {
                       $result .= '<table border="0"><tr bgcolor="#ffbbbb"><td>';
                       $result .= 'This student has sumbitted too many '.
                           'collaborators.  Maximum is '.$ncol;
                       $result .= '</td></tr></table>';
                   }
                   $result.='<input type="hidden" name="collaborator'.$counter.
                       '" value="'.(join ':',@col_list).'" />'."\n";
               }
  }   }
     }      }
     $request->print($result."\n");      $request->print($result."\n");
Line 1077  KEYWORDS Line 1109  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 1135  sub get_last_submission { Line 1173  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 1161  sub keywords_highlight { Line 1199  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
       # better one at this time.  So here we go - the m in the s:::mg causes
       # ^ to match the beginning of a new line.  So we replace(???) the beginning
       # of the line with <br /> to make things formatted a little better.
       $string =~ s:^:<br />:mg;
     return $string;      return $string;
 }  }
   
Line 1183  sub processHandGrade { Line 1226  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 1333  sub saveHandGrade { Line 1376  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 1610  sub viewgrades { Line 1657  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++;

Removed from v.1.56  
changed lines
  Added in v.1.62


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