--- loncom/homework/grades.pm 2003/04/30 15:52:28 1.87 +++ loncom/homework/grades.pm 2003/04/30 20:16:02 1.88 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.87 2003/04/30 15:52:28 www Exp $ +# $Id: grades.pm,v 1.88 2003/04/30 20:16:02 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -237,7 +237,7 @@ sub most_similar { $uessay=~s/\W+/ /gs; # 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 $sdom=''; my $scrsid=''; @@ -246,22 +246,22 @@ sub most_similar { foreach my $tkey (keys %oldessays) { my ($tname,$tdom,$tcrsid)=split(/\./,$tkey); # ... except the same student - if (($tname ne $uname) && ($tdom ne $udom)) { + 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::similar($uessay,$tessay,$limit); + my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit); # Found one if ($tsimilar>$limit) { $limit=$tsimilar; $sname=$tname; - $sdom=$sdom; + $sdom=$tdom; $scrsid=$tcrsid; $sessay=$oldessays{$tkey}; } } } - if ($limit>0.5) { + if ($limit>0.6) { return ($sname,$sdom,$scrsid,$sessay,$limit); } else { return ('','','','',0); @@ -1122,6 +1122,9 @@ sub submission { $request->print($prnmsg); if ($ENV{'form.handgrade'} eq 'yes' && $ENV{'form.showgrading'} eq 'yes') { +# +# Print out the keyword options line +# $request->print(<Keyword Options:  List    @@ -1129,6 +1132,14 @@ sub submission { CLASS="page">Paste Selection to List    Highlight Attribute

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); } } @@ -1236,6 +1247,15 @@ KEYWORDS my ($partid,$respid) = /^resource\.(\d+)\.(\d+)\.submission/; if ($part eq ($partid.'_'.$respid)) { 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='

Essay is '.$osim.'% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom). + '

'. + &keywords_highlight($oessay).'

'; + } $lastsubonly.='Part '. $partid.' ( ID '.$respid. ' )   '. @@ -1243,8 +1263,8 @@ KEYWORDS ' File uploaded by student Like all files provided by users, this file may contain virusses
':''). - 'Answer: '. - &keywords_highlight($subval).''."\n" + 'Answer:
'. + &keywords_highlight($subval).'

 '.$similar.''."\n" if ($ENV{'form.lastSub'} eq 'lastonly' || ($ENV{'form.lastSub'} eq 'hdgrade' && $$handgrade{$part} =~ /:yes$/));