ContentModule

content. ContentModule

Module which handles course content

Constructor

new ContentModule()

Source:

Extends

  • AbstractApiModule

Members

postCloneHook :Hook

Description:
  • Hook invoked after content data is cloned
Source:
Hook invoked after content data is cloned
Type:
  • Hook

preCloneHook :Hook

Description:
  • Hook invoked before content data is cloned
Source:
Hook invoked before content data is cloned
Type:
  • Hook

Methods

(async) clone(userId, _id, _parentId, customData, options) → {Promise.<Object>}

Description:
  • Clones a content item and all its descendants in a single bulk operation. Pre-generates all _id values and friendly IDs, then inserts everything in parallel.
Source:
Parameters:
Name Type Description
userId String The user performing the action
_id String ID of the object to clone
_parentId String The intended parent object (if this is not passed, no parent will be set)
customData Object Data to be applied to the root content item
options Object
Properties
Name Type Description
tree ContentTree Pre-built tree to avoid a DB query
parent Object Pre-fetched parent doc to avoid redundant lookup
Returns:
The cloned root item
Type
Promise.<Object>

(async) computeAssetIds(doc) → {Promise.<Array.<String>>}

Description:
  • Computes the _assetIds array for a content document
Source:
Parameters:
Name Type Description
doc Object Full content document
Returns:
Unique asset IDs found in the doc
Type
Promise.<Array.<String>>

(async) delete()

Source:

(async) deleteCounters(courseIds) → {Promise}

Description:
  • Removes counter documents for deleted courses
Source:
Parameters:
Name Type Description
courseIds Array.<String>
Returns:
Type
Promise

(async) enforceAssetNotInUse(asset) → {Promise}

Description:
  • Refuses asset deletion when the asset is referenced by content. Throws RESOURCE_IN_USE listing the affected course titles.
Source:
Parameters:
Name Type Description
asset Object Asset document being deleted
Returns:
Type
Promise

(async) findMaxSeq(_type, _courseId) → {Promise.<Number>}

Description:
  • Finds the current max sequence number from existing content (for counter seeding)
Source:
Parameters:
Name Type Description
_type String
_courseId String
Returns:
Type
Promise.<Number>

(async) generateFriendlyIds(_type, _courseId, count, _languageopt) → {Promise.<Array.<String>>}

Description:
  • Generates multiple unique friendly IDs for a given type in a single atomic counter increment.
Source:
Parameters:
Name Type Attributes Description
_type String Content type (e.g. 'page', 'block', 'component')
_courseId String The course these items belong to
count Number Number of IDs to generate
_language String <optional>
Language code (only used for courses)
Returns:
Type
Promise.<Array.<String>>

(async) getSchema()

Source:

(async) getSchemaName()

Source:

(async) handleClone(req, res, next) → {Promise}

Description:
  • Request handler for cloning content items
Source:
Parameters:
Name Type Description
req external:ExpressRequest
res external:ExpressResponse
next function
Returns:
Resolves with the cloned data
Type
Promise

(async) handleInsertRecursive(req, res, next)

Description:
  • Special request handler for bootstrapping a new content object with dummy content
Source:
Parameters:
Name Type Description
req external:ExpressRequest
res external:ExpressResponse
next function

(async) handleTree(req, res, next)

Description:
  • Returns a lightweight projection of all content items for a course
Source:
Parameters:
Name Type Description
req external:ExpressRequest
res external:ExpressResponse
next function

(async) init()

Source:

(async) insert()

Source:

(async) insertRecursive(req)

Description:
  • Creates a new parent content type, along with any necessary children
Source:
Parameters:
Name Type Description
req external:ExpressRequest

registerConfigSchemas()

Description:
  • Adds config schema extensions
Source:

(async) setValues()

Source:

(async) touchCourse(doc) → {Promise}

Description:
  • Touches the parent course's updatedAt so the tree endpoint's If-Modified-Since check invalidates after any descendant content changes.
Source:
Parameters:
Name Type Description
doc Object Content document that was inserted/updated/deleted
Returns:
Type
Promise

(async) update()

Source:

(async) updateEnabledPlugins(item, options) → {Promise}

Description:
  • Maintains the list of plugins used in the current course
Source:
Parameters:
Name Type Description
item Object The updated item
options Object
Properties
Name Type Description
forceUpdate Boolean Forces an update of defaults regardless of whether the _enabledPlugins list has changed
tree ContentTree Pre-built tree to avoid redundant full-course fetch
Returns:
Type
Promise

(async) updateSortOrder(item, updateData) → {Promise}

Description:
  • Recalculates the _sortOrder values for all content items affected by an update
Source:
Parameters:
Name Type Description
item Object The existing item data
updateData Object The update data
Returns:
Type
Promise