--- loncom/homework/grades.pm 2007/07/04 20:28:44 1.420
+++ loncom/homework/grades.pm 2007/08/21 22:21:54 1.432
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.420 2007/07/04 20:28:44 www Exp $
+# $Id: grades.pm,v 1.432 2007/08/21 22:21:54 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -45,7 +45,6 @@ use LONCAPA;
use POSIX qw(floor);
-my %oldessays=();
my %perm=();
# ----- These first few routines are general use routines.----
@@ -538,7 +537,7 @@ sub compute_points {
#
sub most_similar {
- my ($uname,$udom,$uessay)=@_;
+ my ($uname,$udom,$uessay,$old_essays)=@_;
# ignore spaces and punctuation
@@ -555,23 +554,22 @@ sub most_similar {
my $scrsid='';
my $sessay='';
# go through all essays ...
- foreach my $tkey (keys %oldessays) {
- my ($tname,$tdom,$tcrsid)=split(/\./,$tkey);
+ foreach my $tkey (keys(%$old_essays)) {
+ my ($tname,$tdom,$tcrsid)=map {&unescape($_)} (split(/\./,$tkey));
# ... except the same student
- if (($tname ne $uname) || ($tdom ne $udom)) {
- my $tessay=$oldessays{$tkey};
- $tessay=~s/\W+/ /gs;
+ next if (($tname eq $uname) && ($tdom eq $udom));
+ my $tessay=$old_essays->{$tkey};
+ $tessay=~s/\W+/ /gs;
# String similarity gives up if not even limit
- my $tsimilar=&String::Similarity::similarity($uessay,$tessay,$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 ($tsimilar>$limit) {
+ $limit=$tsimilar;
+ $sname=$tname;
+ $sdom=$tdom;
+ $scrsid=$tcrsid;
+ $sessay=$old_essays->{$tkey};
+ }
}
if ($limit>0.6) {
return ($sname,$sdom,$scrsid,$sessay,$limit);
@@ -725,7 +723,6 @@ LISTJAVASCRIPT
my $saveStatus = $env{'form.Status'} eq '' ? 'Active' : $env{'form.Status'};
$env{'form.Status'} = $saveStatus;
-
$gradeTable.=''."\n".
''."\n".
''."\n".
@@ -736,8 +733,7 @@ LISTJAVASCRIPT
''.
''.
''.
-
- ''."\n".
+ &build_section_inputs().
''."\n".
'
'."\n".
'
'."\n".
@@ -1663,6 +1659,19 @@ sub download_all_link {
return
}
+sub build_section_inputs {
+ my $section_inputs;
+ if ($env{'form.section'} eq '') {
+ $section_inputs .= ''."\n";
+ } else {
+ my @sections = &Apache::loncommon::get_env_multiple('form.section');
+ foreach my $section(@sections) {
+ $section_inputs .= ''."\n";
+ }
+ }
+ return $section_inputs;
+}
+
# --------------------------- show submissions of a student, option to grade
sub submission {
my ($request,$counter,$total) = @_;
@@ -1691,6 +1700,7 @@ sub submission {
'" src="'.$request->dir_config('lonIconsURL').
'/check.gif" height="16" border="0" />';
+ my %old_essays;
# header info
if ($counter == 0) {
&sub_page_js($request);
@@ -1742,7 +1752,6 @@ sub submission {
$env{'form.savemsgN'} = $keyhash{$symb.'_savemsgN'} ne '' ? $keyhash{$symb.'_savemsgN'} : '0';
}
my $overRideScore = $env{'form.overRideScore'} eq '' ? 'no' : $env{'form.overRideScore'};
-
$request->print('