--- loncom/homework/grades.pm 2024/12/09 21:39:48 1.799 +++ loncom/homework/grades.pm 2024/12/10 04:55:03 1.802 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.799 2024/12/09 21:39:48 raeburn Exp $ +# $Id: grades.pm,v 1.802 2024/12/10 04:55:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1726,7 +1726,7 @@ sub passbacks_for_symb { } sub process_passbacks { - my ($context,$symbs,$cdom,$cnum,$udom,$uname,$weights,$awardeds,$excuseds,$needpb, + my ($context,$symbs,$cdom,$cnum,$udom,$uname,$usec,$weights,$awardeds,$excuseds,$needpb, $skip_passback,$pbsave,$pbids) = @_; if ((ref($needpb) eq 'HASH') && (ref($skip_passback) eq 'HASH') && (ref($pbsave) eq 'HASH')) { my (%weight,%awarded,%excused); @@ -1827,6 +1827,7 @@ sub process_passbacks { 'uname' => $uname, 'udom' => $udom, 'uhome' => $uhome, + 'usec' => $usec, 'pbid' => $pbid, 'pburl' => $pburl, 'pbtype' => $pb{'type'}, @@ -1840,7 +1841,7 @@ sub process_passbacks { 'total_s' => \%total_by_symb, 'possible_s' => \%possible_by_symb, }; - push(@Apache::lonhomework::ltipassback,$ltigrade); + push(@Apache::grades::ltipassback,$ltigrade); next; } my ($total,$possible); @@ -4249,16 +4250,17 @@ sub processHandGrade { } else { $pbcollab{$collaborator}{$part} = [$pts,$wgt]; if ($message ne '') { - my ($baseurl,$showsymb) = - &get_feedurl_and_symb($symb,$collaborator, - $udom); - if ($env{'form.withgrades'.$ctr}) { - $messagetail = " for $restitle"; + my ($baseurl,$showsymb) = + &get_feedurl_and_symb($symb,$collaborator, + $udom); + if ($env{'form.withgrades'.$ctr}) { + $messagetail = " for $restitle"; + } + $msgstatus = + &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message.$messagetail,undef,$baseurl,undef,undef,undef,$showsymb,$restitle); } - $msgstatus = - &Apache::lonmsg::user_normal_msg($collaborator,$udom,$subject,$message.$messagetail,undef,$baseurl,undef,undef,undef,$showsymb,$restitle); - } + } } } } @@ -4560,7 +4562,7 @@ sub saveHandGrade { if (($sendupdate) && (!$submitter)) { if ((ref($needpb) eq 'HASH') && (keys(%{$needpb}))) { - &process_passbacks('handgrade',[$symb],$cdom,$cnum,$domain,$stuname,\%weights, + &process_passbacks('handgrade',[$symb],$cdom,$cnum,$domain,$stuname,$usec,\%weights, \%awardeds,\%excuseds,$needpb,$skip_passback,$pbsave); } } @@ -5649,7 +5651,7 @@ sub editgrades { $updateCtr++; if (keys(%needpb)) { $weights{$symb} = \%weight; - &process_passbacks('editgrades',[$symb],$cdom,$cnum,$udom,$uname,\%weights, + &process_passbacks('editgrades',[$symb],$cdom,$cnum,$udom,$uname,$usec,\%weights, \%awardeds,\%excuseds,\%needpb,\%skip_passback,\%pbsave); } } else { @@ -6178,7 +6180,7 @@ sub csvuploadassign { $request->print('.'); # Remove from grading queue &Apache::bridgetask::remove_from_queue('gradingqueue',$symb,$cdom,$cnum, - $domain,$username); + $domain,$username); $countdone++; if ($passback) { my @parts_in_upload; @@ -6200,7 +6202,7 @@ sub csvuploadassign { $awardeds{$symb}{$part} = $record{"resource.$part.awarded"}; } } - &process_passbacks('csvupload',[$symb],$cdom,$cnum,$domain,$username,\%weights, + &process_passbacks('csvupload',[$symb],$cdom,$cnum,$domain,$username,$usec,\%weights, \%awardeds,\%excuseds,\%needpb,\%skip_passback,\%pbsave); } } else { @@ -6951,7 +6953,6 @@ sub updateGradeByPage { $request->print($hidemsg.$grademsg.$studentTable); if (@updates) { - undef(@Apache::lonhomework::ltipassback); my (@allsymbs,$mapsymb,@recurseup,%parentmapsymbs,%possmappb,%possrespb); @allsymbs = @updates; if (ref($map)) { @@ -7009,13 +7010,14 @@ sub updateGradeByPage { } } my @symbs = keys(%uniqsymbs); - &process_passbacks('updatebypage',\@symbs,$cdom,$cnum,$udom,$uname,\%weights, + &process_passbacks('updatebypage',\@symbs,$cdom,$cnum,$udom,$uname,$usec,\%weights, \%awardeds,\%excuseds,\%needpb,\%skip_passback,\%pbsave,\%pbids); - if (@Apache::lonhomework::ltipassback) { + if (@Apache::grades::ltipassback) { unless ($registered_cleanup) { my $handlers = $request->get_handlers('PerlCleanupHandler'); $request->set_handlers('PerlCleanupHandler' => - [\&Apache::lonhomework::do_ltipassback,@{$handlers}]); + [\&Apache::grades::make_passback,@{$handlers}]); + $registered_cleanup=1; } } } @@ -7023,6 +7025,17 @@ sub updateGradeByPage { return ''; } +sub make_passback { + if (@Apache::grades::ltipassback) { + my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; + my $ip = &Apache::lonnet::get_host_ip($lonhost); + foreach my $item (@Apache::grades::ltipassback) { + &Apache::lonhomework::run_passback($item,$lonhost,$ip); + } + undef(@Apache::grades::ltipassback); + } +} + #-------- end of section for handling grading by page/sequence --------- # #------------------------------------------------------------------- @@ -12807,6 +12820,10 @@ sub handler { &Apache::lonnet::logthis("grades got multiple commands ".join(':',@commands)); } +# -------------------------------------- Flag and buffer for registered cleanup + $registered_cleanup=0; + undef(@Apache::grades::ltipassback); + # see what the symb is my $symb=$env{'form.symb'};