--- loncom/homework/grades.pm 2011/11/14 03:08:01 1.663 +++ loncom/homework/grades.pm 2012/12/18 18:05:35 1.683 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.663 2011/11/14 03:08:01 raeburn Exp $ +# $Id: grades.pm,v 1.683 2012/12/18 18:05:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,6 +54,7 @@ use POSIX qw(floor); my %perm=(); +my %old_essays=(); # These variables are used to recover from ssi errors @@ -202,6 +203,7 @@ sub get_display_part { sub reset_caches { &reset_analyze_cache(); &reset_perm(); + &reset_old_essays(); } { @@ -681,7 +683,11 @@ sub compute_points { # sub most_similar { - my ($uname,$udom,$uessay,$old_essays)=@_; + my ($uname,$udom,$symb,$uessay)=@_; + + unless ($symb) { return ''; } + + unless (ref($old_essays{$symb}) eq 'HASH') { return ''; } # ignore spaces and punctuation @@ -698,11 +704,11 @@ sub most_similar { my $scrsid=''; my $sessay=''; # go through all essays ... - foreach my $tkey (keys(%$old_essays)) { + foreach my $tkey (keys(%{$old_essays{$symb}})) { my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey)); # ... except the same student next if (($tname eq $uname) && ($tdom eq $udom)); - my $tessay=$old_essays->{$tkey}; + my $tessay=$old_essays{$symb}{$tkey}; $tessay=~s/\W+/ /gs; # String similarity gives up if not even limit my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$limit); @@ -712,7 +718,7 @@ sub most_similar { $sname=$tname; $sdom=$tdom; $scrsid=$tcrsid; - $sessay=$old_essays->{$tkey}; + $sessay=$old_essays{$symb}{$tkey}; } } if ($limit>0.6) { @@ -1524,17 +1530,15 @@ INNERJS function savedMsgHeader(Nmsg,usrctr,fullname) { var height = 70*Nmsg+250; - var scrollbar = "no"; if (height > 600) { height = 600; - scrollbar = "yes"; } var xpos = (screen.width-600)/2; xpos = (xpos < 0) ? '0' : xpos; var ypos = (screen.height-height)/2-30; ypos = (ypos < 0) ? '0' : ypos; - pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars='+scrollbar+',screenx='+xpos+',screeny='+ypos+',width=700,height='+height); + pWin = window.open('', 'MessageCenter', 'resizable=yes,toolbar=no,location=no,scrollbars=yes,screenx='+xpos+',screeny='+ypos+',width=700,height='+height); pWin.focus(); pDoc = pWin.document; pDoc.$docopen; @@ -1542,39 +1546,38 @@ INNERJS pDoc.write("
"); pDoc.write(""); - pDoc.write("

 $lt{'comp'}\"+fullname+\"<\\/span><\\/h3>

"); + pDoc.write("

 $lt{'comp'}\"+fullname+\"<\\/h1>"); - pDoc.write('
'); - pDoc.write(''); - pDoc.write("
$lt{'type'}<\\/b><\\/td>$lt{'incl'}<\\/b><\\/td>$lt{'mesa'}<\\/td><\\/tr>"); + pDoc.write(''); + pDoc.write(""); - pDoc.write(""); pDoc.write(""); - pDoc.write(""); pDoc.write("
$lt{'incl'}<\\/b><\\/td>$lt{'type'}<\\/b><\\/td>$lt{'mesa'}<\\/td><\\/tr>"); } function displaySubject(msg,shwsel) { pDoc = pWin.document; - pDoc.write("
$lt{'subj'}<\\/td>"); + pDoc.write("
<\\/td>"); - pDoc.write("<\\/td><\\/tr>"); + pDoc.write("$lt{'subj'}<\\/td>"); + pDoc.write("<\\/td><\\/tr>"); } function displaySavedMsg(ctr,msg,shwsel) { pDoc = pWin.document; - pDoc.write("
"+ctr+"<\\/td>"); + pDoc.write("
<\\/td>"); + pDoc.write(""+ctr+"<\\/td>"); pDoc.write("