src/UI/Lessons.php
public function getCustomWithInherit($key, $rlid=false) {
        global $CFG;

        $custom = LTIX::ltiCustomGet($key);
        if ( strlen($custom) > 0 ) return $custom;

        if ( $rlid === false ) return false;
        $lti = $this->getLtiByRlid($rlid);
        if ( isset($lti->custom) ) foreach($lti->custom as $custom ) {
            if (isset($custom->key) && isset($custom->value) && $custom->key == $key ) {
                return $custom->value;
            }
        }
        return false;
    }
public function getCustomWithInherit($key, $rlid=false) {
        global $CFG;

        $custom = LTIX::ltiCustomGet($key);
        if ( strlen($custom) > 0 ) return $custom;

        if ( $rlid === false ) return false;
        $lti = $this->getLtiByRlid($rlid);
        if ( isset($lti->custom) ) foreach($lti->custom as $custom ) {
            if (isset($custom->key) && isset($custom->value) && $custom->key == $key ) {
                return $custom->value;
            }
        }
        return false;
    }
public function getCustomWithInherit ( $ key , $ rlid = false ) { global $ CFG ; $ custom = LTIX :: ltiCustomGet ( $ key ) ; if ( strlen ( $ custom ) > 0 ) return $ custom ; if ( $ rlid === false ) return false ; $ lti = $ this -> getLtiByRlid ( $ rlid ) ; if ( isset ( $ lti -> custom ) ) foreach ( $ lti -> custom as $ custom ) { if ( isset ( $ custom -> key ) && isset ( $ custom -> value ) && $ custom -> key == $ key ) { return $ custom -> value ; } } return false ; }
Check if a setting value is in a resource in a Lesson

This solves the problems that (a) most LMS systems do not handle
custom well for Common Cartridge Imports and (b) some systems
do not handle custom at all when links are installed via
ContentItem.  Canvas has this problem for sure and others might
as well.

The solution is to add the resource link from the Lesson as a GET
parameter on the launchurl URL to be a fallback:

https://../mod/zap/?inherit=assn03

Say the tool has custom key of "exercise" that it wants a default
for when the tool has not yet been configured.  First we check
if the LMS sent us a custom parameter and use it if present.

If not, load up the LTI launch for the resource link id (assn03)
in the above example and see if there is a custom parameter set
in that launch and assume it was passed to us.

Sample call:

$assn = Settings::linkGet('exercise');
if ( ! $assn || ! isset($assignments[$assn]) ) {
$rlid = isset($_GET['inherit']) ? $_GET['inherit'] : false;
if ( $rlid && isset($CFG->lessons) ) {
$l = new Lessons($CFG->lessons);
$assn = $l->getCustomWithInherit($rlid, 'exercise');
} else {
$assn = LTIX::ltiCustomGet('exercise');
}
Settings::linkSet('exercise', $assn);
}
Check if a setting value is in a resource in a Lesson