diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2017-02-27 18:38:25 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2017-02-27 18:38:25 +0100 |
commit | a0c72e1a50c1164bad7f1d9c66fb4af906e0a52a (patch) | |
tree | f1629523e712ac4be2f1b72b35b4521ca0a9cc46 /js | |
parent | d85c5d061764ea41c8ea7097239c332cd16c509d (diff) |
Report hints both when offered and viewed
Diffstat (limited to 'js')
-rw-r--r-- | js/codeq/hint.js | 19 |
1 files changed, 12 insertions, 7 deletions
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 <http://www.gnu.org/licenses/>. */ 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 <http://www.gnu.org/licenses/>. */ var i, hint, hintDef, hintContent, n_correct = 0, n_all = 0, jqHintBox = $('<div class="feedback"></div>'), - 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 <http://www.gnu.org/licenses/>. */ } else { // otherwise, hide hints behind a button + activityHandler.queueTrace({'typ': 'hint', 'feedback': hints, 'shown': false}); jqHintBtn = $('<button class="display-hints" data-tkey="btn_hint">Hint</button>'); 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); |