--- loncom/homework/grades.pm 2025/01/18 22:04:36 1.810 +++ loncom/homework/grades.pm 2025/06/28 14:35:00 1.811 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.810 2025/01/18 22:04:36 raeburn Exp $ +# $Id: grades.pm,v 1.811 2025/06/28 14:35:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -881,14 +881,20 @@ sub jscriptNform { -# Given the score (as a number [0-1] and the weight) what is the final -# point value? This function will round to the nearest tenth, third, -# or quarter if one of those is within the tolerance of .00001. +# Given the score (as a number [0-1], the weight, and a posible +# reduction for submission between duedate and overduedate) +# what is the final point value? This function will round to +# the nearest tenth, third, or quarter if one of those is +# within the tolerance of .00001. sub compute_points { - my ($score, $weight) = @_; + my ($score, $weight, $latefrac) = @_; my $tolerance = .00001; my $points = $score * $weight; + if (($latefrac ne '') && + ($latefrac < 1) && ($latefrac >= 0)) { + $points = $points * $latefrac; + } # Check for nearness to 1/x. my $check_for_nearness = sub { @@ -2951,7 +2957,8 @@ sub gradeBox { : ''.&mt('problem weight assigned by computer').''; $wgt = ($wgt > 0 ? $wgt : '1'); my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ? - '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt)); + '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt, + $$record{'resource.'.$partid.'.latefrac'})); my $data_WGT=''."\n"; my $display_part= &get_display_part($partid,$symb); my %last_resets = &get_last_resets($symb,$env{'request.course.id'}, @@ -5419,6 +5426,7 @@ sub viewstudentgrade { foreach my $apart (@$parts) { my ($part,$type) = &split_part_type($apart); my $score=$record{"resource.$part.$type"}; + my $latefrac=$record{"resource.$part.latefrac"}; $result.=''; my ($aggtries,$totaltries); unless (exists($aggregates{$part})) { @@ -5435,7 +5443,7 @@ sub viewstudentgrade { $aggregates{$part} = 1; } if ($type eq 'awarded') { - my $pts = $score eq '' ? '' : &compute_points($score,$$weight{$part}); + my $pts = $score eq '' ? '' : &compute_points($score,$$weight{$part},$latefrac); $result.=''."\n"; $result.='