23
/** User clicks "Run" button. Do an Ajax call and print the test output.
25
function runproblem(problemid, filename)
27
/* Get the source code the student is submitting */
28
var problemdiv = document.getElementById(problemid);
29
var problembox = problemdiv.getElementsByTagName("textarea")[0];
30
var code = problembox.value;
32
var args = {"code": code, "problem": filename, "action": "run"};
34
/* Send the form as multipart/form-data, since we are sending a whole lump
35
* of Python code, it should be treated like a file upload. */
36
var xhr = ajax_call("tutorialservice", "", args, "POST",
37
"multipart/form-data");
38
var testresponse = JSON.parse(xhr.responseText);
39
handle_runresponse(problemdiv, testresponse);
42
/** Given a response object (JSON-parsed object), displays the result of the
43
* test to the user. This modifies the given problemdiv's children.
45
function handle_runresponse(problemdiv, runresponse)
47
var runoutput = problemdiv.getElementsByTagName("textarea")[1];
48
dom_removechildren(runoutput);
49
runoutput.appendChild(document.createTextNode(runresponse.stdout));
23
52
/** User clicks "Submit" button. Do an Ajax call and run the test.
24
53
* problemid: "id" of the problem's div element.
25
54
* filename: Filename of the problem's XML file (used to identify the problem