From 02d0c132aeff34ffb763f06096bf8a7eb664aa63 Mon Sep 17 00:00:00 2001 From: Aleksander Sadikov Date: Wed, 30 Sep 2015 20:58:07 +0200 Subject: Add a popup hint for grandparent --- prolog/problems/family_relations/grandparent_2/common.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'prolog/problems') 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 -- cgit v1.2.1