Skip to content

Commit

Permalink
Merge pull request #43 from EmpowrOrg/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dri94 authored Oct 5, 2022
2 parents 45378b3 + d3eabac commit 644003a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions swiftplugin/swiftplugin/static/js/src/swiftplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ function SwiftPluginXBlock(runtime, element) {
init_problem()
}

function init_code_mirror(mode) {
function init_code_mirror(response) {
const codemirror_config = {
value: "// Your code here.",
value: response.starter_code,
lineNumbers: true,
mode: mode,
mode: response.problem_language,
lineWrapping: true,
indentWithTabs: true,
lineWiseCopyCut: true,
Expand Down Expand Up @@ -128,7 +128,7 @@ function SwiftPluginXBlock(runtime, element) {

function updateProblem(response) {
updateValues(response)
init_code_mirror(response.problem_language)
init_code_mirror(response)
updateProblemDescription(response)
updateProblemTitle(response)
if (response.has_solution_defined) {
Expand Down
8 changes: 7 additions & 1 deletion swiftplugin/swiftplugin/swiftplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class SwiftPluginXBlock(
help="User code",
)

starter_code = String(
default="",
scope=Scope.settings,
help="Starter code for user"
)

reference_id = String(
default="",
scope=Scope.settings,
Expand Down Expand Up @@ -214,7 +220,7 @@ def get_problem_info(self, data, suffix=''):
'show_submit_button': show_submit_button,
'display_language': self.get_mode_display_language(),
'allowed_languages': self.get_allowed_languages(),

'starter_code': self.starter_code,
}

def handle_request(self, url, language):
Expand Down

0 comments on commit 644003a

Please sign in to comment.