[LON-CAPA-cvs] cvs: loncom /homework grades.pm /interface loncreatecourse.pm /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 30 Mar 2004 20:46:24 -0000


www		Tue Mar 30 15:46:24 2004 EDT

  Modified files:              
    /loncom/homework	grades.pm 
    /loncom/interface	loncreatecourse.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  * Store an encryption key in course environment, to be used for receipts
  and eventually URL encryption
  * Modify receipt algorithm 2 to use this key and also a stored key prefix.
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.183 loncom/homework/grades.pm:1.184
--- loncom/homework/grades.pm:1.183	Thu Mar 18 23:20:24 2004
+++ loncom/homework/grades.pm	Tue Mar 30 15:46:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.183 2004/03/19 04:20:24 albertel Exp $
+# $Id: grades.pm,v 1.184 2004/03/30 20:46:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -511,7 +511,7 @@
     my $request  = shift;
 
     my $courseid = $ENV{'request.course.id'};
-    my $receipt  = unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).'-'.
+    my $receipt  = &Apache::lonnet::recprefix($courseid).'-'.
 	$ENV{'form.receipt'};
     $receipt     =~ s/[^\-\d]//g;
     my $url      = $ENV{'form.url'};
@@ -4441,17 +4441,18 @@
 
     $result.='<table width="100%" border=0>';
     $result.='<tr bgcolor="#ffffe6"><td>'.
-	'<input type="button" onClick="javascript:checkChoice(this.form,\'3\',\'csvform\');" value="Upload" />'.
-	' scores from file </td></tr>'."\n";
+	'<input type="button" onClick="javascript:checkChoice(this.form,\'3\',\'csvform\');" value="'.&mt('Upload').'" />'.
+	' '.&mt('scores from file').' </td></tr>'."\n";
 
     $result.='<tr bgcolor="#ffffe6"valign="top"><td colspan="2">'.
 	'<input type="button" onClick="javascript:checkChoice(this.form,\'4\',\'scantron_selectphase\');'.
-	'" value="Grade" /> scantron forms</td></tr>'."\n";
+	'" value="'.&mt('Grade').'" /> scantron forms</td></tr>'."\n";
 
     if ((&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) && ($symb)) {
 	$result.='<tr bgcolor="#ffffe6"valign="top"><td>'.
-	    '<input type="button" onClick="javascript:checkChoice(this.form,\'5\',\'verify\');" value="Verify" />'.
-	    ' submission Receipt no: '.unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).
+	    '<input type="button" onClick="javascript:checkChoice(this.form,\'5\',\'verify\');" value="'.&mt('Verify').'" />'.
+	    ' '.&mt('receipt').': '.
+	    &Apache::lonnet::recprefix($ENV{'request.course.id'}).
 	    '-<input type="text" name="receipt" size="4" onChange="javascript:checkReceiptNo(this.form,\'OK\')">'.
 	    '</td></tr>'."\n";
     } 
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.52 loncom/interface/loncreatecourse.pm:1.53
--- loncom/interface/loncreatecourse.pm:1.52	Fri Feb 27 12:53:05 2004
+++ loncom/interface/loncreatecourse.pm	Tue Mar 30 15:46:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.52 2004/02/27 17:53:05 albertel Exp $
+# $Id: loncreatecourse.pm,v 1.53 2004/03/30 20:46:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -681,6 +681,11 @@
     #
     $cenv{'rndseed'}=&Apache::lonnet::latest_rnd_algorithm_id();;
     $cenv{'receiptalg'}=&Apache::lonnet::latest_receipt_algorithm_id();;
+    #
+    # The encryption code and receipt prefix for this course
+    #
+    $cenv{'internal.encseed'}=$Apache::lonnet::perlvar{'lonReceipt'}.$$.time.int(rand(9999));
+    $cenv{'internal.encpref'}=100+int(9*rand(99));
     #
     # By default, use standard grading
     $cenv{'grading'} = 'standard';
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.479 loncom/lonnet/perl/lonnet.pm:1.480
--- loncom/lonnet/perl/lonnet.pm:1.479	Fri Mar 19 11:45:25 2004
+++ loncom/lonnet/perl/lonnet.pm	Tue Mar 30 15:46:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.479 2004/03/19 16:45:25 albertel Exp $
+# $Id: lonnet.pm,v 1.480 2004/03/30 20:46:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4460,15 +4460,37 @@
     return 'receipt2';
 }
 
+sub recunique {
+    my $fucourseid=shift;
+    my $unique;
+    if ($ENV{"course.$fucourseid.receiptalg"} eq 'receipt2') {
+	$unique=$ENV{"course.$fucourseid.internal.encseed"};
+    } else {
+	$unique=$perlvar{'lonReceipt'};
+    }
+    return unpack("%32C*",$unique);
+}
+
+sub recprefix {
+    my $fucourseid=shift;
+    my $prefix;
+    if ($ENV{"course.$fucourseid.receiptalg"} eq 'receipt2') {
+	$prefix=$ENV{"course.$fucourseid.internal.encpref"};
+    } else {
+	$prefix=$perlvar{'lonHostID'};
+    }
+    return unpack("%32C*",$prefix);
+}
+
 sub ireceipt {
     my ($funame,$fudom,$fucourseid,$fusymb,$part)=@_;
     my $cuname=unpack("%32C*",$funame);
     my $cudom=unpack("%32C*",$fudom);
     my $cucourseid=unpack("%32C*",$fucourseid);
     my $cusymb=unpack("%32C*",$fusymb);
-    my $cunique=unpack("%32C*",$perlvar{'lonReceipt'});
+    my $cunique=&recunique($fucourseid);
     my $cpart=unpack("%32S*",$part);
-    my $return =unpack("%32C*",$perlvar{'lonHostID'}).'-';
+    my $return =&recprefix($fucourseid).'-';
     if ($ENV{"course.$fucourseid.receiptalg"} eq 'receipt2' ||
 	$ENV{'request.state'} eq 'construct') {
 	&Apache::lonxml::debug("doing receipt2  using parts $cpart, uname $cuname and udom $cudom gets  ".($cpart%$cuname).