[LON-CAPA-cvs] cvs: loncom /lti ltipassback.pm

raeburn raeburn at source.lon-capa.org
Fri Dec 15 12:07:09 EST 2017


raeburn		Fri Dec 15 17:07:09 2017 EDT

  Modified files:              
    /loncom/lti	ltipassback.pm 
  Log:
  - Bug 6754 LON-CAPA as LTI Consumer
  - Scores passed back - solved is correct_by_passback or incorrect_by_passback 
  - A try is recorded when a score is passed back. 
  
  
Index: loncom/lti/ltipassback.pm
diff -u loncom/lti/ltipassback.pm:1.4 loncom/lti/ltipassback.pm:1.5
--- loncom/lti/ltipassback.pm:1.4	Tue Dec 12 02:13:21 2017
+++ loncom/lti/ltipassback.pm	Fri Dec 15 17:07:09 2017
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # LTI Consumer Module to receive grades passed back by Provider 
 #
-# $Id: ltipassback.pm,v 1.4 2017/12/12 02:13:21 raeburn Exp $
+# $Id: ltipassback.pm,v 1.5 2017/12/15 17:07:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -226,7 +226,7 @@
         $resulttype =~ s/(^\s+|\s+)$//g;
     } else {
         $resulttype = 'decimal';
-    } 
+    }
     $result = $params->{'result_resultscore_textstring'};
     $result =~ s/(^\s+|\s+)$//g;
     my $posslang = $params->{'result_resultscore_language'};
@@ -270,19 +270,24 @@
             my %newrecord=();
             my $reckey = 'resource.0.solved'; 
             my %record = &Apache::lonnet::restore($symb,$cdom.'_'.$cnum,$udom,$uname);
+            my $tries = 0;
+            if ($record{'resource.0.tries'} =~ /^\d$/) {
+                $tries = $record{'resource.0.tries'};
+            }
             if ($record{'resource.0.awarded'} ne $pcf) {
                 $newrecord{'resource.0.awarded'}  = $pcf;
             }
             if ($pcf == 0) {
-                if ($record{$reckey} ne 'incorrect_by_override') {
-                    $newrecord{$reckey} = 'incorrect_by_override';
+                if ($record{$reckey} ne 'incorrect_by_passback') {
+                    $newrecord{$reckey} = 'incorrect_by_passback';
                 }
             } else {
-                if ($record{$reckey} ne 'correct_by_override') {
-                    $newrecord{$reckey} = 'correct_by_override';
+                if ($record{$reckey} ne 'correct_by_passback') {
+                    $newrecord{$reckey} = 'correct_by_passback';
                 }
             }
             if (%newrecord) {
+                $newrecord{'resource.0.tries'} = 1 + $tries;
                 $env{'request.course.id'} = $cdom.'_'.$cnum;
                 my $result = &Apache::lonnet::cstore(\%newrecord,$symb,$cdom.'_'.$cnum,
                                                      $udom,$uname);
@@ -293,6 +298,8 @@
                     $errors{25} = 1;
                     &invalid_request($r,$params,\%errors);
                 }
+            } else {
+                &success($r,$params->{'sourcedid'},$resulttype,$result,$lang);
             }
         } else {
             $errors{26} = 1;




More information about the LON-CAPA-cvs mailing list