summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/codeq/comms.js5
-rw-r--r--js/prolog.js30
-rw-r--r--prolog.html1
3 files changed, 35 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
+})();
diff --git a/prolog.html b/prolog.html
index 0d44108..96d13cb 100644
--- a/prolog.html
+++ b/prolog.html
@@ -61,6 +61,7 @@
<button type="button" class="btn btn-default navbar-btn" id="btn_code_run">Run</button>
<button type="button" class="btn btn-default navbar-btn" id="btn_code_break">Break</button>
<button type="button" class="btn btn-default navbar-btn" id="btn_code_hint">Hint</button>
+ <button type="button" class="btn btn-default navbar-btn" id="btn_code_test">Test</button>
</div>
</nav>
<div id="code_editor"></div>