summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2015-09-30 20:58:07 +0200
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2015-09-30 20:58:07 +0200
commit02d0c132aeff34ffb763f06096bf8a7eb664aa63 (patch)
treec3c479b9b0f9f8633bd285adcb772643abd4618f
parentaec4e861a2477762326c0f9b001668f5c1ff9ddb (diff)
Add a popup hint for grandparent
-rw-r--r--prolog/problems/family_relations/grandparent_2/common.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py
index 8ccd23d..078ed4e 100644
--- a/prolog/problems/family_relations/grandparent_2/common.py
+++ b/prolog/problems/family_relations/grandparent_2/common.py
@@ -1,9 +1,10 @@
# coding=utf-8
+from operator import itemgetter
import socket
import prolog.engine
import prolog.util
-from server.hints import Hint, HintSequence
+from server.hints import Hint, HintSequence, HintPopup
import server.problems
id = 95
@@ -20,7 +21,7 @@ grandparent(X, Y) :-
hint_type = {
'no_common_z': Hint('no_common_z'),
- 'gender_is_irrelevant': Hint('gender_is_irrelevant'),
+ 'gender_is_irrelevant': HintPopup('gender_is_irrelevant'),
'or_instead_of_and': Hint('or_instead_of_and'),
'x_must_be_parent': Hint('x_must_be_parent'),
'x_need_not_have_parent': Hint('x_need_not_have_parent'),
@@ -84,10 +85,8 @@ def hint(program, solved_problems):
# gender testing is redundant
# this is not necessarily wrong, but worth mentioning anyway
targets = [prolog.util.Token('NAME', 'male'), prolog.util.Token('NAME', 'female')]
- pos = [(t.pos, t.pos + len(t.val)) for t in tokens if t in targets]
- if pos:
- # TODO: resolve how highlighting info is communicated
- return [{'id': 'gender_is_irrelevant', 'highlight': pos}]
+ marks = [(t.pos, t.pos + len(t.val)) for t in tokens if t in targets]
+ return [{'id': 'gender_is_irrelevant', 'start': m[0], 'end': m[1]} for m in marks]
# OR (;) instead of AND (,)
# this hint has to be before the next two