--- loncom/homework/grades.pm 2003/09/24 23:51:14 1.130.2.1.2.1
+++ loncom/homework/grades.pm 2003/08/18 18:24:32 1.134
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.130.2.1.2.1 2003/09/24 23:51:14 albertel Exp $
+# $Id: grades.pm,v 1.134 2003/08/18 18:24:32 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -544,7 +544,7 @@ LISTJAVASCRIPT
$gradeTable.='" />'."\n";
-
+ $gradeTable.='Check For Plagiarism';
my (undef, undef, $fullname) = &getclasslist($getsec,'1');
$gradeTable.='
'.
'
';
@@ -1461,13 +1461,20 @@ KEYWORDS
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).'
';
+ my $oname;
+ my $odom;
+ my $ocrsid;
+ my $oessay;
+ my $osim;
+ if($ENV{'form.checkPlag'}){
+ ($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.
@@ -1480,7 +1487,7 @@ KEYWORDS
'this file may contain virusses ':'').
'Submitted Answer: '.
&cleanRecord($subval,$responsetype,$symb).
- '
'.$similar."\n"
+ '
'.$similar."\n"
if ($ENV{'form.lastSub'} eq 'lastonly' ||
($ENV{'form.lastSub'} eq 'hdgrade' &&
$$handgrade{$part} =~ /:yes$/));
@@ -2798,9 +2805,7 @@ LISTJAVASCRIPT
sub getSymbMap {
my ($request) = @_;
- my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db',
- $ENV{'request.course.fn'}.'_parms.db');
- $navmap->init();
+ my $navmap = Apache::lonnavmaps::navmap->new();
my %symbx = ();
my @titles = ();
@@ -2845,8 +2850,7 @@ sub displayPage {
&sub_page_js($request);
$request->print($result);
- my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db',
- $ENV{'request.course.fn'}.'_parms.db',1, 1);
+ my $navmap = Apache::lonnavmaps::navmap->new();
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'});
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
@@ -3008,8 +3012,7 @@ sub updateGradeByPage {
$request->print($result);
- my $navmap = Apache::lonnavmaps::navmap-> new($ENV{'request.course.fn'}.'.db',
- $ENV{'request.course.fn'}.'_parms.db',1, 1);
+ my $navmap = Apache::lonnavmaps::navmap->new();
my ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'});
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
@@ -3184,7 +3187,7 @@ sub scantron_selectphase {
my $result;
$result.= <
-
+
$default_form_data
@@ -3214,7 +3217,7 @@ sub scantron_selectphase {
-
+
$grading_menu_button
SCANTRONFORM
@@ -3296,23 +3299,14 @@ sub scantron_parse_scanline {
}
sub scantron_add_delay {
- my ($delayqueue,$scanline,$errormessage,$errorcode)=@_;
- Apache->request->print('add_delay_error '.$_[2] );
- push(@$delayqueue,
- {'line' => $scanline, 'emsg' => $errormessage,
- 'ecode' => $errorcode }
- );
}
sub scantron_find_student {
my ($scantron_record,$idmap)=@_;
my $scanID=$$scantron_record{'scantron.ID'};
foreach my $id (keys(%$idmap)) {
- #Apache->request->print('
');
+ if (lc($id) eq lc($scanID)) { Apache->request->print('success');return $$idmap{$id}; }
}
return undef;
}
@@ -3325,18 +3319,6 @@ sub scantron_filter {
return 0;
}
-#FIXME I think I am doing this in the wrong order, I think it would be
-#better to make a several passes analyzing all of the lines in the
-#file for common errors wrong/invalid PID/username duplicated
-#PID/username, missing bubbles, double bubbles, missing/invalid CODE
-#and then get the instructor to fix all of these errors, then grade
-#the corrected one, I'll still need to catch error conditions, but
-#maybe most will taken care even before we start
-
-sub scantron_validate_file {
- my ($r) = @_;
-}
-
sub scantron_process_students {
my ($r) = @_;
my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'});
@@ -3349,10 +3331,10 @@ sub scantron_process_students {
my @scanlines=<$scanlines>;
my $classlist=&Apache::loncoursedata::get_classlist();
my %idmap=&username_to_idmap($classlist);
- my $navmap=Apache::lonnavmaps::navmap->new($ENV{'request.course.fn'}.'.db',$ENV{'request.course.fn'}.'_parms.db',1, 1);
+ my $navmap=Apache::lonnavmaps::navmap->new();
my $map=$navmap->getResourceByUrl($sequence);
my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0);
-# $r->print("geto ".scalar(@resources)." ");
+ $r->print("geto ".scalar(@resources)." ");
my $result= <
@@ -3361,36 +3343,29 @@ SCANTRONFORM
$r->print($result);
my @delayqueue;
- my %completedstudents;
-
+ my $totalcorrect;
+ my $totalincorrect;
+
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,
'Scantron Status','Scantron Progress',scalar(@scanlines));
- &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
- 'Processing first student');
- my $start=&Time::HiRes::time();
foreach my $line (@scanlines) {
- $r->print('
line is'.$line.'
');
+ my $studentcorrect;
+ my $studentincorrect;
chomp($line);
my $scan_record=&scantron_parse_scanline($line,\%scantron_config);
my ($uname,$udom);
- unless ($uname=&scantron_find_student($scan_record,\%idmap)) {
- &scantron_add_delay(\@delayqueue,$line,
- 'Unable to find a student that matches',1);
- next;
- }
- if (exists $completedstudents{$uname}) {
+ if ($uname=&scantron_find_student($scan_record,\%idmap)) {
&scantron_add_delay(\@delayqueue,$line,
- 'Student '.$uname.' has multiple sheets',2);
- next;
+ 'Unable to find a student that matches');
}
$r->print('
result is'.$result);
+ &Apache::lonhomework::showhash(%score);
# if ($i eq 3) {last;}
}
- $completedstudents{$uname}={'line'=>$line};
- } continue {
&Apache::lonnet::delenv('form.counter');
&Apache::lonnet::delenv('scantron\.');
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
- 'last student');
- #last;
+ 'last student Who got a '.$studentcorrect.' correct and '.
+ $studentincorrect.' incorrect. The class has gotten '.
+ $totalcorrect.' correct and '.$totalincorrect.' incorrect');
+ last;
#FIXME
#get iterator for $sequence
#foreach question 'submit' the students answer to the server
@@ -3434,11 +3409,7 @@ SCANTRONFORM
# generate data to pass back that includes grade recevied
#}
}
- &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
- my $lasttime = &Time::HiRes::time()-$start;
- $r->print("
took $lasttime
");
-
- #$Apache::lonxml::debug=0;
+ $Apache::lonxml::debug=0;
foreach my $delay (@delayqueue) {
#FIXME
#print out each delayed student with interface to select how
@@ -3721,8 +3692,6 @@ sub handler {
}
} elsif ($command eq 'scantron_selectphase' && $perm{'mgr'}) {
$request->print(&scantron_selectphase($request));
- } elsif ($command eq 'scantron_validate' && $perm{'mgr'}) {
- $request->print(&scantron_validate_file($request));
} elsif ($command eq 'scantron_process' && $perm{'mgr'}) {
$request->print(&scantron_process_students($request));
} elsif ($command) {