Difference between revisions of "Widget:CodeExplorer"

From Coder Merlin
Line 2: Line 2:
Parameters:
Parameters:
;userName: string: The current user's username
;userName: string: The current user's username
;pageName: string: The name of the page from which the widget is invoked
;sessionID: string: The ID of the current user's session
;experienceID: string: The experienceID of the page from which the widget is invoked
;codeExplorerGroupID: string: The code explorer group.  If empty, the submit button will be disabled.
;codeExplorerGroupID: string: The code explorer group.  If empty, the submit button will be disabled.
;uniqueID: integer: id for editor, must be unique per page
;uniqueID: integer: id for editor, must be unique per page
Line 17: Line 18:
{{#widget:CodeExplorer
{{#widget:CodeExplorer
|userName=john-williams
|userName=john-williams
|pageName=Boolean algebra
|sessionID=qh0ubrrme911kcg7db0i0ec6lct94h7f
|experienceID=W1020.23
|codeExplorerGroupID=WTRS-8527
|codeExplorerGroupID=WTRS-8527
|uniqueID=10
|uniqueID=10
Line 92: Line 94:
                         "https://language-server-stg.codermerlin.com/" :
                         "https://language-server-stg.codermerlin.com/" :
                         "https://language-server.codermerlin.com/";  
                         "https://language-server.codermerlin.com/";  
                     url += event.target.submitter;
                     switch (event.target.submitter) {
 
                        case "execute":
                            url += "execution/" + "experience/" + "<!--{$experienceID}-->/" + "unique/" + "<!--{$uniqueID}-->";
                            break;
                        case "submit":
                            url += "codeExplorerGroup/" + "id/" + "<!--{$codeExplorerGroupID}-->/" + "experience/" + "<!--{$experienceID}-->/" + "unique/" + "<!--{$uniqueID}-->";
                            break;
                    }
                    console.log(url);
                     var response = $.post(url, {
                     var response = $.post(url, {
                         "username": "<!--{$userName}-->",
                         "username": "<!--{$userName}-->",
                         "experienceID": "W1001",
                         "sessionID": "<!--{$sessionID}-->",
                        "exerciseID": 10,
                         "sourceCodeLanguage": "swift",
                         "sourceCodeLanguage": "swift",
                         "sourceCode": codeEditor<!--{$uniqueID|validate:int}-->.getValue()
                         "sourceCode": codeEditor<!--{$uniqueID|validate:int}-->.getValue()

Revision as of 18:27, 27 July 2021

Parameters:

userName
string: The current user's username
sessionID
string: The ID of the current user's session
experienceID
string: The experienceID of the page from which the widget is invoked
codeExplorerGroupID
string: The code explorer group. If empty, the submit button will be disabled.
uniqueID
integer: id for editor, must be unique per page
width
integer|string: percentage (as string, e.g. "100%" or integer size in pixels), null for no change (full width)
height
integer|string: percentage (as string, e.g. "100%" or integer size in pixels), null for no change (~10 lines)
lineNumbers
boolean: true to display line numbers
theme
string: name of theme (which must be loaded via css)
readOnly
boolean: true if editing should be disabled
mode
string: language for highlighting (which must be loaded via js)
initialCode
string: initial code to place in editor

Example:

{{#widget:CodeExplorer
|userName=john-williams
|sessionID=qh0ubrrme911kcg7db0i0ec6lct94h7f
|experienceID=W1020.23
|codeExplorerGroupID=WTRS-8527
|uniqueID=10
|width=null
|height=null
|lineNumbers=true
|theme=vibrant-ink
|readOnly=false
|mode=swift
|initialCode=func sayHello() {
    print("Hello, World!")
}
}}