From ffeb1a12491780d489d96dd7159a09b5fd16090c Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 18 Sep 2015 16:24:32 +0200 Subject: Add "Plan" button to display next "planning" hint --- js/codeq/python.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'js/codeq/python.js') diff --git a/js/codeq/python.js b/js/codeq/python.js index e856c08..1d4ee17 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -97,9 +97,11 @@ * add the above function to the buttons */ addClickListenerTranstions = function(){ + $('#btn_code_plan').on('click',clickListenerTransitionFun); $('#btn_code_hint').on('click',clickListenerTransitionFun); $('#btn_code_test').on('click',clickListenerTransitionFun); + $('#btn_code_plan').on(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_hint').on(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_test').on(transitionEventName,mouseDownEventIgnoreFun); }, @@ -107,9 +109,11 @@ * and a function to remove it */ removeClickListenerTransition = function(){ + $('#btn_code_plan').off('click',clickListenerTransitionFun); $('#btn_code_hint').off('click',clickListenerTransitionFun); $('#btn_code_test').off('click',clickListenerTransitionFun); + $('#btn_code_plan').off(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_hint').off(transitionEventName,mouseDownEventIgnoreFun); $('#btn_code_test').off(transitionEventName,mouseDownEventIgnoreFun); }, @@ -312,11 +316,12 @@ editor = CodeMirror(jqEditor[0], { cursorHeight: 0.85, lineNumbers: true, matchBrackets: true, mode: 'python' }), activityHandler = makeActivityHandler(editor, problem.id), terminal = makePythonTerminalHandler(jqConsole, editor, problem.id, activityHandler), - hinter = codeq.makeHinter(jqHints, jqEditor, editor, problem.hint); + hinter = codeq.makeHinter(jqHints, jqEditor, editor, problem.hint, problem.plan); editor.setValue(info.solution); $('#title').text(problem.slug); jqDescription.html(problem.description); + $('#btn_code_plan').prop('disabled', problem.plan.length == 0); editor.on('change', function (instance, changeObj) { var doc = editor.getDoc(), @@ -331,6 +336,12 @@ } }); + $('#btn_code_plan').on('click', function () { + if (!hinter.planNext()) { + $('#btn_code_plan').prop('disabled', true); + $('#btn_code_plan').blur(); + } + }); $('#btn_code_hint').on('click', function () { var doc = editor.getDoc(); codeq.comms.sendHint({ -- cgit v1.2.1 From c922a97f9810321eb6812cf52c463454617b82d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 18 Sep 2015 16:34:54 +0200 Subject: Don't crash loading a python problem, if the problem has no plan set. --- js/codeq/python.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/codeq/python.js') diff --git a/js/codeq/python.js b/js/codeq/python.js index 1d4ee17..a8d4c95 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -321,7 +321,7 @@ editor.setValue(info.solution); $('#title').text(problem.slug); jqDescription.html(problem.description); - $('#btn_code_plan').prop('disabled', problem.plan.length == 0); + $('#btn_code_plan').prop('disabled', (problem.plan || '').length == 0); editor.on('change', function (instance, changeObj) { var doc = editor.getDoc(), -- cgit v1.2.1 From 3df482a0fcca2f11cce51fc072e6a4dbc861c2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 18 Sep 2015 16:36:21 +0200 Subject: Implement console history and enable it with python problems. --- js/codeq/python.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/codeq/python.js') diff --git a/js/codeq/python.js b/js/codeq/python.js index a8d4c95..c5f7df6 100644 --- a/js/codeq/python.js +++ b/js/codeq/python.js @@ -225,7 +225,8 @@ var makePythonTerminalHandler = function (jqConsole, editor, problem_id, activityHandler) { var terminal = codeq.makeConsole(jqConsole, { - 'greeting': 'CodeQ Python terminal proxy' + 'greeting': 'CodeQ Python terminal proxy', + 'autoHistory': true }), tcs = function terminalCommandSuccess (data) { if (data.code !== 0) { -- cgit v1.2.1