--- loncom/homework/grades.pm	2003/07/31 15:08:41	1.129
+++ loncom/homework/grades.pm	2003/09/09 18:46:28	1.136
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.129 2003/07/31 15:08:41 ng Exp $
+# $Id: grades.pm,v 1.136 2003/09/09 18:46:28 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -517,8 +517,8 @@ LISTJAVASCRIPT
     my $saveStatus = $ENV{'form.Status'} eq '' ? 'Active' : $ENV{'form.Status'};
     $ENV{'form.Status'} = $saveStatus;
 
-    $gradeTable.='<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last sub only'."\n".
-	'<input type="radio" name="lastSub" value="last" /> last sub & parts info'."\n".
+    $gradeTable.='<input type="radio" name="lastSub" value="lastonly" '.$checklastsub.' /> last submission only'."\n".
+	'<input type="radio" name="lastSub" value="last" /> last submission & parts info'."\n".
 	'<input type="radio" name="lastSub" value="datesub" /> by dates and submissions'."\n".
 	'<input type="radio" name="lastSub" value="all" /> all details'."\n".
 	'<input type="hidden" name="section"     value="'.$getsec.'" />'."\n".
@@ -544,7 +544,7 @@ LISTJAVASCRIPT
     $gradeTable.='<input type="button" '."\n".
 	'onClick="javascript:checkSelect(this.form.stuinfo);" '."\n".
 	'value="Next->" />'."\n";
-
+    $gradeTable.='<input type="checkbox" name="checkPlag" checked="on">Check For Plagiarism</input>';
     my (undef, undef, $fullname) = &getclasslist($getsec,'1');  
     $gradeTable.='<table border="0"><tr><td bgcolor="#777777">'.
 	'<table border="0"><tr bgcolor="#e6ffff">';
@@ -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='<hr /><h3><font color="#FF0000">Essay is '.$osim.
-					'% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom).
-					'</font></h3><blockquote><i>'.
-					&keywords_highlight($oessay).'</i></blockquote><hr />';
+				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='<hr /><h3><font color="#FF0000">Essay is '.$osim.
+					    '% similar to an essay by '.&Apache::loncommon::plainname($oname,$odom).
+					    '</font></h3><blockquote><i>'.
+					    &keywords_highlight($oessay).'</i></blockquote><hr />';
+				    }
 				}
 				$lastsubonly.='<tr><td bgcolor="#ffffe6"><b>Part '.
 				    $partid.'</b> <font color="#999999">( ID '.$respid.
@@ -1480,7 +1487,7 @@ KEYWORDS
 				     'this file may contain virusses</font><br />':'').
 				     '<b>Submitted Answer: </b>'.
 				     &cleanRecord($subval,$responsetype,$symb).
-				      '<br /><br />'.$similar."\n"
+				     '<br /><br />'.$similar."\n"
 				     if ($ENV{'form.lastSub'} eq 'lastonly' || 
 					 ($ENV{'form.lastSub'} eq 'hdgrade' && 
 					  $$handgrade{$part} =~ /:yes$/));
@@ -2175,7 +2182,7 @@ sub viewgrades {
 
 #--- call by previous routine to display each student
 sub viewstudentgrade {
-    my ($$url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr) = @_;
+    my ($url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr) = @_;
     my ($uname,$udom) = split(/:/,$student);
     $student=~s/:/_/;
     my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
@@ -2510,7 +2517,6 @@ to this page if the data selected is ins
 $javascript
 </script>
 ENDPICK
-    $request->print(&show_grading_menu_form($symb,$url));
     return '';
 
 }
@@ -2799,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 = ();
@@ -2846,9 +2850,8 @@ 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 ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'});
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    my ($mapUrl, $id, $resUrl)=&Apache::lonnet::decode_symb($ENV{'form.page'});
     my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
 
     my $iterator = $navmap->getIterator($map->map_start(),
@@ -3009,9 +3012,8 @@ 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 ($mapUrl, $id, $resUrl) = split(/___/, $ENV{'form.page'});
+    my $navmap = Apache::lonnavmaps::navmap->new();
+    my ($mapUrl, $id, $resUrl) = &Apache::lonnet::decode_symb( $ENV{'form.page'});
     my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
 
     my $iterator = $navmap->getIterator($map->map_start(),
@@ -3319,7 +3321,7 @@ sub scantron_filter {
 
 sub scantron_process_students {
     my ($r) = @_;
-    my (undef,undef,$sequence)=split(/___/,$ENV{'form.selectpage'});
+    my (undef,undef,$sequence)=&Apache::lonnet::decode_symb($ENV{'form.selectpage'});
     my ($symb,$url)=&get_symb_and_url($r);
     if (!$symb) {return '';}
     my $default_form_data=&defaultFormData($symb,$url);
@@ -3329,7 +3331,7 @@ 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)."<br />");
@@ -3605,7 +3607,7 @@ sub handler {
     my $command=$ENV{'form.command'};
     if (!$url) {
 	my ($temp1,$temp2);
-	($temp1,$temp2,$ENV{'form.url'})=split(/___/,$symb);
+	($temp1,$temp2,$ENV{'form.url'})=&Apache::lonnet::decode_symb($symb);
 	$url = $ENV{'form.url'};
     }
     &send_header($request);