Skip to content

Commit

Permalink
handling "0/0" scores for the LMS
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Jordan committed Nov 19, 2024
1 parent 8f0955f commit 46bc516
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/WeBWorK/Utils/Sets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -245,25 +245,37 @@ sub get_LTISendScoresAfterDate ($set, $ce) {
# Checks if the set is past the LTISendScoresAfterDate or has met the LTISendGradesEarlyThreshold.
# Returns a reference to hash with keys totalRight, total, score, criticalDate if the set has met
# either condition and undef if not.
# If the set is a test, the score "0/0" is treated as 0.
# If the set is not a test, the score "0/0" is treated as 0 if we have not yet reached the
# LTISendScoresAfterDate and have not attempted the set. Otherwise, "0/0" is treated as 1.
sub can_submit_LMS_score ($db, $ce, $userID, $userSet) {
my $totalRight;
my $total;
if ($userSet->assignment_type() =~ /gateway/) {
if ($userSet->assignment_type =~ /gateway/) {
($totalRight, $total) = grade_gateway($db, $userSet->set_id, $userID);
} else {
($totalRight, $total) = (grade_set($db, $userSet, $userID))[ 0, 1 ];
}

my $score = $total ? $totalRight / $total : 0;
my $return = { totalRight => $totalRight, total => $total, score => $score };

if ($ce->{LTISendScoresAfterDate} ne 'never') {
my $critical_date;
if ($userSet->assignment_type() =~ /gateway/) {
if ($userSet->assignment_type =~ /gateway/) {
$critical_date = earliest_gateway_date($db, $ce, $userSet);
} else {
$critical_date = get_LTISendScoresAfterDate($userSet, $ce);
}
$return->{criticalDate} = $critical_date;
if ($total == 0) {
$score = (
$userSet->assignment_type =~ /gateway/
|| ($ce->{LTISendScoresAfterDate} eq 'never'
|| before($critical_date) && !set_attempted($db, $userID, $userSet))
) ? 0 : 1;

}
return $return if after($critical_date);
}

Expand Down

0 comments on commit 46bc516

Please sign in to comment.