Skip to content

Commit 63ff139

Browse files
pgbovinemmmicedcoffee
authored andcommitted
udpated
1 parent 25c65b6 commit 63ff139

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
lines changed

v3/bottle_server.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import cStringIO
1313
import json
1414
import pg_logger
15+
import urllib
16+
import urllib2
17+
1518

1619
@route('/<filepath:path>')
1720
def index(filepath):
@@ -46,7 +49,9 @@ def load_matrix_problem():
4649
assert prob_name in ('python_comprehension-1',)
4750

4851
fn = 'matrix-demo/' + prob_name + '.py'
49-
cod = open(fn).read()
52+
f = open(fn)
53+
cod = f.read()
54+
f.close()
5055

5156
import doctest
5257
import sys
@@ -73,16 +78,22 @@ def submit_matrix_problem():
7378
test_cod = open(test_fn).read()
7479

7580
# concatenate!
76-
script = test_cod + '\n' + user_code + '\nimport doctest\ndoctest.testmod()'
77-
78-
import simple_sandbox
79-
80-
def json_finalizer(executor):
81-
return json.dumps(dict(code=executor.executed_script,
82-
user_stdout=executor.user_stdout.getvalue(),
83-
user_stderr=executor.user_stderr.getvalue()))
84-
85-
return simple_sandbox.exec_str(script, json_finalizer)
81+
script = test_cod + '\n' + user_code + \
82+
'''
83+
import doctest
84+
(n_fail, n_tests) = doctest.testmod(verbose=False)
85+
if n_fail == 0:
86+
print("All %d tests passed!" % n_tests)
87+
'''
88+
89+
url = 'http://ec2-107-20-94-197.compute-1.amazonaws.com/cgi-bin/run_code.py'
90+
values = {'user_script' : script}
91+
92+
data = urllib.urlencode(values)
93+
req = urllib2.Request(url, data)
94+
response = urllib2.urlopen(req)
95+
the_page = response.read()
96+
return the_page
8697

8798

8899
if __name__ == "__main__":

v3/js/matrixtutor.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ $(document).ready(function() {
116116
$('#pyOutputPane #editBtn').click(function() {
117117
enterEditMode();
118118
});
119+
120+
$('#gradeStdout,#gradeStderr').val(''); // clear 'em
121+
$('#submitGradeBtn').html('Submit for Grading');
122+
$('#submitGradeBtn').attr('disabled', false);
119123
}
120124
else if (appMode == 'display_no_frills') {
121125
$("#pyInputPane").hide();
@@ -142,7 +146,7 @@ $(document).ready(function() {
142146
$("#pyOutputPane,#gradingPane").hide();
143147
$("#embedLinkDiv").hide();
144148

145-
var backendOptionsObj = {cumulative_mode: ($('#cumulativeModeSelector').val() == 'true'),
149+
var backendOptionsObj = {cumulative_mode: false,
146150
heap_primitives: false,
147151
show_only_outputs: false,
148152
py_crazy_mode: false,
@@ -222,11 +226,6 @@ $(document).ready(function() {
222226

223227
var queryStrOptions = getQueryStringOptions();
224228

225-
// ugh, ugly tristate due to the possibility of each being undefined
226-
if (queryStrOptions.cumulativeState !== undefined) {
227-
$('#cumulativeModeSelector').val(queryStrOptions.cumulativeState);
228-
}
229-
230229
appMode = $.bbq.getState('mode'); // assign this to the GLOBAL appMode
231230
if ((appMode == "display") && queryStrOptions.preseededCode /* jump to display only with pre-seeded code */) {
232231
preseededCurInstr = queryStrOptions.preseededCurInstr; // ugly global
@@ -273,12 +272,18 @@ $(document).ready(function() {
273272

274273

275274
$('#submitGradeBtn').bind('click', function() {
275+
$('#submitGradeBtn').html('Now Grading ...');
276+
$('#submitGradeBtn').attr('disabled', true);
277+
276278
$.get('submit_matrix_problem',
277279
{submitted_code: pyInputCodeMirror.getValue(),
278280
problem_name: 'python_comprehension-1'},
279281
function(dataFromBackend) {
280282
$('#gradeStdout').val(dataFromBackend.user_stdout);
281283
$('#gradeStderr').val(dataFromBackend.user_stderr);
284+
285+
$('#submitGradeBtn').html('Submit for Grading');
286+
$('#submitGradeBtn').attr('disabled', false);
282287
},
283288
"json");
284289

v3/matrixtutor.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ <h1 style="margin-bottom: 15px; font-size: 14pt;">Problem: python_comprehension-
9999
</p>
100100

101101
<p>
102-
Program output:<br/>
103-
<textarea id="gradeStdout" cols="100" rows="20" wrap="off" readonly></textarea>
102+
Grader output:<br/>
103+
<textarea id="gradeStdout" cols="80" rows="12" wrap="off" readonly></textarea>
104104
</p>
105105

106106
<p>
107-
Errors:<br/>
108-
<textarea id="gradeStderr" cols="100" rows="10" wrap="off" readonly></textarea>
107+
Grader errors:<br/>
108+
<textarea id="gradeStderr" cols="80" rows="4" wrap="off" readonly></textarea>
109109
</p>
110110

111111
</div>

0 commit comments

Comments
 (0)