diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-27 18:25:03 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-27 18:25:03 +0200 |
commit | fabdc0472b6f2828e34f01a13fc3fa738f9eab5d (patch) | |
tree | 3bc955c35af4e437a93ed0184c27109cce1554d9 /js | |
parent | ad1451c4d5ca6dfcb31b3559b98f78b318159a09 (diff) |
Add testing functionality
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 +})(); |