new QualifiedEmbeddedChallenge(config)
Creates a new embedded editor.
If this editor is created with
config.node being an IFRAME,
then that IFRAME is used directly as the editor.
Otherwise, the editor will inject a new IFRAME as a
child of the node passed in.
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
Properties
|
- Tutorials:
Extends
Classes
Members
-
manager :QualifiedEmbedManager
-
Manager for this editor.
Type:
-
challengeId :string
-
ID of the challenge in the this editor
Type:
- string
-
options :ChallengeOptions
-
Options on the current editor
Type:
-
challengeData :ChallengeOptions~LoadData
-
Contains information about the loaded challenge, set after
ChallengeOptions#onLoaded.Type:
-
node :HTMLElement
-
Node assigned to this editor. As a convenience, this node will have the property
QualifiedEmbedset to this editor, so you can reference this editor vianode.QualifiedEmbed.Type:
- HTMLElement
- Inherited From:
- Overrides:
-
iframe :HTMLIFrameElement
-
IFRAME node for this editor. May be the same as
nodeType:
- HTMLIFrameElement
- Inherited From:
- Overrides:
Methods
-
update(config)
-
Updates the iframe with new options, or reloads the iframe if the challenge ID has changed.
Parameters:
Name Type Description configObject Properties
Name Type Argument Description challengeIdstring <nullable>
Change the challenge ID. Automatically Triggers a reload if the challenge ID is different.
optionsChallengeOptions <nullable>
Update the options for this editor (mixed in with the current ones).
reloadboolean <nullable>
If true, force a reload even if the challenge ID hasn't changed.
-
start()
-
Triggers the editor to start the challenge if not already started.
When the
modeisreadonlyorrestricted, this action is ignored.Returns:
A promise that resolves once the challenge is started, or rejects if an error occurs.
- Type
- Promise
-
runTests()
-
Triggers the editor to run candidate tests. The runnerframe tab must be visible.
Candidate tests can be run with this method even if actions or the testcases tab are hidden.
When the
modeisreadonly, this action is ignored.Returns:
A promise that resolves with the results of the run, or rejects if an error occurs.
- Type
- Promise.<ChallengeOptions~RunResult>
-
attempt()
-
Triggers the editor to run the submission tests for Classic Code Challenges. The runnerframe tab must be visible.
Submission tests can be run with this method even if actions or the code tab are hidden.
When the
modeisreadonly, this action is ignored. This action is also ignored for Project Code Challenges.Returns:
A promise that resolves with the results of the run, or rejects if an error occurs.
- Type
- Promise.<ChallengeOptions~RunResult>
-
reset()
-
Triggers the editor to reset the solution code to the initial state.
When the
modeisreadonly, this action is ignored.When the
modeisrestricted, this action reverts the code to the last saved version.Returns:
A promise that resolves with the current files, or rejects if an error occurs.
- Type
- Promise.<ChallengeOptions~FileContentsData>
-
reload()
-
Reloads the editor. This could result in a loss of data.
-
setFileContents(files, cursor)
-
Sets the file contents for the challenge. You move the cursor without changes by not passing any files.
Parameters:
Name Type Argument Description filesObject Hash of file name or path to file contents to be set on the challenge solution.
Properties
Name Type Description (path)string Contents of each file. Use the file path as the key for project challenges, or
codeandtestcasesfor classic challenges.cursorChallengeOptions~Cursor <nullable> Optional value to move the cursor to a specific file, line, and character. Note: this will move focus to the iframe, so use with caution.
Returns:
A promise that resolves with the current files, or rejects if an error occurs.
- Type
- Promise.<ChallengeOptions~FileContentsData>
-
setRunResult(runResult)
-
Sets the run result for the challenge, which should be the
eventData.datareturned fromChallengeOptions#onRun,QualifiedEmbeddedChallenge#runTests, orQualifiedEmbeddedChallenge#attempt.This can include the
fileDataproperty, which will configure the entire solution at once.Parameters:
Name Type Description runResultChallengeOptions~RunResult Returns:
A promise resolved after the result has been set, or rejects if an error occurs.
- Type
- Promise
-
onChange(root0)
-
Handles changes in the data and updates localStorage if enabled.
Parameters:
Name Type Description root0Object The object containing the data
Properties
Name Type Description data* The data being changed
-
destroy()
-
Destroys this embed and cleans up any resources associated with it.
- Inherited From:
- Overrides: