~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/tutorialservice/__init__.py

  • Committer: mattgiuca
  • Date: 2008-01-29 05:42:01 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:325
tutorial: Added "run" button which submits the students code to the
tutorialservice for "unofficial" testing.
Currently tutorialservice:run just echoes the code back to the student.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
 
65
65
    if act == "test":
66
66
        handle_test(req, problem, code, fields)
 
67
    elif act == "run":
 
68
        handle_run(req, problem, code, fields)
67
69
    else:
68
70
        req.throw_error(req.HTTP_BAD_REQUEST)
69
71
 
90
92
    # Return it.
91
93
    test_results = problem_obj.run_tests(code)
92
94
    req.write(cjson.encode(test_results))
 
95
 
 
96
def handle_run(req, problem, code, fields):
 
97
    """Handles a run action."""
 
98
    # Extremely makeshift.
 
99
    # For now, just echo the code back
 
100
    output = code
 
101
    out_json = {"stdout": output}
 
102
    req.write(cjson.encode(out_json))