Skip to content

Commit

Permalink
more feedback from PR#2617
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Jordan committed Nov 19, 2024
1 parent f251b04 commit 94c7af0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
6 changes: 3 additions & 3 deletions lib/WeBWorK/ConfigValues.pm
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ sub getConfigValues ($ce) {
},
LTISendScoresAfterDate => {
var => 'LTISendScoresAfterDate',
doc => x('When to send scores to the LMS regardless of status'),
doc => x('Date after which scores will be sent to the LMS'),
doc2 => x(
'<p>This can be set to one of the dates assciated with assignments. For a given assignment, if it is after '
. "the \$LTISendScoresAfterDate, then WeBWorK will send grades.</p><ul><li>For 'course' grade "
Expand All @@ -983,7 +983,7 @@ sub getConfigValues ($ce) {
},
LTISendGradesEarlyThreshold => {
var => 'LTISendGradesEarlyThreshold',
doc => x('Condition under which scores can be sent to an LMS early'),
doc => x('Condition under which scores will be sent early to an LMS'),
doc2 => x(
"<p>This can either be set to a score or set to Attempted. When something triggers a potential grade "
. 'passback, if it is earlier than $LTISendScoresAfterDate, the condition described by this '
Expand Down Expand Up @@ -1197,7 +1197,7 @@ sub getConfigValues ($ce) {
@$configValues,
[
x('LTI'),
map { $LTIConfigValues->{$_} }
map { $LTIConfigValues->{$_} }
grep { defined $LTIConfigValues->{$_} } @{ $ce->{LTIConfigVariables} }
]
);
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ async sub pre_header_initialize ($c) {
&& ($ce->{LTIGradeOnSubmit} && $ce->{LTIGradeMode} eq 'homework'
|| $ce->{LTIGradeOnSubmit}
&& $ce->{LTIGradeMode} eq 'course'
&& can_submit_LMS_score($db, $ce, $effectiveUserID, $db->getMergedSet($effectiveUserID, $setID)))
&& can_submit_LMS_score($db, $ce, $effectiveUserID, $c->{set}))
)
{
my $grader = $ce->{LTI}{ $ce->{LTIVersion} }{grader}->new($c);
Expand Down
10 changes: 4 additions & 6 deletions lib/WeBWorK/Utils/ProblemProcessing.pm
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,10 @@ async sub process_and_log_answer ($c) {
if ($ce->{LTIGradeMode}) {
my $LMSname = $ce->{LTI}{ $ce->{LTIVersion} }{LMS_name};
my $LTIGradeResult = -1;
if (
$ce->{LTIGradeOnSubmit} && $ce->{LTIGradeMode} eq 'homework'
|| $ce->{LTIGradeOnSubmit} && $ce->{LTIGradeMode} eq 'course' && can_submit_LMS_score(
$db, $ce, $problem->user_id, $db->getMergedSet($problem->user_id, $problem->set_id)
)
)
if ($ce->{LTIGradeOnSubmit} && $ce->{LTIGradeMode} eq 'homework'
|| $ce->{LTIGradeOnSubmit}
&& $ce->{LTIGradeMode} eq 'course'
&& can_submit_LMS_score($db, $ce, $problem->user_id, $c->{set}))
{
$LTIGradeResult = 0;
my $grader = $ce->{LTI}{ $ce->{LTIVersion} }{grader}->new($c);
Expand Down
16 changes: 5 additions & 11 deletions lib/WeBWorK/Utils/Sets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,11 @@ sub set_attempted ($db, $userID, $userSet) {
# It counts as "attempted" if there is more than one version.
return 1 if (1 < @versionNums);

# If there is one version, check for an attempted problem. There could also
# be no actual attempted problems, but a score was manually overridden.
# If there is one version, check for an attempted problem.
if (@versionNums) {
my @problemNums = $db->listUserProblems($userID, $setID);
my @problemNums = $db->listProblemVersions($userID, $setID, $versionNums[0]);
my $problem = $db->getMergedProblemVersion($userID, $setID, $versionNums[0], $problemNums[0]);
return 1 if defined $problem && $problem->attempted;
for (@problemNums) {
$problem = $db->getMergedProblemVersion($userID, $setID, $versionNums[0], $_);
return 1 if defined $problem && $problem->status > 0;
}
return 0;
return defined $problem && $problem->attempted ? 1 : 0;
}

# If there are no versions, the test was not attempted.
Expand Down Expand Up @@ -259,7 +253,7 @@ sub can_submit_LMS_score ($db, $ce, $userID, $userSet) {
} else {
($totalRight, $total) = (grade_set($db, $userSet, $userID))[ 0, 1 ];
}
my $score = $total > 1 ? $totalRight / $total : 1;
my $score = $total ? $totalRight / $total : 0;
my $return = { totalRight => $totalRight, total => $total, score => $score };

if ($ce->{LTISendScoresAfterDate} ne 'never') {
Expand All @@ -269,7 +263,7 @@ sub can_submit_LMS_score ($db, $ce, $userID, $userSet) {
} else {
$critical_date = get_LTISendScoresAfterDate($userSet, $ce);
}
$return->{critical_date} = $critical_date;
$return->{criticalDate} = $critical_date;
return $return if after($critical_date);
}

Expand Down

0 comments on commit 94c7af0

Please sign in to comment.