class Lessons

Properties

$lessons All the lessons
$module The individual module
$anchor
$position
$resource_links Index by resource_link

Methods

getSetting($key, $default = false)

get a setting for the lesson

header($buffer = false)

emit the header material

__construct($name = 'lessons.json', $anchor = null, $index = null)

No description

static 
adjustArray($entry)

Make non-array into an array and adjust paths

isSingle()

Indicate we are in a single lesson

getModuleByAnchor($anchor)

Get a module associated with an anchor

getLtiByRlid($resource_link_id)

Get an LTI or Discussion associated with a resource link ID

getModuleByRlid($resource_link_id)

Get a module associated with a resource link ID

render($buffer = false)

No description

static 
absolute_url_ref($url)

No description

static 
expandLink($url)

No description

static 
nostyleUrl($title, $url)

No description

static 
nostyleLink($title, $url)

No description

renderSingle($buffer = false)

No description

renderAll($buffer = false)

No description

renderAssignments($allgrades, $alldates, $buffer = false)

No description

static 
makeUrlResource($type, $title, $url)

No description

static 
getUrlResources($module)

No description

renderBadges($allgrades, $buffer = false)

No description

renderDiscussions($buffer = false)

No description

footer($buffer = false)

No description

getCustomWithInherit($key, $rlid = false)

Check if a setting value is in a resource in a Lesson

Details

at line 40
getSetting($key, $default = false)

get a setting for the lesson

Parameters

$key
$default

at line 50
header($buffer = false)

emit the header material

Parameters

$buffer

at line 107
__construct($name = 'lessons.json', $anchor = null, $index = null)

Parameters

$name
$anchor
$index

at line 247
static adjustArray($entry)

Make non-array into an array and adjust paths

Parameters

$entry

at line 262
isSingle()

Indicate we are in a single lesson

at line 269
getModuleByAnchor($anchor)

Get a module associated with an anchor

Parameters

$anchor

at line 280
getLtiByRlid($resource_link_id)

Get an LTI or Discussion associated with a resource link ID

Parameters

$resource_link_id

at line 306
getModuleByRlid($resource_link_id)

Get a module associated with a resource link ID

Parameters

$resource_link_id

at line 326
render($buffer = false)

Parameters

$buffer

at line 334
static absolute_url_ref($url)

Parameters

$url

Parameters

$url

at line 360
static nostyleUrl($title, $url)

Parameters

$title
$url

Parameters

$title
$url

at line 387
renderSingle($buffer = false)

Parameters

$buffer

at line 747
renderAll($buffer = false)

Parameters

$buffer

at line 785
renderAssignments($allgrades, $alldates, $buffer = false)

Parameters

$allgrades
$alldates
$buffer

at line 845
static makeUrlResource($type, $title, $url)

Parameters

$type
$title
$url

at line 882
static getUrlResources($module)

Parameters

$module

at line 914
renderBadges($allgrades, $buffer = false)

Parameters

$allgrades
$buffer

at line 1047
renderDiscussions($buffer = false)

Parameters

$buffer

Parameters

$buffer

at line 1243
getCustomWithInherit($key, $rlid = 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);
}

Parameters

$key
$rlid