Class: QualifiedEmbed

QualifiedEmbed

Manager for working with multiple embedded Qualified challenges. See Embedding Challenges tutorial for usage.

If you are only creating a single challenge, it might be easier to use new QualifiedEmbeddedChallenge() directly.


new QualifiedEmbed(config)

Creates a new Qualified Embed Manager.

Parameters:
Name Type Description
config Object
Properties
Name Type Argument Description
onLoaded function <nullable>

Callback for when the editor has loaded and is ready for solving. See ChallengeOptions#onLoaded for callback arguments.

onChange function <nullable>

Callback with changes any time an embedded challenge solution is modified. See ChallengeOptions#onChange for callback arguments.

onRunStart function <nullable>

Called when a run is started (internally or externally). See ChallengeOptions#onRunStart for callback arguments.

onRun function <nullable>

Callback with the results when any embedded challenge is run against tests. See ChallengeOptions#onRun for callback arguments.

autoCreate boolean | string <nullable>

If truthy, automatically configure any nodes matching the provided selector or [data-qualified-embed] if not a string. When using autoCreate, the challenge ID is found via the node property data-qualified-embed. Additional options can be passed in via challengeOptions.

options ChallengeOptions <nullable>

Default options for new embedded challenges.

challengeOptions Object <nullable>

Hash of options to be passed in when injecting an editor. The key should be the challenge ID.

Properties
Type Description
ChallengeOptions

Unique options for each challenge.

Tutorials:

Classes

QualifiedEmbed

Members


editors :Array.<QualifiedEmbeddedChallenge>

List of editors created on this manager.

Type:

options :ChallengeOptions

Shared options for new editors

Type:

challengeOptions :Object

Challenge-specific options for new embedded challenge editors.

Type:
  • Object
Properties:
Name Type Description
challengeId ChallengeOptions

Options to be set when creating an editor using challengeId as a key.

Methods


<static> init(config)

Creates a new Qualified Embed Manager.

Parameters:
Name Type Description
config *

Configuration to pass into the manager. See the QualifiedEmbed constructor for configuration options.

Returns:

Object that can be used to create, update, and destroy embedded challenges.

Type
QualifiedEmbed

findEditor(searchKeys)

Returns an existing editor via the node OR the challenge ID. If no editor is found, returns false.

Parameters:
Name Type Description
searchKeys Object
Properties
Name Type Argument Description
node HTMLElement <nullable>

Node the editor was created on (preferred).

challengeId string <nullable>

Challenge ID currently in use within an editor.

Returns:

Challenge editor, or false if no editor was found.

Type
QualifiedEmbeddedEditor | boolean

createEditor(config)

Creates or updates a challenge editor. If an existing editor is found via node or challenge ID, then that editor is returned after updating it with any new options and/or the different challenge ID.

Parameters:
Name Type Description
config Object
Properties
Name Type Argument Description
node HTMLElement

DOM node to use as basis for the injection. Will be used directly if an iFrame, otherwise an iFrame will get appended to this node.

challengeId string <nullable>

Challenge ID for this editor. If not provided, will attempt to be found via the node's data-qualified-embed attribute.

options ChallengeOptions <nullable>

Additional options for this editor, mixed with challenge-specific and shared options on the manager object.

Returns:

Existing or newly created challenge editor

Type
QualifiedEmbeddedChallenge

updateEditor(config)

Updates an existing challenge editor, looking it up via node or challenge ID.

Parameters:
Name Type Description
config Object
Properties
Name Type Argument Description
node HTMLElement <nullable>

DOM node to use as basis for the injection.

challengeId string <nullable>

Challenge ID currently used on the editor.

options ChallengeOptions <nullable>

Updated options to set on the editor.

Returns:

Challenge editor, or false if no editor was found.

Type
QualifiedEmbeddedChallenge | boolean

destroy()

Destroy this manager and all embedded challenges and event listeners created through it.