Skip to content

Commit

Permalink
various feedback from PR#2617
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Jordan committed Nov 16, 2024
1 parent 8964a0c commit 22457bc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
6 changes: 3 additions & 3 deletions conf/authen_LTI.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -208,7 +208,7 @@ $LTIGradeOnSubmit = 1;

#$LTISendScoresAfterDate = 'open_date';
$LTISendScoresAfterDate = 'reduced_scoring_date';
#$LTISendScoresAfterDate = 'close_date';
#$LTISendScoresAfterDate = 'due_date';
#$LTISendScoresAfterDate = 'answer_date';
#$LTISendScoresAfterDate = 'never';

Expand Down
6 changes: 3 additions & 3 deletions lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/WeBWorK/Authen/LTIAdvantage/SubmitGrade.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/WeBWorK/Utils/ProblemProcessing.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 8 additions & 12 deletions lib/WeBWorK/Utils/Sets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22457bc

Please sign in to comment.