summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/hint.js19
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);