--- loncom/homework/grades.pm 2006/03/28 17:54:44 1.343
+++ loncom/homework/grades.pm 2006/04/02 00:17:26 1.345
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.343 2006/03/28 17:54:44 banghart Exp $
+# $Id: grades.pm,v 1.345 2006/04/02 00:17:26 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2362,12 +2362,10 @@ sub saveHandGrade {
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- if (scalar(keys(%newrecord)) > 0) {
- if (scalar(@version_parts)) {
+ if (%newrecord) {
+ if (@version_parts) {
my @changed_keys = &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
- foreach my $key(@changed_keys) {
- $newrecord{$key} = $record{$key};
- }
+ @newrecord{@changed_keys} = @record{@changed_keys};
}
&Apache::lonnet::cstore(\%newrecord,$symb,
$env{'request.course.id'},$domain,$stuname);
@@ -3512,6 +3510,7 @@ sub csvuploadassign {
my ($request)= @_;
my ($symb)=&get_symb($request);
if (!$symb) {return '';}
+ my $error_msg = '';
&Apache::loncommon::load_tmp_file($request);
my @gradedata = &Apache::loncommon::upfile_record_sep();
if ($env{'form.noFirstLine'}) { shift(@gradedata); }
@@ -3564,12 +3563,20 @@ sub csvuploadassign {
my $part=$1;
my $wgt =&Apache::lonnet::EXT('resource.'.$part.'.weight',
$symb,$domain,$username);
- $entries{$fields{$dest}}=~s/\s//g;
- my $pcr=$entries{$fields{$dest}} / $wgt;
- my $award='correct_by_override';
- $grades{"resource.$part.awarded"}=$pcr;
- $grades{"resource.$part.solved"}=$award;
- $points{$part}=1;
+ if ($wgt) {
+ $entries{$fields{$dest}}=~s/\s//g;
+ my $pcr=$entries{$fields{$dest}} / $wgt;
+ my $award='correct_by_override';
+ $grades{"resource.$part.awarded"}=$pcr;
+ $grades{"resource.$part.solved"}=$award;
+ $points{$part}=1;
+ } else {
+ $error_msg = "
" .
+ &mt("Some point values were assigned"
+ ." for problems with a weight "
+ ."of zero. These values were "
+ ."ignored.");
+ }
} else {
if ($dest=~/stores_(.*)_awarded/) { if ($points{$1}) {next;} }
if ($dest=~/stores_(.*)_solved/) { if ($points{$1}) {next;} }
@@ -3609,7 +3616,7 @@ sub csvuploadassign {
}
$request->print("
\n");
$request->print(&show_grading_menu_form($symb));
- return '';
+ return $error_msg;
}
#------------- end of section for handling csv file upload ---------
#