From a0c72e1a50c1164bad7f1d9c66fb4af906e0a52a Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 27 Feb 2017 18:38:25 +0100 Subject: Report hints both when offered and viewed --- js/codeq/hint.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/hint.js b/js/codeq/hint.js index 0242443..0c4b2f2 100644 --- a/js/codeq/hint.js +++ b/js/codeq/hint.js @@ -332,7 +332,7 @@ along with this program. If not, see . */ var finalizers = [], i, hint, hintDef, hintContent, hintType, t, fn, ret; - activityHandler.queueTrace({'typ': 'hint', 'feedback': hints}); + activityHandler.queueTrace({'typ': 'hint', 'feedback': hints, 'shown': true}); for (i = 0; i < hints.length; i++) { hint = hints[i]; hintDef = hintProblemDefs[hint.id] || hintCommonDefs[hint.id]; @@ -406,7 +406,8 @@ along with this program. If not, see . */ var i, hint, hintDef, hintContent, n_correct = 0, n_all = 0, jqHintBox = $(''), - jqHintBtn; + jqHintBtn, + fn; // display the test_results hint first if found for (i = 0; i < hints.length; i++) { @@ -430,18 +431,22 @@ along with this program. If not, see . */ } else { // otherwise, hide hints behind a button + activityHandler.queueTrace({'typ': 'hint', 'feedback': hints, 'shown': false}); jqHintBtn = $(''); codeq.tr.translateDom(jqHintBtn); jqHintBtn.on('click', function (e) { jqHintBtn.off().remove(); appendHints(hints, jqHintBox); - }); - jqHintBox.append(jqHintBtn); - // experiment: Prolog hints - activityHandler.queueTrace({'typ': 'experiment', 'data': 'hint button shown'}); - // end of experiment: Prolog hints + // hide the hint button if code changes + fn = function (instance, changeObj) { + jqHintBtn.off().remove(); + editor.off('change', fn); + }; + editor.on('change', fn); + + jqHintBox.append(jqHintBtn); } } jqHints.prepend(jqHintBox); -- cgit v1.2.1