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

version 1.86, 2003/04/21 18:39:43 version 1.88, 2003/04/30 20:16:02
Line 46  use Apache::lonhomework; Line 46  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);
   use String::Similarity;
   
   my %oldessays=();
   
 # ----- These first few routines are general use routines.----  # ----- These first few routines are general use routines.----
 #  #
Line 221  sub jscriptNform { Line 224  sub jscriptNform {
 }  }
   
 #------------------ End of general use routines --------------------  #------------------ End of general use routines --------------------
   
   #
   # Find most similar essay
   #
   
   sub most_similar {
       my ($uname,$udom,$uessay)=@_;
   
   # ignore spaces and punctuation
   
       $uessay=~s/\W+/ /gs;
   
   # these will be returned. Do not care if not at least 50 percent similar
       my $limit=0.6;
       my $sname='';
       my $sdom='';
       my $scrsid='';
       my $sessay='';
   # go through all essays ...
       foreach my $tkey (keys %oldessays) {
    my ($tname,$tdom,$tcrsid)=split(/\./,$tkey);
   # ... except the same student
           if (($tname ne $uname) || ($tdom ne $udom)) {
       my $tessay=$oldessays{$tkey};
               $tessay=~s/\W+/ /gs;
   # String similarity gives up if not even limit
               my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit);
   # Found one
               if ($tsimilar>$limit) {
    $limit=$tsimilar;
                   $sname=$tname;
                   $sdom=$tdom;
                   $scrsid=$tcrsid;
                   $sessay=$oldessays{$tkey};
               }
           } 
       }
       if ($limit>0.6) {
          return ($sname,$sdom,$scrsid,$sessay,$limit);
       } else {
          return ('','','','',0);
       }
   }
   
 #-------------------------------------------------------------------  #-------------------------------------------------------------------
   
 #------------------------------------ Receipt Verification Routines  #------------------------------------ Receipt Verification Routines
Line 1075  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 1082  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 1189  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 1196  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.86  
changed lines
  Added in v.1.88


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