[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /homework grades.pm
raeburn
raeburn at source.lon-capa.org
Thu Aug 9 16:07:22 EDT 2012
raeburn Thu Aug 9 20:07:22 2012 EDT
Modified files: (Branch: version_2_11_X)
/loncom/homework grades.pm
Log:
- For 2.11
- Backport 1.674.
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.596.2.12.2.8 loncom/homework/grades.pm:1.596.2.12.2.9
--- loncom/homework/grades.pm:1.596.2.12.2.8 Sun May 13 01:43:54 2012
+++ loncom/homework/grades.pm Thu Aug 9 20:07:21 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.596.2.12.2.8 2012/05/13 01:43:54 raeburn Exp $
+# $Id: grades.pm,v 1.596.2.12.2.9 2012/08/09 20:07:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,6 +52,7 @@
my %perm=();
+my %old_essays=();
# These variables are used to recover from ssi errors
@@ -263,6 +264,7 @@
sub reset_caches {
&reset_analyze_cache();
&reset_perm();
+ &reset_old_essays();
}
{
@@ -746,7 +748,11 @@
#
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
@@ -763,11 +769,11 @@
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);
@@ -777,7 +783,7 @@
$sname=$tname;
$sdom=$tdom;
$scrsid=$tcrsid;
- $sessay=$old_essays->{$tkey};
+ $sessay=$old_essays{$symb}{$tkey};
}
}
if ($limit>0.6) {
@@ -2027,7 +2033,6 @@
'" src="'.$request->dir_config('lonIconsURL').
'/check.gif" height="16" border="0" />';
- my %old_essays;
# header info
if ($counter == 0) {
&sub_page_js($request);
@@ -2143,7 +2148,7 @@
my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
$apath=&escape($apath);
$apath=~s/\W/\_/gs;
- %old_essays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ &init_old_essays($symb,$apath,$adom,$aname);
}
}
@@ -2280,7 +2285,7 @@
}
if($env{'form.checkPlag'}){
my ($oname,$odom,$ocrsid,$oessay,$osim)=
- &most_similar($uname,$udom,$subval,\%old_essays);
+ &most_similar($uname,$udom,$symb,$subval);
if ($osim) {
$osim=int($osim*100.0);
my %old_course_desc =
@@ -9273,6 +9278,21 @@
}
}
+sub init_old_essays {
+ my ($symb,$apath,$adom,$aname) = @_;
+ if ($symb ne '') {
+ my %essays = &Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ if (keys(%essays) > 0) {
+ $old_essays{$symb} = \%essays;
+ }
+ }
+ return;
+}
+
+sub reset_old_essays {
+ undef(%old_essays);
+}
+
sub gather_clicker_ids {
my %clicker_ids;
More information about the LON-CAPA-cvs
mailing list