Tsugi

CC extends TsugiDOM
in package

This class allows us to produce an IMS Common Cartridge (1.2 by default, 1.1 for Moodle).

Version strings, namespaces, and resource types are centralized here so a cartridge cannot advertise one CC version in the manifest while emitting another version's QTI or web-link identifiers. Pass PROFILE_11 for Moodle.

Usage to Create a ZIP file:

$zip = new ZipArchive();
if ($zip->open('cc.zip', ZipArchive::CREATE)!==TRUE) {
$cc_dom = new CC();
$cc_dom->set_title('Web Applications for Everybody');
$cc_dom->set_description('Awesome MOOC to learn PHP, MySQL, and JavaScript.');
$module = $cc_dom->add_module('Week 1');
$sub_module = $cc_dom->add_sub_module($module, 'Part 1');
$cc_dom->zip_add_url_to_module($zip, $sub_module, 'WA4E', 'https://www.wa4e.com');
$custom = array('exercise' => 'http_headers.php');
$cc_dom->zip_add_lti_to_module($zip, $sub_module, 'RRC',
    'https://www.wa4e.com/tools/autograder/index.php', $custom);
$zip->addFromString('imsmanifest.xml',$cc_dom->saveXML());
$zip->close();

Table of Contents

Constants

ASSOCIATED_CONTENT_TYPE  : mixed = 'associatedcontent/imscc_xmlv1p2/learning-appli...
ASSOCIATED_CONTENT_TYPE_11  : mixed = 'associatedcontent/imscc_xmlv1p1/learning-appli...
BLTI_NS  : mixed = 'http://www.imsglobal.org/xsd/imsbasiclti_v1p0'
CC_11_NS  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p1/imscp_v...
CC_1_1_CP  : mixed = self::CC_NS
CC_NS  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p2/imscp_v...
item_xpath  : mixed = '/*/*[2]/*/*'
LOM_11_NS  : mixed = 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource'
LOM_CATALOG_DOCUMENT_TARGET  : mixed = 'tsugi.launch_presentation_document_target'
LOM general.identifier catalog; LTI launch_presentation_document_target values.
LOM_CATALOG_DUE  : mixed = 'tsugi.due'
LOM general.identifier catalog; lesson due day YYYY-MM-DD. Read on import. Not written on export.
LOM_CATALOG_GRADABLE  : mixed = 'tsugi.gradable'
LOM general.identifier catalog; 1 when the item is graded, 0 when it is not.
LOM_CATALOG_HREF_SOURCE  : mixed = 'tsugi.href_source'
LOM general.identifier catalog for web-link URL vs course-content.
LOM_CATALOG_ICON  : mixed = 'tsugi.icon'
LOM general.identifier catalog for an explicit Font Awesome icon class.
LOM_CATALOG_RESOURCE_LINK  : mixed = 'tsugi.resource_link_id'
LOM general.identifier catalog; Quiz1 resource link id to keep across a course import.
lom_general_xpath  : mixed = '/*/*[1]/lomimscc:lom/lomimscc:general'
LOM_NS  : mixed = 'http://ltsc.ieee.org/xsd/imsccv1p2/LOM/resource'
LOMIMSCC_11_NS  : mixed = 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest'
LOMIMSCC_NS  : mixed = 'http://ltsc.ieee.org/xsd/imsccv1p2/LOM/manifest'
LTI_TYPE  : mixed = 'imsbasiclti_xmlv1p0'
LTICM_NS  : mixed = 'http://www.imsglobal.org/xsd/imslticm_v1p0'
LTICP_NS  : mixed = 'http://www.imsglobal.org/xsd/imslticp_v1p0'
metadata_xpath  : mixed = '/*/*[1]'
PROFILE_11  : mixed = '1.1'
PROFILE_12  : mixed = '1.2'
QTI_ASSESSMENT_TYPE  : mixed = 'imsqti_xmlv1p2/imscc_xmlv1p2/assessment'
IMS CC 1.2 QTI 1.2.1 assessment resource type.
QTI_ASSESSMENT_TYPE_11  : mixed = 'imsqti_xmlv1p2/imscc_xmlv1p1/assessment'
QTI_NS  : mixed = 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2'
QTI_SCHEMA_LOCATION  : mixed = 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2 ht...
QTI_SCHEMA_LOCATION_11  : mixed = 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2 ht...
resource_xpath  : mixed = '/*/*[3]'
SCHEMA_NAME  : mixed = 'IMS Common Cartridge'
TOPIC_11_NS  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v...
TOPIC_NS  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p2/imsdt_v...
TOPIC_SCHEMA_LOCATION  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p2/imsdt_v...
TOPIC_SCHEMA_LOCATION_11  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v...
TOPIC_TYPE  : mixed = 'imsdt_xmlv1p2'
TOPIC_TYPE_11  : mixed = 'imsdt_xmlv1p1'
VERSION  : mixed = '1.2.0'
VERSION_11  : mixed = '1.1.0'
WEB_LINK_TYPE  : mixed = 'imswl_xmlv1p2'
WEB_LINK_TYPE_11  : mixed = 'imswl_xmlv1p1'
WEBCONTENT_TYPE  : mixed = 'webcontent'
WL_11_NS  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v...
WL_NS  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p2/imswl_v...
WL_SCHEMA_LOCATION  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p2/imswl_v...
WL_SCHEMA_LOCATION_11  : mixed = 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v...

Properties

$canvas_extensions  : mixed
When false, do not emit Canvas course_settings or assignment wrappers.
$canvas_items  : mixed
$canvas_module_meta  : mixed
$canvas_modules  : mixed
$canvas_quiz_wrapper  : mixed
Setup Canvas export only: assessment_meta.xml, non_cc_assessments, dependency.
$cc_profile  : string
CC profile for this document: PROFILE_11 or PROFILE_12.
$currentNamespace  : mixed
$last_file  : mixed
$last_identifier  : mixed
$last_identifierref  : mixed
$last_type  : mixed
$resource_count  : mixed
$idGenerator  : CCIdentifier
Identifier generator for deterministic, hash-based identifiers
$modulePaths  : array<string|int, mixed>
Map of DOMNode to module path for tracking parent paths
$webResourceNames  : array<string, true>
Zip paths already used under web_resources/ in this cartridge.

Methods

__construct()  : mixed
add_child()  : mixed
add_child_ns()  : mixed
add_header_item()  : The
Add a header item as a Canvas sub-header (no resource, just metadata)
add_identifierref_item()  : DOMNode
Extra module item that points at an existing resource (same identifierref).
add_item_lom_description()  : bool
Attach CC 1.2 LOM to an organization item (description plus Tsugi identifiers).
add_last_item_lom()  : bool
Attach LOM to the most recently added organization item.
add_lti_link()  : The
Add an LTI link resource item
add_module()  : the
Adds a module to the manifest
add_qti_assessment()  : string
Add a QTI 1.2.1 assessment resource item to the manifest.
add_resource_item()  : DOMNode
Add a resource to the manifest.
add_resource_only()  : string
Add a resource to the manifest without creating a module item.
add_sub_module()  : the
Adds a sub module to a module
add_topic()  : mixed
add_web_link()  : mixed
associatedContentType()  : mixed
canvasNewTabForWindowTarget()  : bool
Canvas module_meta new_tab from windowTarget, else $default.
ccNs()  : mixed
delete_children()  : mixed
delete_children_ns()  : mixed
delete_tag()  : mixed
delete_tag_ns()  : mixed
disable_canvas_extensions()  : mixed
Drop Canvas-only extensions so the cartridge is spec CC only.
documentTargetFromLesson()  : string|null
LTI launch_presentation_document_target from a lesson/item, or null to omit.
dump_dom_levels()  : mixed
dump_dom_list()  : mixed
dump_dom_node()  : mixed
get_element()  : mixed
get_tag()  : mixed
get_tag_ns()  : mixed
injectCanvasWikiMetas()  : string
Canvas binds a wiki page to its manifest resource through <meta name="identifier">, which must equal the resource identifier.
isCc11()  : mixed
lessonTargetFromDocumentTarget()  : string|null
Tsugi lesson target from an LTI document_target or IMS windowTarget, or null.
lessonTargetFromWindowTarget()  : string|null
Tsugi lesson target from an IMS webLink windowTarget, or null.
lomDescriptionFromItem()  : string|null
LOM general.description text from an organization item, or null.
lomIdentifiersFromItem()  : array<string, string>
catalog => entry from this organization item's own LOM identifiers.
lomIdentifiersFromLesson()  : array<string, string>
Extra LOM identifier catalog/entry pairs from a lesson/module.
lomImsccNs()  : mixed
organizationDescription()  : string|null
Non-empty lesson/module description for organization-item LOM metadata.
organizationDue()  : string|null
Lesson due day (YYYY-MM-DD) from a lesson/module or a raw value, or null.
organizationGradable()  : bool|null
Whether a lesson item is graded, or null when the source does not say.
organizationHrefSource()  : string|null
Web-link href source: url or course, or null if unset/invalid.
organizationIcon()  : string|null
Explicit Font Awesome icon class from a lesson/module, or null.
organizationResourceLinkId()  : string|null
Quiz resource link id to keep on import, or null.
prettyXML()  : mixed
profileForFlavor()  : string
CC 1.1 for Moodle and Generic 1.1 export; everyone else is CC 1.2.
qtiAssessmentType()  : mixed
qtiSchemaLocation()  : mixed
replace_text()  : mixed
replace_text_ns()  : mixed
reserveWebResourcePath()  : string
Reserve a unique web_resources/ path before writing bytes (page-to-page FILEBASE).
schemaVersion()  : mixed
set_description()  : mixed
set_namespace()  : mixed
set_title()  : mixed
topicNs()  : mixed
topicSchemaLocation()  : mixed
topicType()  : mixed
webLinkNs()  : mixed
webLinkSchemaLocation()  : mixed
webLinkType()  : mixed
windowTargetFromLesson()  : string|null
IMS webLink url/@windowTarget from a lesson/item target, or null to omit.
zip_add_canvas_module_meta()  : mixed
Add the course_settings/module_meta.xml to the manifest and ZIP
zip_add_canvas_quiz_wrapper()  : mixed
Canvas-only: assessment_meta.xml, a same-bytes non_cc_assessments copy, and the manifest dependency. Canvas selective import discovers the quiz from the non_cc file on the metadata resource.
zip_add_file_at_path_to_module()  : string
Add webcontent at an already-reserved zip path.
zip_add_file_listing_to_module()  : DOMNode
Another Lessons listing of a file already in the cartridge.
zip_add_file_to_module()  : string
Add a webcontent file to the module and store the bytes in the ZIP.
zip_add_lti_outcome_to_module()  : mixed
zip_add_lti_to_module()  : mixed
zip_add_qti_assessment_to_module()  : string
Add a QTI assessment to the module and write the XML into the ZIP.
zip_add_topic_to_module()  : mixed
zip_add_url_to_module()  : mixed
zip_add_wiki_listing_to_module()  : DOMNode
Another Lessons listing of a wiki page already in the cartridge.
zip_add_wiki_page_to_module()  : string
Add a Canvas-style wiki page (wiki_content/*.html) as IMS CC webcontent.
zip_finish_qti_assessment()  : mixed
Write QTI bytes, optional Canvas quiz wrapper, and module_meta item.
fixedIdentifier()  : mixed
generate_canvas_assignment_xml()  : string
Generate Canvas assignment XML
identifierTaken()  : mixed
lessonTargetValue()  : string|null
lessonType()  : mixed
manifestSkeleton()  : string
Empty-ish manifest matching this profile (sample items are stripped in the constructor).
organizationItemByIdentifier()  : DOMElement|null
Organization item with this identifier, or null.
resource_by_identifier()  : mixed
uniqueNamedPath()  : mixed
uniqueWebResourcePath()  : mixed
Safe unique path under web_resources/ for an in-cartridge file.
uniqueWikiContentPath()  : mixed
Safe unique path under wiki_content/ for a Canvas wiki page.

Constants

ASSOCIATED_CONTENT_TYPE

public mixed ASSOCIATED_CONTENT_TYPE = 'associatedcontent/imscc_xmlv1p2/learning-application-resource'

ASSOCIATED_CONTENT_TYPE_11

public mixed ASSOCIATED_CONTENT_TYPE_11 = 'associatedcontent/imscc_xmlv1p1/learning-application-resource'

BLTI_NS

public mixed BLTI_NS = 'http://www.imsglobal.org/xsd/imsbasiclti_v1p0'

CC_11_NS

public mixed CC_11_NS = 'http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1'

CC_1_1_CP

Use CC_NS. Same URI; name kept for older callers.

public mixed CC_1_1_CP = self::CC_NS

CC_NS

public mixed CC_NS = 'http://www.imsglobal.org/xsd/imsccv1p2/imscp_v1p1'

item_xpath

public mixed item_xpath = '/*/*[2]/*/*'

LOM_11_NS

public mixed LOM_11_NS = 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource'

LOM_CATALOG_DOCUMENT_TARGET

LOM general.identifier catalog; LTI launch_presentation_document_target values.

public mixed LOM_CATALOG_DOCUMENT_TARGET = 'tsugi.launch_presentation_document_target'

LOM_CATALOG_DUE

LOM general.identifier catalog; lesson due day YYYY-MM-DD. Read on import. Not written on export.

public mixed LOM_CATALOG_DUE = 'tsugi.due'

LOM_CATALOG_GRADABLE

LOM general.identifier catalog; 1 when the item is graded, 0 when it is not.

public mixed LOM_CATALOG_GRADABLE = 'tsugi.gradable'

LOM_CATALOG_HREF_SOURCE

LOM general.identifier catalog for web-link URL vs course-content.

public mixed LOM_CATALOG_HREF_SOURCE = 'tsugi.href_source'

LOM_CATALOG_ICON

LOM general.identifier catalog for an explicit Font Awesome icon class.

public mixed LOM_CATALOG_ICON = 'tsugi.icon'

LOM general.identifier catalog; Quiz1 resource link id to keep across a course import.

public mixed LOM_CATALOG_RESOURCE_LINK = 'tsugi.resource_link_id'

lom_general_xpath

public mixed lom_general_xpath = '/*/*[1]/lomimscc:lom/lomimscc:general'

LOM_NS

public mixed LOM_NS = 'http://ltsc.ieee.org/xsd/imsccv1p2/LOM/resource'

LOMIMSCC_11_NS

public mixed LOMIMSCC_11_NS = 'http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest'

LOMIMSCC_NS

public mixed LOMIMSCC_NS = 'http://ltsc.ieee.org/xsd/imsccv1p2/LOM/manifest'

LTI_TYPE

public mixed LTI_TYPE = 'imsbasiclti_xmlv1p0'

LTICM_NS

public mixed LTICM_NS = 'http://www.imsglobal.org/xsd/imslticm_v1p0'

LTICP_NS

public mixed LTICP_NS = 'http://www.imsglobal.org/xsd/imslticp_v1p0'

metadata_xpath

public mixed metadata_xpath = '/*/*[1]'

PROFILE_11

public mixed PROFILE_11 = '1.1'

PROFILE_12

public mixed PROFILE_12 = '1.2'

QTI_ASSESSMENT_TYPE

IMS CC 1.2 QTI 1.2.1 assessment resource type.

public mixed QTI_ASSESSMENT_TYPE = 'imsqti_xmlv1p2/imscc_xmlv1p2/assessment'

QTI_ASSESSMENT_TYPE_11

public mixed QTI_ASSESSMENT_TYPE_11 = 'imsqti_xmlv1p2/imscc_xmlv1p1/assessment'

QTI_NS

public mixed QTI_NS = 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2'

QTI_SCHEMA_LOCATION

public mixed QTI_SCHEMA_LOCATION = 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2 http://www.imsglobal.org/profile/cc/ccv1p2/ccv1p2_qtiasiv1p2p1_v1p0.xsd'

QTI_SCHEMA_LOCATION_11

public mixed QTI_SCHEMA_LOCATION_11 = 'http://www.imsglobal.org/xsd/ims_qtiasiv1p2 http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_qtiasiv1p2p1_v1p0.xsd'

resource_xpath

public mixed resource_xpath = '/*/*[3]'

SCHEMA_NAME

public mixed SCHEMA_NAME = 'IMS Common Cartridge'

TOPIC_11_NS

public mixed TOPIC_11_NS = 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1'

TOPIC_NS

public mixed TOPIC_NS = 'http://www.imsglobal.org/xsd/imsccv1p2/imsdt_v1p2'

TOPIC_SCHEMA_LOCATION

public mixed TOPIC_SCHEMA_LOCATION = 'http://www.imsglobal.org/xsd/imsccv1p2/imsdt_v1p2 http://www.imsglobal.org/profile/cc/ccv1p2/ccv1p2_imsdt_v1p2.xsd'

TOPIC_SCHEMA_LOCATION_11

public mixed TOPIC_SCHEMA_LOCATION_11 = 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1 http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imsdt_v1p1.xsd'

TOPIC_TYPE

public mixed TOPIC_TYPE = 'imsdt_xmlv1p2'

TOPIC_TYPE_11

public mixed TOPIC_TYPE_11 = 'imsdt_xmlv1p1'

VERSION

public mixed VERSION = '1.2.0'

VERSION_11

public mixed VERSION_11 = '1.1.0'
public mixed WEB_LINK_TYPE = 'imswl_xmlv1p2'
public mixed WEB_LINK_TYPE_11 = 'imswl_xmlv1p1'

WEBCONTENT_TYPE

public mixed WEBCONTENT_TYPE = 'webcontent'

WL_11_NS

public mixed WL_11_NS = 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1'

WL_NS

public mixed WL_NS = 'http://www.imsglobal.org/xsd/imsccv1p2/imswl_v1p2'

WL_SCHEMA_LOCATION

public mixed WL_SCHEMA_LOCATION = 'http://www.imsglobal.org/xsd/imsccv1p2/imswl_v1p2 http://www.imsglobal.org/profile/cc/ccv1p2/ccv1p2_imswl_v1p2.xsd'

WL_SCHEMA_LOCATION_11

public mixed WL_SCHEMA_LOCATION_11 = 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1 http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imswl_v1p1.xsd'

Properties

$canvas_extensions

When false, do not emit Canvas course_settings or assignment wrappers.

public mixed $canvas_extensions = true

Default true so legacy /cc/export is unchanged.

$canvas_items

public mixed $canvas_items = null

$canvas_module_meta

public mixed $canvas_module_meta = null

$canvas_modules

public mixed $canvas_modules = null

$canvas_quiz_wrapper

Setup Canvas export only: assessment_meta.xml, non_cc_assessments, dependency.

public mixed $canvas_quiz_wrapper = false

Off for Generic and Sakai. Legacy /cc/export does not set this.

$cc_profile

CC profile for this document: PROFILE_11 or PROFILE_12.

public string $cc_profile = self::PROFILE_12

$currentNamespace

public mixed $currentNamespace = false

$last_file

public mixed $last_file = false

$last_identifier

public mixed $last_identifier = false

$last_identifierref

public mixed $last_identifierref = false

$last_type

public mixed $last_type = false

$resource_count

public mixed $resource_count = 0

$idGenerator

Identifier generator for deterministic, hash-based identifiers

private CCIdentifier $idGenerator = null

$modulePaths

Map of DOMNode to module path for tracking parent paths

private array<string|int, mixed> $modulePaths = array()

$webResourceNames

Zip paths already used under web_resources/ in this cartridge.

private array<string, true> $webResourceNames = array()

Methods

__construct()

public __construct([mixed $profile = self::PROFILE_12 ]) : mixed
Parameters
$profile : mixed = self::PROFILE_12

add_child()

public add_child(mixed $entry, mixed $tag[, mixed $text = null ][, mixed $attr = null ]) : mixed
Parameters
$entry : mixed
$tag : mixed
$text : mixed = null
$attr : mixed = null

add_child_ns()

public add_child_ns(mixed $ns, mixed $entry, mixed $tag[, mixed $text = null ][, mixed $attr = null ]) : mixed
Parameters
$ns : mixed
$entry : mixed
$tag : mixed
$text : mixed = null
$attr : mixed = null

add_header_item()

Add a header item as a Canvas sub-header (no resource, just metadata)

public add_header_item(mixed $module, mixed $title[, mixed $parentPath = null ][, mixed $description = null ]) : The
Parameters
$module : mixed

DOMNode The module or sub module where we are adding the header

$title : mixed

The title/text of the header

$parentPath : mixed = null

Optional parent path for deterministic ID generation (auto-detected if not provided)

$description : mixed = null

Optional heading description (CC 1.2 LOM)

Return values
The —

DOMNode of the newly added header item

add_identifierref_item()

Extra module item that points at an existing resource (same identifierref).

public add_identifierref_item(DOMNode $module, string $title, string $itemIdentifier, string $identifierref[, string|null $canvasContentType = null ]) : DOMNode

Used when Lessons lists the same file or page more than once.

Parameters
$module : DOMNode
$title : string
$itemIdentifier : string

Unique item identifier (not the resource id)

$identifierref : string

Existing resource identifier

$canvasContentType : string|null = null

CanvasModuleMeta content_type_* or null

Return values
DOMNode

add_item_lom_description()

Attach CC 1.2 LOM to an organization item (description plus Tsugi identifiers).

public add_item_lom_description(DOMElement|null $item, mixed $description) : bool

Identifiers use standard lomimscc catalog/entry (repeatable). No-op for CC 1.1, a missing item, or when there is nothing to emit. Inserts metadata after title and before nested items.

Parameters
$item : DOMElement|null
$description : mixed

string, or lesson/module object/array

Return values
bool —

true when metadata was emitted

add_last_item_lom()

Attach LOM to the most recently added organization item.

public add_last_item_lom(mixed $source) : bool
Parameters
$source : mixed
Return values
bool

Add an LTI link resource item

public add_lti_link(mixed $module[, mixed $title = null ][, mixed $url = null ][, mixed $resourceLinkId = null ][, mixed $parentPath = null ][, string|null $identifier = null ]) : The

This adds an LTI link to the manifest, to complete this when making a zip file, you must generate and place the LTI XML in the returned file name within the ZIP. The zip_add_lti_to_module() combines these two steps.

Parameters
$module : mixed

DOMNode The module or sub module where we are adding the lti link

$title : mixed = null

The title of the LTI link

$url : mixed = null

Optional URL/endpoint for deterministic ID generation

$resourceLinkId : mixed = null

Optional resource_link_id for deterministic ID generation

$parentPath : mixed = null

Optional parent path for deterministic ID generation (auto-detected if not provided)

$identifier : string|null = null

Item identifier. When set, this is the lesson resource link id (a ":" is written as colon) instead of a hash.

Return values
The —

name of a file to contain the lti link XML in the ZIP.

add_module()

Adds a module to the manifest

public add_module(mixed $title[, mixed $parentPath = '' ][, mixed $description = null ]) : the
Parameters
$title : mixed

The title of the module

$parentPath : mixed = ''

Optional parent path for deterministic ID generation (e.g., "")

$description : mixed = null

Optional lesson description (CC 1.2 LOM on the item)

Return values
the —

DOMNode of the newly added module

add_qti_assessment()

Add a QTI 1.2.1 assessment resource item to the manifest.

public add_qti_assessment(DOMNode $module[, string|null $title = null ][, int|string|null $quizId = null ][, string|null $parentPath = null ][, string|null $identifier = null ]) : string

Place the assessment XML at the returned path in the ZIP. zip_add_qti_assessment_to_module() combines both steps.

Parameters
$module : DOMNode
$title : string|null = null
$quizId : int|string|null = null

Stable Quiz1 id for deterministic identifiers

$parentPath : string|null = null
$identifier : string|null = null

Item identifier. When set, this is the quiz resource link id (a ":" in the id is written as colon) instead of a hash of the quiz primary key.

Return values
string —

Path of the QTI XML file inside the ZIP

add_resource_item()

Add a resource to the manifest.

public add_resource_item(mixed $module, mixed $title, mixed $type, mixed $identifier, mixed $file[, string|null $resourceHref = null ]) : DOMNode
Parameters
$module : mixed
$title : mixed
$type : mixed
$identifier : mixed
$file : mixed
$resourceHref : string|null = null

Optional href on the resource element (webcontent).

Return values
DOMNode —

The created item node

add_resource_only()

Add a resource to the manifest without creating a module item.

public add_resource_only(string $type, string $identifier, string $file) : string

Used for creating LTI resources that will be referenced by Canvas assignments.

Parameters
$type : string

The resource type

$identifier : string

The resource identifier

$file : string

The file path

Return values
string —

The identifierref (identifier + "_R")

add_sub_module()

Adds a sub module to a module

public add_sub_module(mixed $module, mixed $title[, mixed $parentPath = null ][, mixed $description = null ]) : the

As a note, while some LMS's are happpy with deeply nested sub-module trees, other LMS's prefer a strict two-layer module / submodule structure.

Parameters
$module : mixed

DOMNode The module where we are adding the submodule

$title : mixed

The title of the sub module

$parentPath : mixed = null

Optional parent path for deterministic ID generation (auto-detected if not provided)

$description : mixed = null

Optional lesson description (CC 1.2 LOM on the item)

Return values
the —

DOMNode of the newly added sub module

add_topic()

public add_topic(mixed $module[, mixed $title = null ][, mixed $text = null ][, mixed $parentPath = null ][, mixed $identifier = null ]) : mixed
Parameters
$module : mixed
$title : mixed = null
$text : mixed = null
$parentPath : mixed = null
$identifier : mixed = null
public add_web_link(mixed $module[, mixed $title = null ][, mixed $url = null ][, mixed $parentPath = null ]) : mixed
Parameters
$module : mixed
$title : mixed = null
$url : mixed = null
$parentPath : mixed = null

associatedContentType()

public associatedContentType() : mixed

canvasNewTabForWindowTarget()

Canvas module_meta new_tab from windowTarget, else $default.

public static canvasNewTabForWindowTarget(string|null $windowTarget[, bool $default = true ]) : bool
Parameters
$windowTarget : string|null
$default : bool = true
Return values
bool

ccNs()

public ccNs() : mixed

delete_children()

public delete_children(mixed $tag) : mixed
Parameters
$tag : mixed

delete_children_ns()

public delete_children_ns(mixed $ns, mixed $tag) : mixed
Parameters
$ns : mixed
$tag : mixed

delete_tag()

public delete_tag(mixed $tag) : mixed
Parameters
$tag : mixed

delete_tag_ns()

public delete_tag_ns(mixed $ns, mixed $tag) : mixed
Parameters
$ns : mixed
$tag : mixed

disable_canvas_extensions()

Drop Canvas-only extensions so the cartridge is spec CC only.

public disable_canvas_extensions() : mixed

Used by Setup Generic and Moodle export. Do not call from legacy cc/export.php.

documentTargetFromLesson()

LTI launch_presentation_document_target from a lesson/item, or null to omit.

public static documentTargetFromLesson(mixed $source) : string|null

window / iframe / frame / modal (Tsugi).

Parameters
$source : mixed

lesson object/array, or a target string

Return values
string|null

dump_dom_levels()

public dump_dom_levels(mixed $node[, mixed $level = 0 ]) : mixed
Parameters
$node : mixed
$level : mixed = 0

dump_dom_list()

public dump_dom_list(mixed $node_list) : mixed
Parameters
$node_list : mixed

dump_dom_node()

public dump_dom_node(mixed $tag) : mixed
Parameters
$tag : mixed

get_element()

public get_element(mixed $ns, mixed $tag) : mixed
Parameters
$ns : mixed
$tag : mixed

get_tag()

public get_tag(mixed $tag[, mixed $key = null ][, mixed $value = null ]) : mixed
Parameters
$tag : mixed
$key : mixed = null
$value : mixed = null

get_tag_ns()

public get_tag_ns(mixed $ns, mixed $tag[, mixed $key = null ][, mixed $value = null ]) : mixed
Parameters
$ns : mixed
$tag : mixed
$key : mixed = null
$value : mixed = null

injectCanvasWikiMetas()

Canvas binds a wiki page to its manifest resource through <meta name="identifier">, which must equal the resource identifier.

public static injectCanvasWikiMetas(string $html, string $identifier) : string
Parameters
$html : string
$identifier : string

Resource identifier (identifierref)

Return values
string

isCc11()

public isCc11() : mixed

lessonTargetFromDocumentTarget()

Tsugi lesson target from an LTI document_target or IMS windowTarget, or null.

public static lessonTargetFromDocumentTarget(mixed $documentTarget) : string|null
Parameters
$documentTarget : mixed
Return values
string|null

lessonTargetFromWindowTarget()

Tsugi lesson target from an IMS webLink windowTarget, or null.

public static lessonTargetFromWindowTarget(mixed $windowTarget) : string|null
Parameters
$windowTarget : mixed
Return values
string|null

lomDescriptionFromItem()

LOM general.description text from an organization item, or null.

public static lomDescriptionFromItem(DOMElement $item) : string|null

Reads only this item's own metadata (not nested items). Does not trim or rewrite the recovered string, so HTML descriptions round-trip.

Parameters
$item : DOMElement
Return values
string|null

lomIdentifiersFromItem()

catalog => entry from this organization item's own LOM identifiers.

public static lomIdentifiersFromItem(DOMElement $item) : array<string, string>
Parameters
$item : DOMElement
Return values
array<string, string>

lomIdentifiersFromLesson()

Extra LOM identifier catalog/entry pairs from a lesson/module.

public static lomIdentifiersFromLesson(mixed $source) : array<string, string>
Parameters
$source : mixed
Return values
array<string, string>

lomImsccNs()

public lomImsccNs() : mixed

organizationDescription()

Non-empty lesson/module description for organization-item LOM metadata.

public static organizationDescription(mixed $source) : string|null

Accepts a string, or a lesson/module object/array with a description property. Empty string and non-strings become null (skip metadata).

Parameters
$source : mixed
Return values
string|null

organizationDue()

Lesson due day (YYYY-MM-DD) from a lesson/module or a raw value, or null.

public static organizationDue(mixed $source) : string|null
Parameters
$source : mixed
Return values
string|null

organizationGradable()

Whether a lesson item is graded, or null when the source does not say.

public static organizationGradable(mixed $source) : bool|null
Parameters
$source : mixed

lesson/module, or a raw 1/0 value

Return values
bool|null

organizationHrefSource()

Web-link href source: url or course, or null if unset/invalid.

public static organizationHrefSource(mixed $source) : string|null
Parameters
$source : mixed
Return values
string|null

organizationIcon()

Explicit Font Awesome icon class from a lesson/module, or null.

public static organizationIcon(mixed $source) : string|null
Parameters
$source : mixed
Return values
string|null

organizationResourceLinkId()

Quiz resource link id to keep on import, or null.

public static organizationResourceLinkId(mixed $source) : string|null

A raw string is the LOM entry. A lesson object or array is read only for its resource_link_id field.

Parameters
$source : mixed
Return values
string|null

profileForFlavor()

CC 1.1 for Moodle and Generic 1.1 export; everyone else is CC 1.2.

public static profileForFlavor(mixed $tsugi_lms) : string
Parameters
$tsugi_lms : mixed
Return values
string

qtiAssessmentType()

public qtiAssessmentType() : mixed

qtiSchemaLocation()

public qtiSchemaLocation() : mixed

replace_text()

public replace_text(mixed $tag, mixed $text) : mixed
Parameters
$tag : mixed
$text : mixed

replace_text_ns()

public replace_text_ns(mixed $ns, mixed $tag, mixed $text) : mixed
Parameters
$ns : mixed
$tag : mixed
$text : mixed

reserveWebResourcePath()

Reserve a unique web_resources/ path before writing bytes (page-to-page FILEBASE).

public reserveWebResourcePath(string $filename) : string
Parameters
$filename : string
Return values
string

schemaVersion()

public schemaVersion() : mixed

set_description()

public set_description(mixed $desc) : mixed
Parameters
$desc : mixed

set_namespace()

public set_namespace(mixed $new) : mixed
Parameters
$new : mixed

set_title()

public set_title(mixed $title) : mixed
Parameters
$title : mixed

topicNs()

public topicNs() : mixed

topicSchemaLocation()

public topicSchemaLocation() : mixed

topicType()

public topicType() : mixed

webLinkNs()

public webLinkNs() : mixed

webLinkSchemaLocation()

public webLinkSchemaLocation() : mixed

webLinkType()

public webLinkType() : mixed

windowTargetFromLesson()

IMS webLink url/@windowTarget from a lesson/item target, or null to omit.

public static windowTargetFromLesson(mixed $source) : string|null

Maps Tsugi/LTI values onto the CC 1.2 attribute: _blank, _self, modal.

Parameters
$source : mixed

lesson object/array, or a target string

Return values
string|null

zip_add_canvas_module_meta()

Add the course_settings/module_meta.xml to the manifest and ZIP

public zip_add_canvas_module_meta(mixed $zip) : mixed

Parameters
$zip : mixed

zip_add_canvas_quiz_wrapper()

Canvas-only: assessment_meta.xml, a same-bytes non_cc_assessments copy, and the manifest dependency. Canvas selective import discovers the quiz from the non_cc file on the metadata resource.

public zip_add_canvas_quiz_wrapper(mixed $zip, mixed $title, mixed $qtiXml[, mixed $quiz = null ]) : mixed
Parameters
$zip : mixed
$title : mixed
$qtiXml : mixed
$quiz : mixed = null

zip_add_file_at_path_to_module()

Add webcontent at an already-reserved zip path.

public zip_add_file_at_path_to_module(ZipArchive $zip, DOMNode $module, string $title, string $zipPath, string $bytes[, string|null $stableKey = null ]) : string
Parameters
$zip : ZipArchive
$module : DOMNode
$title : string
$zipPath : string
$bytes : string
$stableKey : string|null = null
Return values
string

zip_add_file_listing_to_module()

Another Lessons listing of a file already in the cartridge.

public zip_add_file_listing_to_module(DOMNode $module, string $title, string $stableKey, int $listingIndex, string $identifierref) : DOMNode

New module item, same resource identifierref — Canvas Files stays one blob.

Parameters
$module : DOMNode
$title : string
$stableKey : string

SHA-256

$listingIndex : int

2 for the second listing, 3 for the third, ...

$identifierref : string

Resource identifier from the first listing

Return values
DOMNode

zip_add_file_to_module()

Add a webcontent file to the module and store the bytes in the ZIP.

public zip_add_file_to_module(ZipArchive $zip, DOMNode $module, string $title, string $filename, string $bytes[, string|null $parentPath = null ][, string|null $stableKey = null ]) : string
Parameters
$zip : ZipArchive
$module : DOMNode
$title : string
$filename : string

Display / zip basename

$bytes : string

File contents

$parentPath : string|null = null
$stableKey : string|null = null

SHA-256 or other stable identity

Return values
string —

Path of the file inside the ZIP

zip_add_lti_outcome_to_module()

public zip_add_lti_outcome_to_module(mixed $zip, mixed $module, mixed $title, mixed $url[, mixed $custom = null ][, mixed $extensions = null ][, mixed $resourceLinkId = null ][, mixed $parentPath = null ][, mixed $identifier = null ]) : mixed
Parameters
$zip : mixed
$module : mixed
$title : mixed
$url : mixed
$custom : mixed = null
$extensions : mixed = null
$resourceLinkId : mixed = null
$parentPath : mixed = null
$identifier : mixed = null

zip_add_lti_to_module()

public zip_add_lti_to_module(mixed $zip, mixed $module, mixed $title, mixed $url[, mixed $custom = null ][, mixed $extensions = null ][, mixed $resourceLinkId = null ][, mixed $parentPath = null ][, mixed $identifier = null ]) : mixed
Parameters
$zip : mixed
$module : mixed
$title : mixed
$url : mixed
$custom : mixed = null
$extensions : mixed = null
$resourceLinkId : mixed = null
$parentPath : mixed = null
$identifier : mixed = null

zip_add_qti_assessment_to_module()

Add a QTI assessment to the module and write the XML into the ZIP.

public zip_add_qti_assessment_to_module(ZipArchive $zip, DOMNode $module, string $title, string $qtiXml[, int|string|null $quizId = null ][, string|null $parentPath = null ][, Quiz1|null $quiz = null ]) : string
Parameters
$zip : ZipArchive
$module : DOMNode
$title : string
$qtiXml : string

UTF-8 QTI 1.2.1 assessment document

$quizId : int|string|null = null
$parentPath : string|null = null
$quiz : Quiz1|null = null

For Canvas assessment_meta points/description

Return values
string

zip_add_topic_to_module()

public zip_add_topic_to_module(mixed $zip, mixed $module, mixed $title, mixed $text[, mixed $parentPath = null ][, mixed $identifier = null ]) : mixed
Parameters
$zip : mixed
$module : mixed
$title : mixed
$text : mixed
$parentPath : mixed = null
$identifier : mixed = null

zip_add_url_to_module()

public zip_add_url_to_module(mixed $zip, mixed $module, mixed $title, mixed $url[, mixed $parentPath = null ][, mixed $new_tab = true ][, mixed $lesson = null ]) : mixed
Parameters
$zip : mixed
$module : mixed
$title : mixed
$url : mixed
$parentPath : mixed = null
$new_tab : mixed = true
$lesson : mixed = null

zip_add_wiki_listing_to_module()

Another Lessons listing of a wiki page already in the cartridge.

public zip_add_wiki_listing_to_module(DOMNode $module, string $title, string $logicalKey, int $listingIndex, string $identifierref) : DOMNode
Parameters
$module : DOMNode
$title : string
$logicalKey : string
$listingIndex : int
$identifierref : string
Return values
DOMNode

zip_add_wiki_page_to_module()

Add a Canvas-style wiki page (wiki_content/*.html) as IMS CC webcontent.

public zip_add_wiki_page_to_module(ZipArchive $zip, DOMNode $module, string $title, string $logicalKey, string $html[, string|null $parentPath = null ]) : string

Canvas reads the page name from the HTML <title>.

Parameters
$zip : ZipArchive
$module : DOMNode
$title : string
$logicalKey : string

Zip basename without .html

$html : string

Full HTML document

$parentPath : string|null = null
Return values
string —

Path of the file inside the ZIP

zip_finish_qti_assessment()

Write QTI bytes, optional Canvas quiz wrapper, and module_meta item.

public zip_finish_qti_assessment(mixed $zip, mixed $file, mixed $title, mixed $qtiXml[, mixed $quiz = null ]) : mixed
Parameters
$zip : mixed
$file : mixed
$title : mixed
$qtiXml : mixed
$quiz : mixed = null

fixedIdentifier()

private fixedIdentifier(string $identifier) : mixed
Parameters
$identifier : string

Item identifier, before the _R resource suffix

generate_canvas_assignment_xml()

Generate Canvas assignment XML

private generate_canvas_assignment_xml(string $title, string $ltiResourceId, string $launchUrl[, float $pointsPossible = 10.0 ]) : string
Parameters
$title : string

The assignment title

$ltiResourceId : string

The identifier of the LTI resource this assignment references

$launchUrl : string

The actual launch URL for the LTI tool

$pointsPossible : float = 10.0

Points possible (default 10.0)

Return values
string —

XML content

identifierTaken()

private identifierTaken(string $identifier) : mixed
Parameters
$identifier : string

Item identifier, before the _R resource suffix

lessonTargetValue()

private static lessonTargetValue(mixed $source) : string|null
Parameters
$source : mixed
Return values
string|null

lessonType()

private static lessonType(mixed $source) : mixed
Parameters
$source : mixed

manifestSkeleton()

Empty-ish manifest matching this profile (sample items are stripped in the constructor).

private manifestSkeleton() : string
Return values
string

organizationItemByIdentifier()

Organization item with this identifier, or null.

private organizationItemByIdentifier(string|false $identifier) : DOMElement|null
Parameters
$identifier : string|false
Return values
DOMElement|null

resource_by_identifier()

private resource_by_identifier(mixed $identifier) : mixed
Parameters
$identifier : mixed

uniqueNamedPath()

private uniqueNamedPath(string $dir, string $filename, string $fallback) : mixed
Parameters
$dir : string
$filename : string
$fallback : string

uniqueWebResourcePath()

Safe unique path under web_resources/ for an in-cartridge file.

private uniqueWebResourcePath(string $filename) : mixed
Parameters
$filename : string

uniqueWikiContentPath()

Safe unique path under wiki_content/ for a Canvas wiki page.

private uniqueWikiContentPath(string $filename) : mixed
Parameters
$filename : string

        
On this page

Search results