Diff for /loncom/homework/grades.pm between versions 1.87 and 1.88

version 1.87, 2003/04/30 15:52:28 version 1.88, 2003/04/30 20:16:02
Line 237  sub most_similar { Line 237  sub most_similar {
     $uessay=~s/\W+/ /gs;      $uessay=~s/\W+/ /gs;
   
 # these will be returned. Do not care if not at least 50 percent similar  # these will be returned. Do not care if not at least 50 percent similar
     my $limit=0.5;      my $limit=0.6;
     my $sname='';      my $sname='';
     my $sdom='';      my $sdom='';
     my $scrsid='';      my $scrsid='';
Line 246  sub most_similar { Line 246  sub most_similar {
     foreach my $tkey (keys %oldessays) {      foreach my $tkey (keys %oldessays) {
  my ($tname,$tdom,$tcrsid)=split(/\./,$tkey);   my ($tname,$tdom,$tcrsid)=split(/\./,$tkey);
 # ... except the same student  # ... except the same student
         if (($tname ne $uname) && ($tdom ne $udom)) {          if (($tname ne $uname) || ($tdom ne $udom)) {
     my $tessay=$oldessays{$tkey};      my $tessay=$oldessays{$tkey};
             $tessay=~s/\W+/ /gs;              $tessay=~s/\W+/ /gs;
 # String similarity gives up if not even limit  # String similarity gives up if not even limit
             my $tsimilar=&String::Similarity::similar($uessay,$tessay,$limit);              my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit);
 # Found one  # Found one
             if ($tsimilar>$limit) {              if ($tsimilar>$limit) {
  $limit=$tsimilar;   $limit=$tsimilar;
                 $sname=$tname;                  $sname=$tname;
                 $sdom=$sdom;                  $sdom=$tdom;
                 $scrsid=$tcrsid;                  $scrsid=$tcrsid;
                 $sessay=$oldessays{$tkey};                  $sessay=$oldessays{$tkey};
             }              }
         }           } 
     }      }
     if ($limit>0.5) {      if ($limit>0.6) {
        return ($sname,$sdom,$scrsid,$sessay,$limit);         return ($sname,$sdom,$scrsid,$sessay,$limit);
     } else {      } else {
        return ('','','','',0);         return ('','','','',0);
Line 1122  sub submission { Line 1122  sub submission {
  $request->print($prnmsg);   $request->print($prnmsg);
   
  if ($ENV{'form.handgrade'} eq 'yes' && $ENV{'form.showgrading'} eq 'yes') {   if ($ENV{'form.handgrade'} eq 'yes' && $ENV{'form.showgrading'} eq 'yes') {
   #
   # Print out the keyword options line
   #
     $request->print(<<KEYWORDS);      $request->print(<<KEYWORDS);
 &nbsp;<b>Keyword Options:</b>&nbsp;  &nbsp;<b>Keyword Options:</b>&nbsp;
 <a href="javascript:keywords(document.SCORE.keywords)"; TARGET=_self>List</a>&nbsp; &nbsp;  <a href="javascript:keywords(document.SCORE.keywords)"; TARGET=_self>List</a>&nbsp; &nbsp;
Line 1129  sub submission { Line 1132  sub submission {
  CLASS="page">Paste Selection to List</a>&nbsp; &nbsp;   CLASS="page">Paste Selection to List</a>&nbsp; &nbsp;
 <a href="javascript:kwhighlight()"; TARGET=_self>Highlight Attribute</a><br /><br />  <a href="javascript:kwhighlight()"; TARGET=_self>Highlight Attribute</a><br /><br />
 KEYWORDS  KEYWORDS
   #
   # Load the other essays for similarity check
   #
               my $essayurl=&Apache::lonnet::declutter($url);
       my ($adom,$aname,$apath)=($essayurl=~/^(\w+)\/(\w+)\/(.*)$/);
       $apath=&Apache::lonnet::escape($apath);
       $apath=~s/\W/\_/gs;
       %oldessays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
         }          }
     }      }
   
Line 1236  KEYWORDS Line 1247  KEYWORDS
  my ($partid,$respid) = /^resource\.(\d+)\.(\d+)\.submission/;   my ($partid,$respid) = /^resource\.(\d+)\.(\d+)\.submission/;
  if ($part eq ($partid.'_'.$respid)) {   if ($part eq ($partid.'_'.$respid)) {
     my ($ressub,$subval) = split(/:/,$_,2);      my ($ressub,$subval) = split(/:/,$_,2);
   # Similarity check
                               my $similar='';
                               my ($oname,$odom,$ocrsid,$oessay,$osim)=&most_similar($uname,$udom,$subval);
                               if ($osim) {
    $osim=int($osim*100.0);
    $similar='<hr /><h3><font color="#FF0000">Essay is '.$osim.'% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom).
                                   '</font></h3><blockquote><i>'.
                                   &keywords_highlight($oessay).'</i></blockquote><hr />';
                               }
     $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;'.   ' )</font>&nbsp; &nbsp;'.
Line 1243  KEYWORDS Line 1263  KEYWORDS
                                 '<a href="'.                                  '<a href="'.
                                 &Apache::lonnet::tokenwrapper($record{"resource.$partid.$respid.uploadedurl"}).                                  &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 />':'').     '"><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>'.                                  '<b>Answer: </b><blockquote>'.
  &keywords_highlight($subval).'</td></tr>'."\n"   &keywords_highlight($subval).'</blockquote><br />&nbsp;'.$similar.'</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$/));

Removed from v.1.87  
changed lines
  Added in v.1.88


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