Skip to content

Commit 0edb98f

Browse files
committed
LTI 1.1 configure number of digits to round score.
This adds a configuration option `$LTI{v1p1}{round_score_digits}` which sets the number of digits to round the score to before sending it to the LMS. If this is set to a number less than 2 (nearest whole percent), then rounding of the score is disabled. The default is `2` which is current behavior. This was requested in #2785.
1 parent f3abb2f commit 0edb98f

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

conf/authen_LTI_1_1.conf.dist

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ $LTI{v1p1}{LMS_name} = 'the LMS';
1919
$LTI{v1p1}{LMS_url} = '';
2020
#$LTI{v1p1}{LMS_url} = 'https://myschool.edu/lms/';
2121

22+
# This sets the number of decimal digits to round the score (a value between 0 and 1) sent to the LMS.
23+
# A setting of 2 means the score is rounded to 2 digits or the nearest whole percent. Setting this to
24+
# a number less than 2 will disable rounding. Note that there maybe some rounding since floats are
25+
# used to compute and save scores in the database and LMS may round the score received.
26+
$LTI{v1p1}{round_score_digits} = 2;
27+
#$LTI{v1p1}{round_score_digits} = 0; # Disable rounding.
28+
2229
################################################################################################
2330
# LTI 1.1 preferred and fallback source of WW user_id
2431
################################################################################################

lib/WeBWorK/Authen/LTIAdvanced/SubmitGrade.pm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@ async sub submit_set_grade ($self, $userID, $setID, $submittedSet = undef) {
168168

169169
# Submits a score of $score to the lms with $sourcedid as the identifier.
170170
async sub submit_grade ($self, $sourcedid, $score) {
171-
my $c = $self->{c};
172-
my $ce = $c->{ce};
173-
my $db = $c->{db};
171+
my $c = $self->{c};
172+
my $ce = $c->{ce};
173+
my $db = $c->{db};
174+
my $digits = $ce->{LTI}{v1p1}{round_score_digits} // 2;
174175

175-
$score = wwRound(2, $score);
176+
# Disable rounding unless rounding to two or more digits, which is the nearest whole percent.
177+
$score = wwRound($digits, $score) if $digits > 1;
176178

177179
my $request_url = $db->getSettingValue('lis_outcome_service_url');
178180
if (!$request_url) {

0 commit comments

Comments
 (0)