- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
sub deprecate_marks
{
my ($marks, $task) = @_;
# дополнительное задание -- не уменьшаем оценку
$_->{days_late} < 0 ? $_->{days_late} = 0 : undef for @$marks;
$task->{half_life} or return ($marks->[0] || {})->{points};
my ($dep_points, $prev_points) = (0, 0);
for my $m (reverse @$marks)
{
# Раньше вычиталось dep_points, что приводило к необоснованному завышению оценки.
# Чтобы не менять старые данные, исправляем ошибку только для новых заданий.
my $p = $task->{after_marks_fix} > 0 ? $prev_points : $dep_points;
my $diff = max($m->{points} - $p, 0);
$prev_points = $m->{points};
my $dep_coeff = $task->{half_life} / ($m->{days_late} + $task->{half_life});
$dep_points += $diff * max(($task->{deprecation_limit} || 10) / 100, $dep_coeff);
$m->{dep_points} = sprintf '%.1f', $dep_points;
}
$dep_points;
}