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 :QualifiedEmbed
-
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
QualifiedEmbed
set 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
node
Type:
- 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 config
Object Properties
Name Type Argument Description challengeId
string <nullable>
Change the challenge ID. Automatically Triggers a reload if the challenge ID is different.
options
ChallengeOptions <nullable>
Update the options for this editor (mixed in with the current ones).
reload
boolean <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
mode
isreadOnly
orrestricted
, 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
mode
isreadOnly
, 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
mode
isreadOnly
, 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
mode
isreadOnly
, this action is ignored.When the
mode
isrestricted
, 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 files
Object 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
code
andtestcases
for classic challenges.cursor
ChallengeOptions~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.data
returned fromChallengeOptions#onRun
,QualifiedEmbeddedChallenge#runTests
, orQualifiedEmbeddedChallenge#attempt
.This can include the
fileData
property, which will configure the entire solution at once.Parameters:
Name Type Description runResult
ChallengeOptions~RunResult Returns:
A promise resolved after the result has been set, or rejects if an error occurs.
- Type
- Promise
-
destroy()
-
Destroys this embed and cleans up any resources associated with it.
- Inherited From:
- Overrides: