-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add edit function for parsons problem
- Loading branch information
Showing
6 changed files
with
171 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- if !@lti_launch | ||
= render partial: 'layouts/breadcrumb' | ||
|
||
%h1 | ||
Edit Parsons: | ||
- if @exercise | ||
= link_to @exercise.display_name, exercise_practice_path(@exercise) | ||
- else | ||
%span Error: Exercise not found. | ||
|
||
|
||
%h2 | ||
Edit JSON Data for Step: #{params[:step]} | ||
= form_tag update_parsons_exercise_path(step: params[:step]), method: :post do | ||
%fieldset | ||
.field | ||
= label_tag :step_json_data, "Step JSON Data" | ||
= text_area_tag :step_json_data, JSON.pretty_generate(@step_data), class: 'json-editor', rows: 20, cols: 80 | ||
.actions | ||
= submit_tag "Save JSON Changes", class: 'btn btn-primary' | ||
|
||
:css | ||
.json-editor { | ||
font-family: monospace; | ||
background-color: #f9f9f9; | ||
border: 1px solid #ccc; | ||
width: 100%; | ||
margin-top: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,94 @@ | ||
{ | ||
"s3":{ | ||
"initial": "IF $$toggle::a::b$$ $$toggle::<::>::<>$$ b THEN\n min := a\nELSE\n min := b\nENDIF", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"vartests": [ | ||
{ | ||
"initcode": "min = None\na = 0\nb = 2", | ||
"code": "", | ||
"message": "Testing with a = 0 ja b = 2", | ||
"variables": { | ||
"min": 0 | ||
} | ||
}, | ||
{ | ||
"initcode": "min = None\na = 7\nb = 4\n", | ||
"code": "", | ||
"message": "Testing with a = 7 ja b = 4", | ||
"variables": { | ||
"min": 4 | ||
} | ||
} | ||
], | ||
"executable_code": "if $$toggle$$ $$toggle::<::>::!=$$ b:\nmin = a\nelse:\nmin = b\npass", | ||
"programmingLang": "pseudo" | ||
"s3": { | ||
"initial": "IF $$toggle::a::b$$ $$toggle::<::>::<>$$ b THEN\n min := a\nELSE\n min := b\nENDIF", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"vartests": [ | ||
{ | ||
"initcode": "min = None\na = 1\nb = 2", | ||
"code": "", | ||
"message": "Testing with a = 1 ja b = 2", | ||
"variables": { | ||
"min": 1 | ||
} | ||
}, | ||
"title": "Find minimum", | ||
"instructions": "Construct a function by drag& dropping and reordering lines from the left to the right.The constructed function should set the value of variable min to be the smaller of variables a and b.", | ||
"order": 0 | ||
{ | ||
"initcode": "min = None\na = 7\nb = 4\n", | ||
"code": "", | ||
"message": "Testing with a = 7 ja b = 4", | ||
"variables": { | ||
"min": 4 | ||
} | ||
} | ||
], | ||
"executable_code": "if $$toggle$$ $$toggle::<::>::!=$$ b:\nmin = a\nelse:\nmin = b\npass", | ||
"programmingLang": "pseudo" | ||
}, | ||
"s4":{ | ||
"initial": "$$toggle::x::y::tmp$$ = $$toggle::x::y::tmp$$\n$$toggle::x::y::tmp$$ = $$toggle::x::y::tmp$$\n$$toggle::x::y::tmp$$ = $$toggle::x::y::tmp$$", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"vartests": [ | ||
{ | ||
"initcode": "x = 0\ny=2", | ||
"code": "", | ||
"message": "Testing with initial variable values x = 0 and y = 2", | ||
"variables": { | ||
"x": 2 | ||
} | ||
}, | ||
{ | ||
"initcode": "x = 3\ny=4\n", | ||
"code": "", | ||
"message": "Testing with initial variable values x = 3 and y = 4", | ||
"variables": { | ||
"x": 4, | ||
"y": 3 | ||
} | ||
} | ||
], | ||
"executable_code": "tmp = x\nx = y\ny = tmp\npass" , | ||
"programmingLang": "pseudo" | ||
"title": "Find minimum", | ||
"instructions": "Construct a function by drag& dropping and reordering lines from the left to the right.The constructed function should set the value of variable min to be the smaller of variables a and b.", | ||
"order": 0 | ||
}, | ||
"s4": { | ||
"initial": "$$toggle::x::y::tmp$$ = $$toggle::x::y::tmp$$\n$$toggle::x::y::tmp$$ = $$toggle::x::y::tmp$$\n$$toggle::x::y::tmp$$ = $$toggle::x::y::tmp$$", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"vartests": [ | ||
{ | ||
"initcode": "x = 0\ny=2", | ||
"code": "", | ||
"message": "Testing with initial variable values x = 0 and y = 2", | ||
"variables": { | ||
"x": 2 | ||
} | ||
}, | ||
"title": "Variable Swap", | ||
"instructions": "Construct a program that swaps the values of variables <code>x</code> and <code>y</code> using the helper variable <code>tmp</code>. You can change the names of the variables", | ||
"order": 1 | ||
{ | ||
"initcode": "x = 3\ny=4\n", | ||
"code": "", | ||
"message": "Testing with initial variable values x = 3 and y = 4", | ||
"variables": { | ||
"x": 4, | ||
"y": 3 | ||
} | ||
} | ||
], | ||
"executable_code": "tmp = x\nx = y\ny = tmp\npass", | ||
"programmingLang": "pseudo" | ||
}, | ||
"s5":{ | ||
"initial": "for (int i=0;i<3;i++) {\nSystem.out.print(\"I \");\nSystem.out.print(\"am \");\nSystem.out.print(\"a Java program \");\n}", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"vartests": [ | ||
{ | ||
"initcode": "output = ''", | ||
"code": "", | ||
"message": "Testing...", | ||
"variables": { | ||
"output": "I am a Java program I am a Java program I am a Java program " | ||
} | ||
} | ||
], | ||
"executable_code": "for x in range(3):\noutput += 'I '\noutput += 'am '\noutput += 'a Java program '\npass\n", | ||
"programmingLang": "java" | ||
}, | ||
"title": "Print message with loop", | ||
"instructions": "Construct code by reordering and indenting the lines.", | ||
"order": 2 | ||
"title": "Variable Swap", | ||
"instructions": "Construct a program that swaps the values of variables <code>x</code> and <code>y</code> using the helper variable <code>tmp</code>. You can change the names of the variables", | ||
"order": 1 | ||
}, | ||
"s5": { | ||
"initial": "for (int i=0;i<3;i++) {\nSystem.out.print(\"I \");\nSystem.out.print(\"am \");\nSystem.out.print(\"a Java program \");\n}", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"vartests": [ | ||
{ | ||
"initcode": "output = ''", | ||
"code": "", | ||
"message": "Testing...", | ||
"variables": { | ||
"output": "I am a Java program I am a Java program I am a Java program " | ||
} | ||
} | ||
], | ||
"executable_code": "for x in range(3):\noutput += 'I '\noutput += 'am '\noutput += 'a Java program '\npass\n", | ||
"programmingLang": "java" | ||
}, | ||
"s6":{ | ||
"initial": "REPEAT 3 TIMES\nforward(100)\nleft(120)\nENDREPEAT", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"turtleModelCode":"modelTurtle.forward(100)\nmodelTurtle.left(120)\nmodelTurtle.forward(100)\nmodelTurtle.left(120)\nmodelTurtle.forward(100)\nmodelTurtle.left(120)", | ||
"executable_code": "for i in range(0,3):\nmyTurtle.forward(100)\nmyTurtle.left(120)\npass", | ||
"programmingLang": "pseudo" | ||
}, | ||
"title": "draw triangle", | ||
"instructions": "Construct a program by drag&dropping and reordering lines from the left to the right.The constructed program should draw a triangle like shown below.", | ||
"order": 3 | ||
} | ||
|
||
"title": "Print message with loop", | ||
"instructions": "Construct code by reordering and indenting the lines.", | ||
"order": 2 | ||
}, | ||
"s6": { | ||
"initial": "REPEAT 3 TIMES\nforward(100)\nleft(120)\nENDREPEAT", | ||
"parsonsConfig": { | ||
"max_wrong_lines": 1, | ||
"turtleModelCode": "modelTurtle.forward(100)\nmodelTurtle.left(120)\nmodelTurtle.forward(100)\nmodelTurtle.left(120)\nmodelTurtle.forward(100)\nmodelTurtle.left(120)", | ||
"executable_code": "for i in range(0,3):\nmyTurtle.forward(100)\nmyTurtle.left(120)\npass", | ||
"programmingLang": "pseudo" | ||
}, | ||
"title": "draw triangle", | ||
"instructions": "Construct a program by drag&dropping and reordering lines from the left to the right.The constructed program should draw a triangle like shown below.", | ||
"order": 3 | ||
} | ||
} |