From 22457bc3c3233f9e4dda1dc30078a7b6c8bce8ca Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Wed, 13 Nov 2024 22:11:55 -0800 Subject: [PATCH] various feedback from PR#2617 --- conf/authen_LTI.conf.dist | 6 +++--- lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm | 6 +++--- .../Authen/LTIAdvantage/SubmitGrade.pm | 1 - lib/WeBWorK/ContentGenerator/GatewayQuiz.pm | 6 ++++-- lib/WeBWorK/Utils/ProblemProcessing.pm | 3 ++- lib/WeBWorK/Utils/Sets.pm | 20 ++++++++----------- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/conf/authen_LTI.conf.dist b/conf/authen_LTI.conf.dist index 3b8e41db68..f7d57d6986 100644 --- a/conf/authen_LTI.conf.dist +++ b/conf/authen_LTI.conf.dist @@ -185,14 +185,14 @@ $LTIGradeOnSubmit = 1; # periodically update student grades on the LMS on its own. For all three possible triggers for # grades to be passed to the LMS, $LTISendScoresAfterDate and $LTISendGradesEarlyThreshold can # affect what is sent. $LTISendScoresAfterDate can be set to 'open_date', 'reduced_scoring_date', -# 'close_date', 'answer_date', or 'never'. For a given assignment, if it is *after* the +# 'due_date', 'answer_date', or 'never'. For a given assignment, if it is *after* the # $LTISendScoresAfterDate, then WeBWorK will send grades. # - For 'course' grade passback mode, the assignment will be included in the overall course # grade calculation. # - For 'homework' grade passback mode, the assignemnt's score will be sent. # If $LTISendScoresAfterDate = 'reduced_scoring_date' and an assignent has no reduced_scoring_date -# or reduced scoring is disabled for that assignment, the fallback is to use the close_date. +# or reduced scoring is disabled for that assignment, the fallback is to use the due_date. # For a given assignment, if it is *before* the $LTISendScoresAfterDate, WeBWorK *may* send a # score to the LMS depending on $LTISendGradesEarlyThreshold. This variable can either be the @@ -208,7 +208,7 @@ $LTIGradeOnSubmit = 1; #$LTISendScoresAfterDate = 'open_date'; $LTISendScoresAfterDate = 'reduced_scoring_date'; -#$LTISendScoresAfterDate = 'close_date'; +#$LTISendScoresAfterDate = 'due_date'; #$LTISendScoresAfterDate = 'answer_date'; #$LTISendScoresAfterDate = 'never'; diff --git a/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm b/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm index 8af7145682..b90fe02388 100644 --- a/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm +++ b/lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm @@ -30,7 +30,6 @@ use Digest::SHA qw(sha1_base64); use WeBWorK::Debug; use WeBWorK::Utils qw(wwRound); -use WeBWorK::Utils::DateTime qw(after before); use WeBWorK::Utils::Sets qw(grade_set grade_gateway grade_all_sets can_submit_LMS_score); # This package contains utilities for submitting grades to the LMS @@ -307,8 +306,9 @@ EOS # See: https://webwork.maa.org/moodle/mod/forum/discuss.php?d=5002 debug("LMS grade will be updated. sourcedid: $sourcedid; Old score: $oldScore; New score: $score") if $ce->{debug_lti_grade_passback}; - } elsif (abs($score - $oldScore) < 0.001 - && ($score != 1 || $oldScore == 1) + } elsif ($oldScore ne '' + || abs($score - $oldScore) < 0.001 + && ($score != 1 || $oldScore ne '' && $oldScore == 1) && ($score != 0 || $oldScore ne '' || $nullEqualsZero)) { # LMS has essentially the same score, no reason to update it diff --git a/lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm b/lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm index c3ffcd8d6b..b41f15ffbe 100644 --- a/lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm +++ b/lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm @@ -39,7 +39,6 @@ use Time::HiRes; use WeBWorK::Debug; use WeBWorK::Utils qw(wwRound); -use WeBWorK::Utils::DateTime qw(after before); use WeBWorK::Utils::Sets qw(grade_set grade_gateway grade_all_sets can_submit_LMS_score); # This package contains utilities for submitting grades to the LMS via LTI 1.3. diff --git a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm index e8117ddc0c..5d5516f537 100644 --- a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -1028,8 +1028,10 @@ async sub pre_header_initialize ($c) { $c->{submitAnswers} && $will{recordAnswers} && $ce->{LTIGradeMode} - && ($ce->{LTIGradeOnSubmit} eq 'homework_always' && $ce->{LTIGradeMode} eq 'homework' - || $ce->{LTIGradeOnSubmit} && can_submit_LMS_score($db, $ce, $effectiveUserID, $setID)) + && ($ce->{LTIGradeOnSubmit} && $ce->{LTIGradeMode} eq 'homework' + || $ce->{LTIGradeOnSubmit} + && $ce->{LTIGradeMode} eq 'course' + && can_submit_LMS_score($db, $ce, $effectiveUserID, $setID)) ) { my $grader = $ce->{LTI}{ $ce->{LTIVersion} }{grader}->new($c); diff --git a/lib/WeBWorK/Utils/ProblemProcessing.pm b/lib/WeBWorK/Utils/ProblemProcessing.pm index 76836dd861..dd6a8c752f 100644 --- a/lib/WeBWorK/Utils/ProblemProcessing.pm +++ b/lib/WeBWorK/Utils/ProblemProcessing.pm @@ -253,8 +253,9 @@ async sub process_and_log_answer ($c) { if ($ce->{LTIGradeMode}) { my $LMSname = $ce->{LTI}{ $ce->{LTIVersion} }{LMS_name}; my $LTIGradeResult = -1; - if ($ce->{LTIGradeOnSubmit} eq 'homework_always' && $ce->{LTIGradeMode} eq 'homework' + if ($ce->{LTIGradeOnSubmit} && $ce->{LTIGradeMode} eq 'homework' || $ce->{LTIGradeOnSubmit} + && $ce->{LTIGradeMode} eq 'course' && can_submit_LMS_score($db, $ce, $problem->user_id, $problem->set_id)) { $LTIGradeResult = 0; diff --git a/lib/WeBWorK/Utils/Sets.pm b/lib/WeBWorK/Utils/Sets.pm index e7c0c9b809..b71f17379b 100644 --- a/lib/WeBWorK/Utils/Sets.pm +++ b/lib/WeBWorK/Utils/Sets.pm @@ -246,21 +246,17 @@ sub grade_all_sets ($db, $ce, $studentName) { } sub get_LTISendScoresAfterDate ($set, $ce) { - my $dateType = $ce->{LTISendScoresAfterDate}; - my $date; - if ($dateType eq 'open_date') { - $date = $set->open_date; - } elsif ($dateType eq 'reduced_scoring_date') { - $date = - ($ce->{pg}{ansEvalDefaults}{enableReducedScoring} + if ($ce->{LTISendScoresAfterDate} eq 'open_date') { + return $set->open_date; + } elsif ($ce->{LTISendScoresAfterDate} eq 'reduced_scoring_date') { + return ($ce->{pg}{ansEvalDefaults}{enableReducedScoring} && $set->enable_reduced_scoring && $set->reduced_scoring_date) ? $set->reduced_scoring_date : $set->due_date; - } elsif ($dateType eq 'due_date') { - $date = $set->due_date; - } elsif ($dateType eq 'answer_date') { - $date = $set->answer_date; + } elsif ($ce->{LTISendScoresAfterDate} eq 'due_date') { + return $set->due_date; + } elsif ($ce->{LTISendScoresAfterDate} eq 'answer_date') { + return $set->answer_date; } - return $date; } # Checks if the set is past the LTISendScoresAfterDate or has met the LTISendGradesEarlyThreshold