Tsugi

LessonsCartridge
in package

Common Cartridge export from an in-memory Lessons document (v2 items).

Used by course Settings export. Does not rewrite stored lessons JSON.

Canvas's cartridge (wiki_content, canvas_export.txt, module_meta, FILEBASE, $WIKI_REFERENCE$) is the interchange format. The Canvas and Tsugi flavors emit that same zip so Canvas import works today and Tsugi import can later consume a cartridge Canvas itself exported. Do not add Tsugi-only zip shapes to those flavors. Generic (CC 1.2) stays spec CC 1.2. Generic (CC 1.1) and Moodle are the same Generic content as Common Cartridge 1.1.

Table of Contents

Properties

$exportFileResources  : array<string, array{zipPath: string, identifierref: string, listings: int}>
sha256 => array{zipPath:string,identifierref:string,listings:int}
$exportFileZipPaths  : array<string, string>
sha256 / "path:{course path}" => zip path (web_resources/...).
$pendingWikiPages  : array<int, array{html: string, title: string, logical_key: string, sub_module: mixed}>
Wiki pages deferred until files are in the zip so FILEBASE links can use paths.

Methods

addHeadingItem()  : bool
Emit a heading (or legacy header) as a CC item with no resource.
addVideoItem()  : bool
Emit a video as a CC web link, preferring Kaltura when configured.
downloadName()  : mixed
Download basename for the .imscc file, including the export flavor.
exportFlavor()  : mixed
Setup flavor used in the download filename: generic, generic11, moodle, canvas, tsugi, or sakai.
exportFlavorLabels()  : array<string, string>
LMS flavor labels for export dropdowns, including the CC version each flavor writes.
exportTopicMode()  : string
How discussions are written into the cartridge.
moduleCounts()  : array{resources: int, assignments: int, discussions: int, quizzes: int, files: int, pages: int}
summarize()  : array{modules: int, resources: int, assignments: int, discussions: int, quizzes: int, files: int, pages: int}
Counts for the export form.
usesCanvasCartridge()  : bool
Canvas and Tsugi write Canvas's interchange cartridge (same zip contents).
wantsCanvasExtensions()  : mixed
Canvas course_settings / assignment wrappers are LMS extras, not CC 1.2.
writeZip()  : mixed
Write imsmanifest.xml and resource files into an open ZipArchive.
cartridgeFileHref()  : string
cartridgeWikiHref()  : string
Canvas wiki import resolves $WIKI_REFERENCE$/pages/{migration_id}.
countItem()  : mixed
Count one item and its nested items, matching writeZip()/processChildren().
courseFilePathFromHref()  : string|null
Course folder/name from a stored page href (FILEBASE, /files/…, or a live course URL).
coursePageKeyFromHref()  : string|null
Page logical_key from a stored href (FILEBASE, /pages/…, or a live course URL).
customArray()  : array<string, string>
deploymentLaunchUrl()  : string
Launch URL stored on the deployment's registration, for an item whose launch field is empty.
exportContentLaunchUrl()  : string
Launch URL on the content row, for a provisioned item whose lesson item no longer stores one.
exportContentRow()  : array<string, mixed>|null
exportGradable()  : bool
exportLinkIdentifier()  : string|null
Cartridge item identifier for a resource link id. Empty when the id cannot be an XML identifier.
exportResourceLinkId()  : string
Resource link id to write into the cartridge. The lesson item's id, or the id stored on its content row after the tool is provisioned.
fileBaseHref()  : string
Canvas rewrites $IMS-CC-FILEBASE$/{path} against files imported from web_resources/. The token must be followed by a slash, and the path must match the zip path with web_resources/ stripped (spaces/commas intact).
fileSha256()  : string|null
flushCanvasWikiPages()  : mixed
flushGenericPages()  : mixed
Generic CC: pages are HTML files under web_resources/pages/.
flushPendingWikiPages()  : mixed
genericPageHref()  : string
Generic CC has no Pages tool: page links are FILEBASE to web_resources/pages/{key}.html.
gradeLom()  : object
Lesson item plus the graded flag to store in cartridge LOM.
isAssignmentLtiKind()  : mixed
itemHasExportUrl()  : mixed
itemHref()  : mixed
itemsForModule()  : array<int, object>
loadFilePayload()  : array{bytes: string, filename?: string, content_type?: string}|null
loadPagePayload()  : array{title?: string, logical_key?: string, body?: string, html?: string}|null
loadQuiz()  : Quiz1|null
lookupExportZipPath()  : string|null
pendingPageKey()  : string
processChildren()  : mixed
processDiscussion()  : mixed
processFile()  : mixed
Package a Lessons file item as IMS CC webcontent (bytes in the zip).
processHtmlPage()  : mixed
Package a Lessons html_page as IMS CC webcontent.
processItem()  : mixed
processLti()  : mixed
processNativeQuiz()  : mixed
Export a native Quiz1 item as IMS CC QTI 1.2.1. Only quizzes referenced in lessons are included. Missing or invalid quizzes fail the export.
quizExportLinkKey()  : mixed
Resource link id to write for this quiz. The link's stored key, not quiz_id.
rememberExportFilePath()  : mixed
rewriteCartridgeFileLinks()  : string
Point page HTML links at $IMS-CC-FILEBASE$ (and Canvas $WIKI_REFERENCE$ when needed).
urlItemTitle()  : mixed
usesCanvasWikiPages()  : bool
Canvas and Sakai (for now) package pages as wiki_content.

Properties

$exportFileResources

sha256 => array{zipPath:string,identifierref:string,listings:int}

private static array<string, array{zipPath: string, identifierref: string, listings: int}> $exportFileResources = array()

$exportFileZipPaths

sha256 / "path:{course path}" => zip path (web_resources/...).

private static array<string, string> $exportFileZipPaths = array()

$pendingWikiPages

Wiki pages deferred until files are in the zip so FILEBASE links can use paths.

private static array<int, array{html: string, title: string, logical_key: string, sub_module: mixed}> $pendingWikiPages = array()

Methods

addHeadingItem()

Emit a heading (or legacy header) as a CC item with no resource.

public static addHeadingItem(CC $cc_dom, mixed $sub_module, mixed $item[, string|null $parentPath = null ]) : bool

Used by Settings export and legacy /cc/export. Canvas stores these as ContextModuleSubHeader in module_meta.

Parameters
$cc_dom : CC
$sub_module : mixed
$item : mixed
$parentPath : string|null = null
Return values
bool —

true when the item is a heading (even if an empty title skips emit)

addVideoItem()

Emit a video as a CC web link, preferring Kaltura when configured.

public static addVideoItem(ZipArchive $zip, CC $cc_dom, mixed $sub_module, mixed $item[, string|null $parentPath = null ]) : bool

Same preference as Lessons rendering: kaltura_embed + kaltura_id, else a YouTube watch URL. Kaltura links use presentation target modal.

Parameters
$zip : ZipArchive
$cc_dom : CC
$sub_module : mixed
$item : mixed
$parentPath : string|null = null
Return values
bool —

true when the item is a video

downloadName()

Download basename for the .imscc file, including the export flavor.

public static downloadName(mixed $l[, mixed $tsugi_lms = 'generic' ]) : mixed
Parameters
$l : mixed
$tsugi_lms : mixed = 'generic'

exportFlavor()

Setup flavor used in the download filename: generic, generic11, moodle, canvas, tsugi, or sakai.

public static exportFlavor(mixed $tsugi_lms) : mixed
Parameters
$tsugi_lms : mixed

exportFlavorLabels()

LMS flavor labels for export dropdowns, including the CC version each flavor writes.

public static exportFlavorLabels() : array<string, string>
Return values
array<string, string> —

flavor => label

exportTopicMode()

How discussions are written into the cartridge.

public static exportTopicMode(mixed $raw) : string

Default is native CC discussion (LMS topic), not an LTI link.

Parameters
$raw : mixed
Return values
string —

none|lti|lms|lti_grade

moduleCounts()

public static moduleCounts(mixed $module) : array{resources: int, assignments: int, discussions: int, quizzes: int, files: int, pages: int}
Parameters
$module : mixed
Return values
array{resources: int, assignments: int, discussions: int, quizzes: int, files: int, pages: int}

summarize()

Counts for the export form.

public static summarize(mixed $l) : array{modules: int, resources: int, assignments: int, discussions: int, quizzes: int, files: int, pages: int}
Parameters
$l : mixed
Return values
array{modules: int, resources: int, assignments: int, discussions: int, quizzes: int, files: int, pages: int}

usesCanvasCartridge()

Canvas and Tsugi write Canvas's interchange cartridge (same zip contents).

public static usesCanvasCartridge(string $tsugi_lms) : bool

Future Tsugi import should accept this format from Tsugi or from Canvas.

Parameters
$tsugi_lms : string
Return values
bool

wantsCanvasExtensions()

Canvas course_settings / assignment wrappers are LMS extras, not CC 1.2.

public static wantsCanvasExtensions(mixed $tsugi_lms) : mixed

Generic Setup export omits them. Legacy /cc/export is unchanged.

Parameters
$tsugi_lms : mixed

writeZip()

Write imsmanifest.xml and resource files into an open ZipArchive.

public static writeZip(object $l, ZipArchive $zip[, array{tsugi_lms?: string, topic?: string, anchors?: array|false, context_id?: int, load_quiz?: callable, load_file?: callable, load_page?: callable} $options = array() ]) : mixed
Parameters
$l : object

Lessons

$zip : ZipArchive
$options : array{tsugi_lms?: string, topic?: string, anchors?: array|false, context_id?: int, load_quiz?: callable, load_file?: callable, load_page?: callable} = array()

cartridgeFileHref()

private static cartridgeFileHref(string $url, int $context_id[, bool $canvasWiki = true ]) : string
Parameters
$url : string
$context_id : int
$canvasWiki : bool = true

Canvas FILEBASE strips web_resources/; generic keeps it

Return values
string

cartridgeWikiHref()

Canvas wiki import resolves $WIKI_REFERENCE$/pages/{migration_id}.

private static cartridgeWikiHref(string $url) : string

Tsugi stores page links as $IMS-CC-FILEBASE$pages/{logical_key}; leaving that in wiki HTML makes Canvas treat it as a missing course file.

Parameters
$url : string
Return values
string

countItem()

Count one item and its nested items, matching writeZip()/processChildren().

private static countItem(mixed $item, mixed &$resources, mixed &$assignments, mixed &$discussions, mixed &$quizzes, mixed &$files, mixed &$pages) : mixed
Parameters
$item : mixed
$resources : mixed
$assignments : mixed
$discussions : mixed
$quizzes : mixed
$files : mixed
$pages : mixed

courseFilePathFromHref()

Course folder/name from a stored page href (FILEBASE, /files/…, or a live course URL).

private static courseFilePathFromHref(string $url) : string|null
Parameters
$url : string
Return values
string|null

coursePageKeyFromHref()

Page logical_key from a stored href (FILEBASE, /pages/…, or a live course URL).

private static coursePageKeyFromHref(string $url) : string|null
Parameters
$url : string
Return values
string|null

customArray()

private static customArray(mixed $item) : array<string, string>
Parameters
$item : mixed
Return values
array<string, string>

deploymentLaunchUrl()

Launch URL stored on the deployment's registration, for an item whose launch field is empty.

private static deploymentLaunchUrl(int $toolDeploymentId, array{context_id?: int} $options, string $title) : string
Parameters
$toolDeploymentId : int
$options : array{context_id?: int}
$title : string
Return values
string

exportContentLaunchUrl()

Launch URL on the content row, for a provisioned item whose lesson item no longer stores one.

private static exportContentLaunchUrl(object $item, array<string, mixed> $options) : string
Parameters
$item : object
$options : array<string, mixed>
Return values
string

exportContentRow()

private static exportContentRow(object $item, array<string, mixed> $options) : array<string, mixed>|null
Parameters
$item : object
$options : array<string, mixed>
Return values
array<string, mixed>|null

exportGradable()

private static exportGradable(object $item, array<string, mixed> $options) : bool
Parameters
$item : object
$options : array<string, mixed>
Return values
bool

exportLinkIdentifier()

Cartridge item identifier for a resource link id. Empty when the id cannot be an XML identifier.

private static exportLinkIdentifier(string $resourceLinkId) : string|null
Parameters
$resourceLinkId : string
Return values
string|null

exportResourceLinkId()

Resource link id to write into the cartridge. The lesson item's id, or the id stored on its content row after the tool is provisioned.

private static exportResourceLinkId(object $item, array<string, mixed> $options) : string
Parameters
$item : object
$options : array<string, mixed>
Return values
string

fileBaseHref()

Canvas rewrites $IMS-CC-FILEBASE$/{path} against files imported from web_resources/. The token must be followed by a slash, and the path must match the zip path with web_resources/ stripped (spaces/commas intact).

private static fileBaseHref(string $zipPath, bool $stripWebResources) : string

Percent-encoding that path makes Canvas report missing wiki links.

Parameters
$zipPath : string
$stripWebResources : bool

Canvas maps FILEBASE onto files imported from web_resources/

Return values
string

fileSha256()

private static fileSha256(mixed $item) : string|null
Parameters
$item : mixed
Return values
string|null

flushCanvasWikiPages()

private static flushCanvasWikiPages(ZipArchive $zip, CC $cc_dom, array<string, mixed> $options) : mixed
Parameters
$zip : ZipArchive
$cc_dom : CC
$options : array<string, mixed>

flushGenericPages()

Generic CC: pages are HTML files under web_resources/pages/.

private static flushGenericPages(ZipArchive $zip, CC $cc_dom, array<string, mixed> $options) : mixed
Parameters
$zip : ZipArchive
$cc_dom : CC
$options : array<string, mixed>

flushPendingWikiPages()

private static flushPendingWikiPages(ZipArchive $zip, CC $cc_dom, array<string, mixed> $options) : mixed
Parameters
$zip : ZipArchive
$cc_dom : CC
$options : array<string, mixed>

genericPageHref()

Generic CC has no Pages tool: page links are FILEBASE to web_resources/pages/{key}.html.

private static genericPageHref(string $url, array<string, string> $pageZipPaths) : string
Parameters
$url : string
$pageZipPaths : array<string, string>
Return values
string

gradeLom()

Lesson item plus the graded flag to store in cartridge LOM.

private static gradeLom(object $item, array<string, mixed> $options[, string|null $quizLinkKey = null ]) : object

Due dates stay in the course. A quiz is graded. An LTI item is not graded when the lesson says so, or when its content row cannot return a grade and has no grade column.

Parameters
$item : object
$options : array<string, mixed>
$quizLinkKey : string|null = null

Quiz resource link id to store in LOM

Return values
object

isAssignmentLtiKind()

private static isAssignmentLtiKind(mixed $kind) : mixed
Parameters
$kind : mixed

itemHasExportUrl()

private static itemHasExportUrl(mixed $item, mixed $kind) : mixed
Parameters
$item : mixed
$kind : mixed

itemHref()

private static itemHref(mixed $item) : mixed
Parameters
$item : mixed

itemsForModule()

private static itemsForModule(mixed $module) : array<int, object>
Parameters
$module : mixed
Return values
array<int, object>

loadFilePayload()

private static loadFilePayload(mixed $item, array{context_id?: int, load_file?: callable} $options) : array{bytes: string, filename?: string, content_type?: string}|null
Parameters
$item : mixed
$options : array{context_id?: int, load_file?: callable}
Return values
array{bytes: string, filename?: string, content_type?: string}|null

loadPagePayload()

private static loadPagePayload(mixed $item, array{context_id?: int, load_page?: callable} $options) : array{title?: string, logical_key?: string, body?: string, html?: string}|null
Parameters
$item : mixed
$options : array{context_id?: int, load_page?: callable}
Return values
array{title?: string, logical_key?: string, body?: string, html?: string}|null

loadQuiz()

private static loadQuiz(mixed $quiz_id, array{context_id?: int, load_quiz?: callable} $options) : Quiz1|null
Parameters
$quiz_id : mixed
$options : array{context_id?: int, load_quiz?: callable}
Return values
Quiz1|null

lookupExportZipPath()

private static lookupExportZipPath(string $path) : string|null
Parameters
$path : string
Return values
string|null

pendingPageKey()

private static pendingPageKey(array{logical_key?: string} $pending) : string
Parameters
$pending : array{logical_key?: string}
Return values
string

processChildren()

private static processChildren(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom, mixed $topic, array<string|int, mixed> $options) : mixed
Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$topic : mixed
$options : array<string|int, mixed>

processDiscussion()

private static processDiscussion(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom, mixed $topic[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$topic : mixed
$options : array<string|int, mixed> = array()

processFile()

Package a Lessons file item as IMS CC webcontent (bytes in the zip).

private static processFile(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom, array<string|int, mixed> $options) : mixed
Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$options : array<string|int, mixed>

processHtmlPage()

Package a Lessons html_page as IMS CC webcontent.

private static processHtmlPage(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom, array<string|int, mixed> $options) : mixed

Canvas/Sakai: wiki_content. Generic: web_resources/pages/*.html. Legacy html_page items with only an href (no page identity) stay web links.

Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$options : array<string|int, mixed>

processItem()

private static processItem(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom, mixed $topic, array<string|int, mixed> $options) : mixed
Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$topic : mixed
$options : array<string|int, mixed>

processLti()

private static processLti(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$options : array<string|int, mixed> = array()

processNativeQuiz()

Export a native Quiz1 item as IMS CC QTI 1.2.1. Only quizzes referenced in lessons are included. Missing or invalid quizzes fail the export.

private static processNativeQuiz(mixed $item, mixed $module, mixed $sub_module, mixed $zip, mixed $cc_dom, array<string|int, mixed> $options) : mixed
Parameters
$item : mixed
$module : mixed
$sub_module : mixed
$zip : mixed
$cc_dom : mixed
$options : array<string|int, mixed>

quizExportLinkKey()

Resource link id to write for this quiz. The link's stored key, not quiz_id.

private static quizExportLinkKey(object $quiz, array<string, mixed> $options) : mixed
Parameters
$quiz : object
$options : array<string, mixed>

rememberExportFilePath()

private static rememberExportFilePath(string|null $sha, string $path, string $zipPath) : mixed
Parameters
$sha : string|null
$path : string
$zipPath : string

Point page HTML links at $IMS-CC-FILEBASE$ (and Canvas $WIKI_REFERENCE$ when needed).

private static rewriteCartridgeFileLinks(string $html, array<string, mixed> $options, bool $canvasWiki[, array<string, string> $pageZipPaths = array() ]) : string
Parameters
$html : string
$options : array<string, mixed>
$canvasWiki : bool
$pageZipPaths : array<string, string> = array()

logical_key => zip path

Return values
string

urlItemTitle()

private static urlItemTitle(mixed $item, mixed $module, mixed $kind) : mixed
Parameters
$item : mixed
$module : mixed
$kind : mixed

usesCanvasWikiPages()

Canvas and Sakai (for now) package pages as wiki_content.

private static usesCanvasWikiPages(array<string, mixed> $options) : bool

Generic packages them as ordinary web_resources files.

Parameters
$options : array<string, mixed>
Return values
bool

        
On this page

Search results