src/Core/Result.php
public static function gradeGet($row=false, &$debug_log=false) {
        global $CFG;

        $PDOX = LTIX::getConnection();

        $key_key = LTIX::ltiParameter('key_key');
        $secret = LTIX::decrypt_secret(LTIX::ltiParameter('secret'));
        if ( $row !== false ) {
            $sourcedid = isset($row['sourcedid']) ? $row['sourcedid'] : false;
            $service = isset($row['service']) ? $row['service'] : false;
            // Fall back to session if it is missing
            if ( $service === false ) $service = LTIX::ltiParameter('service');
            $result_id = isset($row['result_id']) ? $row['result_id'] : false;
        } else {
            $sourcedid = LTIX::ltiParameter('sourcedid');
            $service = LTIX::ltiParameter('service');
            $result_id = LTIX::ltiParameter('result_id');
        }

        if ( $key_key == false || $secret === false ||
            $sourcedid === false || $service === false ) {
            error_log("Result::gradeGet is missing required data");
            return false;
        }

        $grade = LTI::getPOXGrade($sourcedid, $service, $key_key, $secret, $debug_log);

        if ( is_string($grade) ) return $grade;

        // UPDATE our local copy of the server's view of the grade
        if ( $result_id !== false ) {
            $stmt = $PDOX->queryDie(
                "UPDATE {$CFG->dbprefix}lti_result SET server_grade = :server_grade,
                    retrieved_at = NOW() WHERE result_id = :RID",
                array( ':server_grade' => $grade, ":RID" => $result_id)
            );
        }
        return $grade;
    }
public static function gradeGet($row=false, &$debug_log=false) {
        global $CFG;

        $PDOX = LTIX::getConnection();

        $key_key = LTIX::ltiParameter('key_key');
        $secret = LTIX::decrypt_secret(LTIX::ltiParameter('secret'));
        if ( $row !== false ) {
            $sourcedid = isset($row['sourcedid']) ? $row['sourcedid'] : false;
            $service = isset($row['service']) ? $row['service'] : false;
            // Fall back to session if it is missing
            if ( $service === false ) $service = LTIX::ltiParameter('service');
            $result_id = isset($row['result_id']) ? $row['result_id'] : false;
        } else {
            $sourcedid = LTIX::ltiParameter('sourcedid');
            $service = LTIX::ltiParameter('service');
            $result_id = LTIX::ltiParameter('result_id');
        }

        if ( $key_key == false || $secret === false ||
            $sourcedid === false || $service === false ) {
            error_log("Result::gradeGet is missing required data");
            return false;
        }

        $grade = LTI::getPOXGrade($sourcedid, $service, $key_key, $secret, $debug_log);

        if ( is_string($grade) ) return $grade;

        // UPDATE our local copy of the server's view of the grade
        if ( $result_id !== false ) {
            $stmt = $PDOX->queryDie(
                "UPDATE {$CFG->dbprefix}lti_result SET server_grade = :server_grade,
                    retrieved_at = NOW() WHERE result_id = :RID",
                array( ':server_grade' => $grade, ":RID" => $result_id)
            );
        }
        return $grade;
    }
public static function gradeGet ( $ row = false , & $ debug_log = false ) { global $ CFG ; $ PDOX = LTIX :: getConnection ( ) ; $ key_key = LTIX :: ltiParameter ( 'key_key' ) ; $ secret = LTIX :: decrypt_secret ( LTIX :: ltiParameter ( 'secret' ) ) ; if ( $ row !== false ) { $ sourcedid = isset ( $ row [ 'sourcedid' ] ) ? $ row [ 'sourcedid' ] : false ; $ service = isset ( $ row [ 'service' ] ) ? $ row [ 'service' ] : false ; // Fall back to session if it is missing if ( $ service === false ) $ service = LTIX :: ltiParameter ( 'service' ) ; $ result_id = isset ( $ row [ 'result_id' ] ) ? $ row [ 'result_id' ] : false ; } else { $ sourcedid = LTIX :: ltiParameter ( 'sourcedid' ) ; $ service = LTIX :: ltiParameter ( 'service' ) ; $ result_id = LTIX :: ltiParameter ( 'result_id' ) ; } if ( $ key_key == false || $ secret === false || $ sourcedid === false || $ service === false ) { error_log ( "Result::gradeGet is missing required data" ) ; return false ; } $ grade = LTI :: getPOXGrade ( $ sourcedid , $ service , $ key_key , $ secret , $ debug_log ) ; if ( is_string ( $ grade ) ) return $ grade ; // UPDATE our local copy of the server's view of the grade if ( $ result_id !== false ) { $ stmt = $ PDOX -> queryDie ( "UPDATE {$CFG->dbprefix}lti_result SET server_grade = :server_grade,
                    retrieved_at = NOW() WHERE result_id = :RID" , array ( ':server_grade' => $ grade , ":RID" => $ result_id ) ) ; } return $ grade ; }
Load the grade for a particular row and update our local copy

Call the right LTI service to retrieve the server's grade and
update our local cached copy of the server_grade and the date
retrieved. This routine pulls the key and secret from the LTIX
session to avoid crossing cross tennant boundaries.

TODO: Add LTI 2.x support for the JSON style services to this

@param $row An optional array with the data that has the result_id, sourcedid,
and service (url) if this is not present, the data is pulled from the LTI
session for the current user/link combination.
@param $debug_log An (optional) array (by reference) that returns the
steps that were taken.
Each entry is an array with the [0] element a message and an optional [1]
element as some detail (i.e. like a POST body)

@return mixed If this work this returns a float.  If not you get
a string with an error.
Load the grade for a particular row and update our local copy