--- loncom/homework/grades.pm 2025/01/18 05:20:01 1.596.2.12.2.60.2.8 +++ loncom/homework/grades.pm 2025/01/18 21:29:42 1.596.2.12.2.60.2.9 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.596.2.12.2.60.2.8 2025/01/18 05:20:01 raeburn Exp $ +# $Id: grades.pm,v 1.596.2.12.2.60.2.9 2025/01/18 21:29:42 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4461,7 +4461,8 @@ sub processHandGrade { #---- Save the score and award for each student, if changed sub saveHandGrade { - my ($request,$symb,$stuname,$domain,$newflg,$submitter,$part,$queueable,$needpb,$skip_passback,$pbsave) = @_; + my ($request,$symb,$stuname,$domain,$newflg,$submitter, + $part,$queueable,$needpb,$skip_passback,$pbsave) = @_; my @version_parts; my $usec = &Apache::lonnet::getsection($domain,$stuname, $env{'request.course.id'}); @@ -4469,7 +4470,7 @@ sub saveHandGrade { my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$domain,$stuname); my @parts_graded; my %newrecord = (); - my ($pts,$wgt,$totchg,$sendupdate) = ('','',0,0); + my ($pts,$wgt,$totchg,$sendupdate,$poss_pb) = ('','',0,0,0); my %aggregate = (); my $aggregateflag = 0; if ($env{'form.HIDE'.$newflg}) { @@ -4477,13 +4478,19 @@ sub saveHandGrade { my $numchgs = &makehidden($version,$parts,\%record,$symb,$domain,$stuname,1); $totchg += $numchgs; } + if ((ref($needpb) eq 'HASH') && (keys(%{$needpb}))) { + $poss_pb = 1; + } my (%weights,%awardeds,%excuseds); my @parts = split(/:/,$env{'form.partlist'.$newflg}); foreach my $new_part (@parts) { #collaborator ($submitter may vary for different parts) if ($submitter && $new_part ne $part) { next; } my $dropMenu = $env{'form.GD_SEL'.$newflg.'_'.$new_part}; - if ($env{'form.WGT'.$newflg.'_'.$new_part} eq '') { + if ($poss_pb) { + $weights{$symb}{$new_part} = + &Apache::lonnet::EXT('resource.'.$new_part.'.weight',$symb,$udom,$uname); + } elsif ($env{'form.WGT'.$newflg.'_'.$new_part} eq '') { $weights{$symb}{$new_part} = 1; } else { $weights{$symb}{$new_part} = $env{'form.WGT'.$newflg.'_'.$new_part}; @@ -4594,12 +4601,9 @@ sub saveHandGrade { &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate, $cdom,$cnum); } - if (($sendupdate || $totchg) && (!$submitter)) { - if ((ref($needpb) eq 'HASH') && - (keys(%{$needpb}))) { - &process_passbacks('handgrade',[$symb],$cdom,$cnum,$domain,$stuname,$usec,\%weights, - \%awardeds,\%excuseds,$needpb,$skip_passback,$pbsave); - } + if (($sendupdate || $totchg) && (!$submitter) && ($poss_pb)) { + &process_passbacks('handgrade',[$symb],$cdom,$cnum,$domain,$stuname,$usec,\%weights, + \%awardeds,\%excuseds,$needpb,$skip_passback,$pbsave); } return ('',$pts,$wgt,$totchg,$sendupdate); }