@@ -192,7 +192,7 @@ async sub get_access_token ($self) {
192192}
193193
194194# Computes and submits the course grade for userID to the LMS.
195- # The course grade is the average of all sets assigned to the user.
195+ # The course grade is the sum of all (weighted) problems assigned to the user.
196196async sub submit_course_grade ($self , $userID ) {
197197 my $c = $self -> {c };
198198 my $ce = $c -> {ce };
@@ -207,7 +207,7 @@ async sub submit_course_grade ($self, $userID) {
207207 $self -> warning(' LMS user id is not available for this user.' ) unless $user -> lis_source_did;
208208 $self -> warning(' LMS lineitem is not available for the course.' ) unless $lineitem ;
209209
210- return await $self -> submit_grade($user -> lis_source_did, $lineitem , scalar ( grade_all_sets($db , $userID ) ));
210+ return await $self -> submit_grade($user -> lis_source_did, $lineitem , grade_all_sets($db , $userID ));
211211}
212212
213213# Computes and submits the set grade for $userID and $setID to the LMS. For gateways the best score is used.
@@ -225,19 +225,14 @@ async sub submit_set_grade ($self, $userID, $setID) {
225225 $self -> warning(' LMS user id is not available for this user.' ) unless $user -> lis_source_did;
226226 $self -> warning(' LMS lineitem is not available for this set.' ) unless $userSet -> lis_source_did;
227227
228- return await $self -> submit_grade(
229- $user -> lis_source_did,
230- $userSet -> lis_source_did,
231- scalar (
232- $userSet -> assignment_type =~ / gateway/
233- ? grade_gateway($db , $userSet , $userSet -> set_id, $userID )
234- : grade_set($db , $userSet , $userID , 0)
235- )
236- );
228+ return await $self -> submit_grade($user -> lis_source_did, $userSet -> lis_source_did,
229+ $userSet -> assignment_type =~ / gateway/
230+ ? grade_gateway($db , $userSet , $userSet -> set_id, $userID )
231+ : (grade_set($db , $userSet , $userID , 0))[ 0, 1 ]);
237232}
238233
239- # Submits a score of $score to the lms with $sourcedid as the identifier.
240- async sub submit_grade ($self , $LMSuserID , $lineitem , $score ) {
234+ # Submits scoreGiven and scoreMaximum to the lms with $sourcedid as the identifier.
235+ async sub submit_grade ($self , $LMSuserID , $lineitem , $scoreGiven , $scoreMaximum ) {
241236 my $c = $self -> {c };
242237 my $ce = $c -> {ce };
243238
@@ -249,8 +244,6 @@ async sub submit_grade ($self, $LMSuserID, $lineitem, $score) {
249244 # So change $c to be the app instead to get access to the url_for helper.
250245 $c = $c -> {app } if $self -> {post_processing_mode };
251246
252- $score = wwRound(2, $score );
253-
254247 my $ua = Mojo::UserAgent-> new;
255248
256249 if ($ce -> {LTICheckPrior }) {
@@ -281,6 +274,7 @@ async sub submit_grade ($self, $LMSuserID, $lineitem, $score) {
281274 my $priorScore = @$priorData
282275 && $priorData -> [0]{resultMaximum } ? $priorData -> [0]{resultScore } / $priorData -> [0]{resultMaximum } : 0;
283276
277+ my $score = $scoreGiven / $scoreMaximum ;
284278 if (abs($score - $priorScore ) < 0.001) {
285279 $self -> warning(
286280 " LMS grade will NOT be updated as the grade is unchanged. Old score: $priorScore , New score: $score ." );
@@ -302,8 +296,8 @@ async sub submit_grade ($self, $LMSuserID, $lineitem, $score) {
302296 json => {
303297 # This must be in ISO 8601 format with sub-second precision. That is why the Time::HiRes::time is used.
304298 timestamp => Mojo::Date-> new(Time::HiRes::time ())-> to_datetime,
305- scoreGiven => $score ,
306- scoreMaximum => 1 ,
299+ scoreGiven => $scoreGiven ,
300+ scoreMaximum => $scoreMaximum ,
307301 activityProgress => ' Submitted' ,
308302 gradingProgress => ' FullyGraded' ,
309303 userId => $LMSuserID
0 commit comments