diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/comms.js | 5 | ||||
-rw-r--r-- | js/prolog.js | 30 |
2 files changed, 34 insertions, 1 deletions
diff --git a/js/codeq/comms.js b/js/codeq/comms.js index cff1015..c2ad715 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -121,6 +121,11 @@ return send('query', query); }, + sendTest: function commsSendTest (json) { + json['sid'] = codeq.sid; + return send('test', json); + }, + getProblem: function commsGetProblem (language, problem_group, problem) { return send('get_problem', { 'sid': codeq.sid, diff --git a/js/prolog.js b/js/prolog.js index e252393..c3e3da8 100644 --- a/js/prolog.js +++ b/js/prolog.js @@ -354,7 +354,35 @@ $('#btn_code_hint').on('click', function () { // handler.processServerHints([{id:'drop_down', start: 20, end: 26, choices:['ena', 'dva', 'tri']}]); }); + $('#btn_code_test').on('click', function () { + jqConsole.echo('?- test.'); + jqConsole.pause(); + var doc = editor.getDoc(); + codeq.comms.sendTest({ + 'program': editor.getDoc().getValue(), + 'problem_id': problem.id + }).then( + function testSuccess(data) { + jqConsole.resume(); + // TODO output to "hints" window once that is implemented + if (data.code === 0) { + t = data.terminal; + lines = t.messages; + for (i = 0; i < lines.length; i++) { + jqConsole.echo(lines[i]); + } + } + else { + jqConsole.error(data.message); + } + }, + tf = function testFailed (error) { + jqConsole.resume(); + jqConsole.exception(error); + } + ).done(); + }); return handler; }; -})();
\ No newline at end of file +})(); |