Skip to content

Commit 2b29b4d

Browse files
author
Philip Guo
committed
some more refactoring
1 parent 9e39e2c commit 2b29b4d

5 files changed

Lines changed: 62 additions & 45 deletions

File tree

TODO

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ line of code immediately below each annotation.
106106
perhaps deploy online on WebFaction, since they offer both Python 2.X
107107
and Python 3.X on their servers.
108108

109-
---
110-
2011-09-22
111-
112-
- Make the 'Edit code' window display in the same place as the read-only
113-
code display column, in order to prevent abrupt jumping.
114109

115110
---
116111
2011-09-23
@@ -147,7 +142,8 @@ display!)
147142
---
148143
2011-09-26
149144

150-
A subset of the suggestions from MIT folks:
145+
A subset of the suggestions from MIT folks (see more in my private notes
146+
file):
151147

152148
- people thought that it's important to draw arrowheads at the end of
153149
pointers ... try to make them relatively 'clean-looking', though
@@ -158,9 +154,6 @@ A subset of the suggestions from MIT folks:
158154
- one idea is to LIMIT the size of the returned JSON data from the
159155
back-end???
160156

161-
- add a highlighter in the code to indicate that the program has
162-
TERMINATED properly (maybe light blue highlight of the code line?)
163-
164157
- to make it easier to jump to certain points in execution rather than
165158
tediously single-step through execution. e.g., could imagine adding a
166159
scrubber (like for video playback) combined with pointing at line of

edu-python-questions.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,43 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
2020
*/
2121

22-
2322
// UI for online problem sets
2423

2524
// Pre-req: edu-python.js should be imported BEFORE this file
2625

2726

27+
$(document).ready(function() {
28+
eduPythonCommonInit(); // must call this first!
29+
30+
$("#pyOutputPane").hide();
31+
32+
$("#executeBtn").attr('disabled', false);
33+
$("#executeBtn").click(function() {
34+
$('#executeBtn').html("Please wait ... processing your code");
35+
$('#executeBtn').attr('disabled', true);
36+
$("#pyOutputPane").hide();
37+
38+
$.post("cgi-bin/web_exec.py",
39+
{user_script : $("#pyInput").val()},
40+
function(traceData) {
41+
renderPyCodeOutput($("#pyInput").val());
42+
processTrace(traceData);
43+
44+
$("#pyInputPane").hide();
45+
$("#pyOutputPane").show();
46+
appMode = 'visualize';
47+
48+
$('#executeBtn').html("Visualize execution");
49+
$('#executeBtn').attr('disabled', false);
50+
},
51+
"json");
52+
});
53+
54+
55+
$("#editBtn").click(function() {
56+
$("#pyInputPane").show();
57+
$("#pyOutputPane").hide();
58+
appMode = 'edit';
59+
});
60+
});
61+

edu-python-tutor.js

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,24 @@ $(document).ready(function() {
3333

3434
$("#executeBtn").attr('disabled', false);
3535
$("#executeBtn").click(function() {
36-
if (localTesting) {
37-
renderPyCodeOutput($("#pyInput").val());
38-
39-
processTrace(data_test_trace);
40-
41-
$("#pyInputPane").hide();
42-
$("#pyOutputPane").show();
43-
appMode = 'visualize';
44-
}
45-
else {
46-
$('#executeBtn').html("Please wait ... processing your code");
47-
$('#executeBtn').attr('disabled', true);
48-
$("#pyOutputPane").hide();
49-
50-
$.post("cgi-bin/web_exec.py",
51-
{user_script : $("#pyInput").val()},
52-
function(traceData) {
53-
renderPyCodeOutput($("#pyInput").val());
54-
processTrace(traceData);
55-
56-
$("#pyInputPane").hide();
57-
$("#pyOutputPane").show();
58-
appMode = 'visualize';
59-
60-
$('#executeBtn').html("Visualize execution");
61-
$('#executeBtn').attr('disabled', false);
62-
},
63-
"json");
64-
}
36+
$('#executeBtn').html("Please wait ... processing your code");
37+
$('#executeBtn').attr('disabled', true);
38+
$("#pyOutputPane").hide();
39+
40+
$.post("cgi-bin/web_exec.py",
41+
{user_script : $("#pyInput").val()},
42+
function(traceData) {
43+
renderPyCodeOutput($("#pyInput").val());
44+
processTrace(traceData);
45+
46+
$("#pyInputPane").hide();
47+
$("#pyOutputPane").show();
48+
appMode = 'visualize';
49+
50+
$('#executeBtn').html("Visualize execution");
51+
$('#executeBtn').attr('disabled', false);
52+
},
53+
"json");
6554
});
6655

6756

edu-python.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ var useJsPlumbRendering = true;
3232
var stackGrowsDown = true;
3333

3434

35-
var localTesting = false; // if this is true, mock-data.js had also better be included
36-
37-
3835
/* colors - see edu-python.css */
3936
var lightYellow = '#F5F798';
4037
var lightLineColor = '#FFFFCC';
@@ -44,6 +41,7 @@ var visitedLineColor = '#3D58A2';
4441
var lightGray = "#cccccc";
4542
//var lightGray = "#dddddd";
4643
var darkBlue = "#3D58A2";
44+
var lightBlue = "#899CD1";
4745
var pinkish = "#F15149";
4846

4947

@@ -153,6 +151,9 @@ function highlightCodeLine(curLine, visitedLinesSet, hasError, isTerminated) {
153151
if (!isTerminated || hasError) {
154152
tbl.find('td.cod:eq(' + (curLine - 1) + ')').css('background-color', lineBgCol);
155153
}
154+
else if (isTerminated) {
155+
tbl.find('td.cod:eq(' + (curLine - 1) + ')').css('background-color', lightBlue);
156+
}
156157
}
157158

158159
// relies on curTrace and curInstr globals

question.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@
6161
<div class="questionsHeaderStmt" id="ProblemStatement"><b>Problem</b>: Write a function that
6262
reverses a list in-place.</div>
6363

64-
<div class="questionsHeaderStmt" id="ExampleStatement"><b>Example</b>: A list [INSERT LIST DIAGRAM]
65-
should be mutated to look like [INSERT LIST DIAGRAM]</div>
64+
<div class="questionsHeaderStmt" id="ExampleStatement"><b>Example</b>: A
65+
list <span id="exampleInputData"></span> should be mutated to look like
66+
<span id="exampleOutputData"></span></div>
6667

6768
<div class="questionsHeaderStmt" id="HintStatement"><a href="#" id="showHintHref">Show hint</a></div>
68-
6969
<div class="questionsHeaderStmt" id="SolutionStatement"><a href="#" id="showSolutionHref">Show solution</a></div>
7070

7171
</div>

0 commit comments

Comments
 (0)