Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tested grade reading and deleting. Fixed bugs.

  • Loading branch information...
commit 60bd82f61d98678b6f0bf6da3b61800290fdd0d2 1 parent 3ff01b2
scriby authored
4  mod/lti/service.php
@@ -38,6 +38,10 @@
38 38
         
39 39
         $ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
40 40
         
  41
+        //Getting the grade requires the context is set
  42
+        $context = get_context_instance(CONTEXT_COURSE, $ltiinstance->course);
  43
+        $PAGE->set_context($context);
  44
+        
41 45
         lti_verify_sourcedid($ltiinstance, $parsed);
42 46
         lti_verify_message($ltiinstance, $rawbody);
43 47
         
5  mod/lti/servicelib.php
@@ -136,7 +136,7 @@ function lti_read_grade($ltiinstance, $userid){
136 136
     
137 137
     $grades = grade_get_grades($ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, $userid);
138 138
     
139  
-    if (isset($grades) && is_array($grades->items[0]->grades)) {
  139
+    if (isset($grades) && isset($grades->items[0]) && is_array($grades->items[0]->grades)) {
140 140
         foreach ($grades->items[0]->grades as $agrade) {
141 141
             $grade = $agrade->grade;
142 142
             break;
@@ -149,6 +149,9 @@ function lti_read_grade($ltiinstance, $userid){
149 149
 }
150 150
 
151 151
 function lti_delete_grade($ltiinstance, $userid){
  152
+    global $CFG;
  153
+    require_once($CFG->libdir . '/gradelib.php');
  154
+    
152 155
     $grade = new stdClass();
153 156
     $grade->userid   = $userid;
154 157
     $grade->rawgrade = null;

0 notes on commit 60bd82f

Please sign in to comment.
Something went wrong with that request. Please try again.