--- loncom/homework/grades.pm 2006/03/28 00:46:20 1.342
+++ 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.342 2006/03/28 00:46:20 banghart Exp $
+# $Id: grades.pm,v 1.345 2006/04/02 00:17:26 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2362,9 +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)) {
- &version_portfiles(\%record, \%newrecord, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
+ if (%newrecord) {
+ if (@version_parts) {
+ my @changed_keys = &version_portfiles(\%record, \@parts_graded, $env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
+ @newrecord{@changed_keys} = @record{@changed_keys};
}
&Apache::lonnet::cstore(\%newrecord,$symb,
$env{'request.course.id'},$domain,$stuname);
@@ -2504,8 +2505,9 @@ sub get_last_resets {
# ----------- Handles creating versions for portfolio files as answers
sub version_portfiles {
- my ($record, $newrecord, $parts_graded, $courseid, $symb, $domain, $stu_name, $v_flag) = @_;
+ my ($record, $parts_graded, $courseid, $symb, $domain, $stu_name, $v_flag) = @_;
my $version_parts = join('|',@$v_flag);
+ my @returned_keys;
my $parts = join('|', @$parts_graded);
my $portfolio_root = &Apache::loncommon::propath($domain,
$stu_name).
@@ -2530,10 +2532,11 @@ sub version_portfiles {
[$symb,$env{'request.course.id'},'graded']);
}
}
- $$newrecord{$key} = join(',',@versioned_portfiles);
+ $$record{$key} = join(',',@versioned_portfiles);
+ push(@returned_keys,$key);
}
}
- return 'ok';
+ return (@returned_keys);
}
sub get_next_version {
@@ -3507,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); }
@@ -3559,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;} }
@@ -3604,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 ---------
#