Tsugi

Package
in package

Open a Common Cartridge zip and index imsmanifest.xml (CC 1.1 or 1.2).

Does not extract to disk. File hrefs are resolved relative to the manifest directory (some LMS zips nest the cartridge in a folder).

Table of Contents

Constants

MAX_ZIP_ENTRIES  : mixed = 2048
Refuse a zip that lists more files than this (stat only).
MAX_ZIP_ENTRY  : mixed = 16 * 1024 * 1024
Refuse to read one zip member larger than this.
MAX_ZIP_UNCOMPRESSED  : mixed = 64 * 1024 * 1024
Refuse a zip whose declared uncompressed sizes sum past this.

Properties

$base  : string
$identifier  : string
$modules  : array<int, array{identifier: string, title: string, description: ?string, items: list>}>
Organization modules (title + items) for Lessons.
$onlyResourceIds  : array<string, true>|null
When set, importableResources() only returns these resource identifiers.
$path  : string
$resources  : array<int, array<string, mixed>>
$schemaversion  : string
$title  : string
$zip  : ZipArchive|null

Methods

close()  : mixed
describeModules()  : array<int, array{key: string, title: string, counts: array{resources: int, files: int, pages: int, assignments: int, discussions: int, quizzes: int}}>
Module list for the Settings import Select Content tab.
importableResources()  : array<int, array<string, mixed>>
Resources the importer should fingerprint (not Canvas course_settings extras).
moduleSelectKey()  : string
Stable checkbox value for one organization module.
open()  : self
placeholderTitle()  : bool
Canvas writes this on the nested LTI item so the wrapper title is the one people see.
readHref()  : string
readMember()  : string
resolveHref()  : string
resourceById()  : array<string, mixed>|null
restrictToModules()  : mixed
Drop organization modules that were not selected and limit importable resources to identifierrefs those modules still point at.
shouldSkip()  : bool
assertZipBudget()  : mixed
attachItems()  : mixed
attachUnreferencedResources()  : mixed
Resources left out of a real organization still need a module so Select Content can show them. An organization with no items is rejected earlier.
childItems()  : array<int, DOMElement>
childTitle()  : string
dirName()  : string
findManifestName()  : string
firstLocalText()  : string
flattenOrgItem()  : array<int, array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}>
Canvas wraps a graded LTI link in an assignment item and nests the real link under it with the title "(hidden)". Keep the nested link, in that spot, and use the wrapper's title.
inheritWrapper()  : array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}
manifestTitle()  : string
nameCandidates()  : array<int, string>
organizationHasItems()  : mixed
True when some item in the organization points at a resource.
orgItem()  : array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}
parseManifest()  : mixed
parseOrganization()  : array<int, array{identifier: string, title: string, description: ?string, items: list>}>
preferNonCcQuizFiles()  : array<string, array<string, mixed>>
Canvas New Quizzes leaves assessment_qti.xml empty and puts the items in a dependency's non_cc_assessments file. Read that file instead.

Constants

MAX_ZIP_ENTRIES

Refuse a zip that lists more files than this (stat only).

public mixed MAX_ZIP_ENTRIES = 2048

MAX_ZIP_ENTRY

Refuse to read one zip member larger than this.

public mixed MAX_ZIP_ENTRY = 16 * 1024 * 1024

MAX_ZIP_UNCOMPRESSED

Refuse a zip whose declared uncompressed sizes sum past this.

public mixed MAX_ZIP_UNCOMPRESSED = 64 * 1024 * 1024

Properties

$base

public string $base = ''

Directory prefix of imsmanifest.xml inside the zip

$identifier

public string $identifier = ''

$modules

Organization modules (title + items) for Lessons.

public array<int, array{identifier: string, title: string, description: ?string, items: list>}> $modules = array()

$onlyResourceIds

When set, importableResources() only returns these resource identifiers.

public array<string, true>|null $onlyResourceIds = null

$path

public string $path = ''

Path used to open the zip (for zip_sha256).

$resources

public array<int, array<string, mixed>> $resources = array()

$schemaversion

public string $schemaversion = ''

$zip

public ZipArchive|null $zip = null

Methods

describeModules()

Module list for the Settings import Select Content tab.

public describeModules() : array<int, array{key: string, title: string, counts: array{resources: int, files: int, pages: int, assignments: int, discussions: int, quizzes: int}}>
Return values
array<int, array{key: string, title: string, counts: array{resources: int, files: int, pages: int, assignments: int, discussions: int, quizzes: int}}>

importableResources()

Resources the importer should fingerprint (not Canvas course_settings extras).

public importableResources() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

moduleSelectKey()

Stable checkbox value for one organization module.

public static moduleSelectKey(array<string, mixed> $mod, int $index) : string
Parameters
$mod : array<string, mixed>
$index : int
Return values
string

open()

public static open(string $path) : self
Parameters
$path : string
Return values
self

placeholderTitle()

Canvas writes this on the nested LTI item so the wrapper title is the one people see.

public static placeholderTitle(mixed $title) : bool
Parameters
$title : mixed
Return values
bool

readHref()

public readHref(string $href) : string
Parameters
$href : string

Manifest file href

Return values
string

readMember()

public readMember(string $name) : string
Parameters
$name : string

Zip member path

Return values
string

resolveHref()

public resolveHref(string $href) : string
Parameters
$href : string
Return values
string

resourceById()

public resourceById(string $id) : array<string, mixed>|null
Parameters
$id : string
Return values
array<string, mixed>|null

restrictToModules()

Drop organization modules that were not selected and limit importable resources to identifierrefs those modules still point at.

public restrictToModules(array<int, string> $keys) : mixed
Parameters
$keys : array<int, string>

shouldSkip()

public static shouldSkip(string $type, string $href) : bool
Parameters
$type : string
$href : string
Return values
bool

assertZipBudget()

private assertZipBudget() : mixed

attachItems()

private attachItems(DOMDocument $dom, array<string, array<string, mixed>> &$byId) : mixed
Parameters
$dom : DOMDocument
$byId : array<string, array<string, mixed>>

attachUnreferencedResources()

Resources left out of a real organization still need a module so Select Content can show them. An organization with no items is rejected earlier.

private attachUnreferencedResources() : mixed

childItems()

private static childItems(DOMElement $el) : array<int, DOMElement>
Parameters
$el : DOMElement
Return values
array<int, DOMElement>

childTitle()

private static childTitle(DOMElement $item) : string
Parameters
$item : DOMElement
Return values
string

dirName()

private static dirName(string $path) : string
Parameters
$path : string
Return values
string

findManifestName()

private findManifestName() : string
Return values
string

firstLocalText()

private static firstLocalText(DOMDocument $dom, mixed $localName) : string
Parameters
$dom : DOMDocument
$localName : mixed
Return values
string

flattenOrgItem()

Canvas wraps a graded LTI link in an assignment item and nests the real link under it with the title "(hidden)". Keep the nested link, in that spot, and use the wrapper's title.

private static flattenOrgItem(DOMElement $el) : array<int, array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}>
Parameters
$el : DOMElement
Return values
array<int, array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}>

inheritWrapper()

private static inheritWrapper(array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string} $child, array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string} $wrapper) : array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}
Parameters
$child : array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}
$wrapper : array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}
Return values
array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}

manifestTitle()

private static manifestTitle(DOMDocument $dom) : string
Parameters
$dom : DOMDocument
Return values
string

nameCandidates()

private static nameCandidates(string $name) : array<int, string>
Parameters
$name : string
Return values
array<int, string>

organizationHasItems()

True when some item in the organization points at a resource.

private static organizationHasItems(DOMElement $org) : mixed

A placeholder such as Canvas LearningModules, with no identifierref, does not count.

Parameters
$org : DOMElement

orgItem()

private static orgItem(DOMElement $el) : array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}
Parameters
$el : DOMElement
Return values
array{identifier: string, identifierref: string, title: string, heading: bool, description: ?string, icon: ?string, href_source: ?string, target: ?string}

parseManifest()

private parseManifest(string $xml) : mixed
Parameters
$xml : string

parseOrganization()

private parseOrganization(DOMDocument $dom) : array<int, array{identifier: string, title: string, description: ?string, items: list>}>
Parameters
$dom : DOMDocument
Return values
array<int, array{identifier: string, title: string, description: ?string, items: list>}>

preferNonCcQuizFiles()

Canvas New Quizzes leaves assessment_qti.xml empty and puts the items in a dependency's non_cc_assessments file. Read that file instead.

private preferNonCcQuizFiles(array<string, array<string, mixed>> $byId) : array<string, array<string, mixed>>
Parameters
$byId : array<string, array<string, mixed>>
Return values
array<string, array<string, mixed>>

        
On this page

Search results