Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tested grade reading and deleting. Fixed bugs.

  • Loading branch information...
commit 60bd82f61d98678b6f0bf6da3b61800290fdd0d2 1 parent 3ff01b2
@scriby scriby authored
Showing with 8 additions and 1 deletion.
  1. +4 −0 mod/lti/service.php
  2. +4 −1 mod/lti/servicelib.php
View
4 mod/lti/service.php
@@ -38,6 +38,10 @@
$ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
+ //Getting the grade requires the context is set
+ $context = get_context_instance(CONTEXT_COURSE, $ltiinstance->course);
+ $PAGE->set_context($context);
+
lti_verify_sourcedid($ltiinstance, $parsed);
lti_verify_message($ltiinstance, $rawbody);
View
5 mod/lti/servicelib.php
@@ -136,7 +136,7 @@ function lti_read_grade($ltiinstance, $userid){
$grades = grade_get_grades($ltiinstance->course, LTI_ITEM_TYPE, LTI_ITEM_MODULE, $ltiinstance->id, $userid);
- if (isset($grades) && is_array($grades->items[0]->grades)) {
+ if (isset($grades) && isset($grades->items[0]) && is_array($grades->items[0]->grades)) {
foreach ($grades->items[0]->grades as $agrade) {
$grade = $agrade->grade;
break;
@@ -149,6 +149,9 @@ function lti_read_grade($ltiinstance, $userid){
}
function lti_delete_grade($ltiinstance, $userid){
+ global $CFG;
+ require_once($CFG->libdir . '/gradelib.php');
+
$grade = new stdClass();
$grade->userid = $userid;
$grade->rawgrade = null;
Please sign in to comment.
Something went wrong with that request. Please try again.