From 1dd4d473bb136c607eeea3a2d655b3f56e5aeee8 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 23 Feb 2016 17:31:56 +0100 Subject: Remove explicit "Hint" button Hints are now generated for each tested program, and the user can press a button to reveal the hints. --- js/codeq/prolog.js | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'js/codeq/prolog.js') diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js index b2ea3e1..3d34423 100644 --- a/js/codeq/prolog.js +++ b/js/codeq/prolog.js @@ -33,9 +33,8 @@ along with this program. If not, see . */ jqAllQuadrants = jqDescription.add(jqCode).add(jqConsole).add(jqInfo), // all the quadrants // buttons jqBtnPlan = jqScreen.find('.btn-plan'), - jqBtnHint = jqScreen.find('.btn-hint').ladda(), jqBtnTest = jqScreen.find('.btn-test').ladda(), - jqAllButtons = jqBtnPlan.add(jqBtnHint).add(jqBtnTest), // all the buttons + jqAllButtons = jqBtnPlan.add(jqBtnTest), // all the buttons // misc currentSubState = null, transitionEventName = 'mousedown',//event name of the event which will trigger the transition between these substates - the most common transition at least (there are some corner cases on the hint and test buttons -> see the code below) @@ -251,7 +250,7 @@ along with this program. If not, see . */ }), activityHandler = codeq.makeActivityHandler(editor, problemDef.id), terminal = makePrologTerminalHandler(jqTerminal, editor, problemDef.id, activityHandler), - hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'prolog_hints', problemDef, commonDef), + hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'prolog_hints', problemDef, commonDef, activityHandler), commError = function (error) { alert(error); }; @@ -279,42 +278,14 @@ along with this program. If not, see . */ }); jqBtnPlan.on('click', function () { - activityHandler.queueTrace({'typ': 'plan'}); if (!hinter.planNext()) { jqBtnPlan.prop('disabled', true).blur(); } }); - jqBtnHint.on('click', function () { - editor.setOption('readOnly', true); - terminal.inputDisable(); - jqBtnTest.prop('disabled', true); - jqBtnHint.ladda('start'); - codeq.comms.sendHint({ - 'program': editor.getDoc().getValue(), - 'problem_id': problemDef.id - }) - .then(function (data) { - if (data.code === 0) { - activityHandler.queueTrace({'typ': 'hint', 'feedback': data.hints}); - hinter.handle(data.hints); - } - else { - terminal.append(data.message + '\n', 'error'); - } - }) - .fail(commError) - .fin(function () { - editor.setOption('readOnly', false); - terminal.inputEnable(); - jqBtnHint.ladda('stop'); - jqBtnTest.prop('disabled', false); - }) - .done(); - }); + jqBtnTest.on('click', function () { editor.setOption('readOnly', true); terminal.inputDisable(); - jqBtnHint.prop('disabled', true); jqBtnTest.ladda('start'); codeq.comms.sendTest({ 'program': editor.getDoc().getValue(), @@ -322,7 +293,6 @@ along with this program. If not, see . */ }) .then(function (data) { if (data.code === 0) { - activityHandler.queueTrace({'typ': 'test', 'feedback': data.hints}); hinter.handle(data.hints); } else { @@ -334,7 +304,6 @@ along with this program. If not, see . */ editor.setOption('readOnly', false); terminal.inputEnable(); jqBtnTest.ladda('stop'); - jqBtnHint.prop('disabled', false); }) .done(); }); -- cgit v1.2.1