--- loncom/homework/grades.pm 2004/02/09 22:37:54 1.174
+++ loncom/homework/grades.pm 2004/03/31 05:23:59 1.185
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.174 2004/02/09 22:37:54 albertel Exp $
+# $Id: grades.pm,v 1.185 2004/03/31 05:23:59 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -511,7 +511,7 @@ sub verifyreceipt {
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'};
@@ -526,18 +526,27 @@ sub verifyreceipt {
my ($string,$contents,$matches) = ('','',0);
my (undef,undef,$fullname) = &getclasslist('all','0');
-
+
+ my $receiptparts=0;
+ if ($ENV{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; }
+ my $parts=['0'];
+ if ($receiptparts) { ($parts)=&response_type($url,$symb); }
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
my ($uname,$udom)=split(/\:/);
- if ($receipt eq
- &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) {
- $contents.='
'."\n".
- ''.$$fullname{$_}.' | '."\n".
- ' '.$uname.' | '.
- ' '.$udom.' |
'."\n";
-
- $matches++;
+ foreach my $part (@$parts) {
+ if ($receipt eq &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb,$part)) {
+ $contents.=' '."\n".
+ ''.$$fullname{$_}.' | '."\n".
+ ' '.$uname.' | '.
+ ' '.$udom.' | ';
+ if ($receiptparts) {
+ $contents.=' '.$part.' | ';
+ }
+ $contents.='
'."\n";
+
+ $matches++;
+ }
}
}
if ($matches == 0) {
@@ -550,8 +559,11 @@ sub verifyreceipt {
''."\n".
' Fullname | '."\n".
' Username | '."\n".
- ' Domain |
'."\n".
- $contents.
+ ' Domain | ';
+ if ($receiptparts) {
+ $string.=' Problem Part | ';
+ }
+ $string.=''."\n".$contents.
'
'."\n";
}
return $string.&show_grading_menu_form($symb,$url);
@@ -1283,10 +1295,10 @@ sub gradeBox {
my $ctr = 0;
$result.=''."\n");
}
# essay grading message center
@@ -3843,7 +3857,7 @@ sub scantron_getfile {
} else {
$scanlines{'skipped'}=[(split("\n",$lines,-1))];
}
- my @tmp=&Apache::lonnet::dump('scantrondata',$cdom,$cname);
+ my @tmp=&Apache::lonnet::dump('nohist_scantrondata',$cdom,$cname);
if ($tmp[0] =~ /^(error:|no_such_host)/) { @tmp=(); }
my %scan_data = @tmp;
return (\%scanlines,\%scan_data);
@@ -3875,7 +3889,7 @@ sub scantron_putfile {
&lonnet_putfile(join("\n",@{$scanlines->{'skipped'}}),
$prefix.'skipped_'.
$ENV{'form.scantron_selectfile'});
- &Apache::lonnet::put('scantrondata',$scan_data,$cdom,$cname);
+ &Apache::lonnet::put('nohist_scantrondata',$scan_data,$cdom,$cname);
}
sub scantron_get_line {
@@ -3992,7 +4006,7 @@ sub scantron_get_correction {
'scantron_username','scantron_domain'));
$r->print(": ");
$r->print("\n@".
- &Apache::loncommon::select_dom_form(undef,'scantron_domain'));
+ &Apache::loncommon::select_dom_form($ENV{'request.role..domain'},'scantron_domain'));
$r->print('');
} elsif ($error eq 'doublebubble') {
@@ -4190,7 +4204,8 @@ sub scantron_upload_scantron_data {
my ($r)=@_;
$r->print(&Apache::loncommon::coursebrowser_javascript($ENV{'request.role.domain'}));
my $select_link=&Apache::loncommon::selectcourse_link('rules','courseid',
- 'domainid');
+ 'domainid',
+ 'coursename');
my $domsel=&Apache::loncommon::select_dom_form($ENV{'request.role.domain'},
'domainid');
my $default_form_data=&defaultFormData(&get_symb_and_url($r,1));
@@ -4207,12 +4222,14 @@ sub scantron_upload_scantron_data {
UPLOAD
@@ -4221,11 +4238,21 @@ UPLOAD
sub scantron_upload_scantron_data_save {
my($r)=@_;
+ my ($symb,$url)=&get_symb_and_url($r,1);
+ my $doanotherupload=
+ '
'."\n";
if (!&Apache::lonnet::allowed('usc',$ENV{'form.domainid'}) &&
!&Apache::lonnet::allowed('usc',
$ENV{'form.domainid'}.'_'.$ENV{'form.courseid'})) {
$r->print("You are not allowed to upload Scantron data to the requested course.
");
- $r->print(&show_grading_menu_form(&get_symb_and_url($r)));
+ if ($symb) {
+ $r->print(&show_grading_menu_form($symb,$url));
+ } else {
+ $r->print($doanotherupload);
+ }
return '';
}
$r->print("Doing upload to ".$ENV{'form.courseid'}."
");
@@ -4246,17 +4273,20 @@ sub scantron_upload_scantron_data_save {
# See if there is anything left
unless ($fname) { return 'error: no uploaded file'; }
$fname='scantron_orig_'.$fname;
- $r->print(&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},
- $ENV{'form.domainid'},
- $home,'upfile',$fname));
- my ($symb,$url)=&get_symb_and_url($r);
+ if (length($ENV{'form.upfile'}) < 2) {
+ $r->print("Error: The file you attempted to upload, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"').", contained no information. Please check that you entered the correct filename.");
+ } else {
+ my $result=&Apache::lonnet::finishuserfileupload($ENV{'form.courseid'},$ENV{'form.domainid'},$home,'upfile',$fname);
+ if ($result =~ m|^/uploaded/|) {
+ $r->print("Success: Successfully uploaded ".(length($ENV{'form.upfile'})-1)." bytes of data into location ".$result."");
+ } else {
+ $r->print("Error: An error (".$result.") occured when attempting to upload the file, ".&HTML::Entities::encode($ENV{'form.upfile.filename'},'<>&"')."");
+ }
+ }
if ($symb) {
- $r->print(&show_grading_menu_form(&get_symb_and_url($r)));
+ $r->print(&show_grading_menu_form($symb,$url));
} else {
- $r->print('
'."\n");
+ $r->print($doanotherupload);
}
return '';
}
@@ -4411,17 +4441,18 @@ GRADINGMENUJS
$result.='