--- loncom/homework/grades.pm 2007/07/25 00:00:23 1.424
+++ loncom/homework/grades.pm 2007/08/21 18:41:27 1.430
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.424 2007/07/25 00:00:23 albertel Exp $
+# $Id: grades.pm,v 1.430 2007/08/21 18:41:27 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);
@@ -1691,6 +1689,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);
@@ -1805,7 +1804,7 @@ KEYWORDS
my ($adom,$aname,$apath)=($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
$apath=&escape($apath);
$apath=~s/\W/\_/gs;
- %oldessays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
+ %old_essays=&Apache::lonnet::dump('nohist_essay_'.$apath,$adom,$aname);
}
}
@@ -1943,12 +1942,21 @@ KEYWORDS
my $similar='';
if($env{'form.checkPlag'}){
my ($oname,$odom,$ocrsid,$oessay,$osim)=
- &most_similar($uname,$udom,$subval);
+ &most_similar($uname,$udom,$subval,\%old_essays);
if ($osim) {
$osim=int($osim*100.0);
- $similar="
Essay".
- " is $osim% similar to an essay by ".
- &Apache::loncommon::plainname($oname,$odom).
+ my %old_course_desc =
+ &Apache::lonnet::coursedescription($ocrsid,
+ {'one_time' => 1});
+
+ $similar="
".
+ &mt('Essay is [_1]% similar to an essay by [_2] ([_3]:[_4]) in course [_5] (course id [_6]:[_7])',
+ $osim,
+ &Apache::loncommon::plainname($oname,$odom),
+ $oname,$odom,
+ $old_course_desc{'description'},
+ $old_course_desc{'num'},
+ $old_course_desc{'domain'}).
'
'.
&keywords_highlight($oessay).
'
';
@@ -2963,12 +2971,13 @@ sub viewgrades {
''."\n";
my $sectionClass;
+ my $section_display = join (", ",&Apache::loncommon::get_env_multiple('form.section'));
if ($env{'form.section'} eq 'all') {
$sectionClass='Class
';
} elsif ($env{'form.section'} eq 'none') {
$sectionClass='Students in no Section ';
} else {
- $sectionClass='Students in Section '.$env{'form.section'}.'';
+ $sectionClass='Students in Section(s) '.$section_display.'';
}
$result.='
Assign Common Grade To '.$sectionClass;
$result.= '
'."\n".
@@ -5666,6 +5675,26 @@ sub scantron_remove_scan_data {
count - number of scanlines
- second is the scan_data hash possible keys are
+ ($number refers to scanline numbered $number and thus the key affects
+ only that scanline
+ $bubline refers to the specific bubble line element and the aspects
+ refers to that specific bubble line element)
+
+ $number.user - username:domain to use
+ $number.CODE_ignore_dup
+ - ignore the duplicate CODE error
+ $number.useCODE
+ - use the CODE in the scanline as is
+ $number.no_bubble.$bubline
+ - it is valid that there is no bubbled in bubble
+ at $number $bubline
+ remember_skipping
+ - a frozen hash containing keys of $number and values
+ of either
+ 1 - we are on a 'do skipped records pass' and plan
+ on processing this line
+ 2 - we are on a 'do skipped records pass' and this
+ scanline has been marked to skip yet again
=cut
@@ -6904,7 +6933,7 @@ GRADINGMENUJS
$result.='