summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2015-10-01 21:11:58 +0200
committerAleksander Sadikov <aleksander.sadikov@fri.uni-lj.si>2015-10-01 21:11:58 +0200
commit2fefd55550808f630190c89c6d9b3f6bfed3f164 (patch)
treebb0bb85eadf8224231cdf2ee6635ee8b3fe673db
parenteaaeb3af7acebe0e1414fb25c1b50cd5a383f2a3 (diff)
Figures and hints updated for mother/2, father/2, and grandparent/2 problems.
-rw-r--r--prolog/problems/family_relations/father_2/common.py7
-rw-r--r--prolog/problems/family_relations/father_2/sl.py18
-rw-r--r--prolog/problems/family_relations/grandparent_2/common.py7
-rw-r--r--prolog/problems/family_relations/grandparent_2/sl.py13
-rw-r--r--prolog/problems/family_relations/mother_2/common.py1
5 files changed, 33 insertions, 13 deletions
diff --git a/prolog/problems/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py
index cbfbcab..1643066 100644
--- a/prolog/problems/family_relations/father_2/common.py
+++ b/prolog/problems/family_relations/father_2/common.py
@@ -21,6 +21,7 @@ father(X, Y) :-
hint_type = {
'or_instead_of_and': Hint('or_instead_of_and'),
+ 'or_instead_of_and_two_rules': Hint('or_instead_of_and_two_rules'),
'x_must_be_male': Hint('x_must_be_male'),
'x_must_be_parent': Hint('x_must_be_parent'),
'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'),
@@ -80,6 +81,12 @@ def hint(program, solved_problems):
'findall(_, father(X, Y), L), length(L, 48)'):
return [{'id': 'or_instead_of_and'}]
+ # OR instead of AND written with two rules, namely:
+ # (r1) father(X, Y):- male(X). (r2) father(X, Y):- parent(X, Y).
+ if prolog.engine.ask_truth(engine_id,
+ 'findall(_, father(X, Y), L), length(L, 48)'):
+ return [{'id': 'or_instead_of_and_two_rules'}]
+
# X must be male
if prolog.engine.ask_truth(engine_id, 'female(X), father(X, _)'):
return [{'id': 'x_must_be_male'}]
diff --git a/prolog/problems/family_relations/father_2/sl.py b/prolog/problems/family_relations/father_2/sl.py
index ee6893b..67bf764 100644
--- a/prolog/problems/family_relations/father_2/sl.py
+++ b/prolog/problems/family_relations/father_2/sl.py
@@ -17,13 +17,12 @@ description = '''\
plan = [
'''\
-<p><img src="Father-1.png" /></p>
-<p>Loni naj zbriše imena relacij (parent, mother) s te slike!</p>''',
+<p><img src="[%@resource Prolog_father_01.svg%]" alt="Oče ima otroka in je moškega spola." /></p>''',
'''\
-<p><img src="Father-1.png" /></p>''',
+<p><img src="[%@resource Prolog_father_02.svg%]" alt="Oče X je starš od Y in je moškega spola." /></p>''',
'''\
-<p>Če je <code>X</code> ženska in je hkrati <code>X</code> starš od <code>Y</code>,
-potem je <code>X</code> mama od <code>Y</code>.</p>'''
+<p>Če je <code>X</code> moški in je hkrati <code>X</code> starš od <code>Y</code>,
+potem je <code>X</code> oče od <code>Y</code>.</p>'''
]
hint = {
@@ -31,14 +30,19 @@ hint = {
<p>Si morda uporabil podpičje (ki pomeni ALI) namesto vejice (ki pomeni IN)?</p>
''',
+ 'or_instead_of_and_two_rules': '''\
+<p>Si morda zapisal dve pravili, eno za spol in eno za "starševstvo"?
+Pozor: velja eno ALI drugo, ne nujno eno IN drugo!</p>
+''',
+
'x_must_be_male': '''\
<p>Oče je navadno moškega spola.</p>
-<p><img src="Father-2.png" /></p>
+<p><img src="[%@resource Prolog_father_03.svg%]" /></p>
''',
'x_must_be_parent': '''\
<p>Oče naj bi imel vsaj enega otroka... torej je starš od nekoga.</p>
-<p><img src="Father-3.png" /></p>
+<p><img src="[%@resource Prolog_father_04.svg%]" /></p>
''',
'y_can_be_of_any_gender': '''\
diff --git a/prolog/problems/family_relations/grandparent_2/common.py b/prolog/problems/family_relations/grandparent_2/common.py
index 078ed4e..e9df06b 100644
--- a/prolog/problems/family_relations/grandparent_2/common.py
+++ b/prolog/problems/family_relations/grandparent_2/common.py
@@ -21,7 +21,8 @@ grandparent(X, Y) :-
hint_type = {
'no_common_z': Hint('no_common_z'),
- 'gender_is_irrelevant': HintPopup('gender_is_irrelevant'),
+ 'gender_is_irrelevant_markup': HintPopup('gender_is_irrelevant_markup'),
+ 'gender_is_irrelevant': Hint('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'),
@@ -86,7 +87,9 @@ def hint(program, solved_problems):
# this is not necessarily wrong, but worth mentioning anyway
targets = [prolog.util.Token('NAME', 'male'), prolog.util.Token('NAME', 'female')]
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]
+ if marks:
+ return [{'id': 'gender_is_irrelevant_markup', 'start': m[0], 'end': m[1]} for m in marks] + \
+ [{'id': 'gender_is_irrelevant'}]
# OR (;) instead of AND (,)
# this hint has to be before the next two
diff --git a/prolog/problems/family_relations/grandparent_2/sl.py b/prolog/problems/family_relations/grandparent_2/sl.py
index a26d0b7..35ff49e 100644
--- a/prolog/problems/family_relations/grandparent_2/sl.py
+++ b/prolog/problems/family_relations/grandparent_2/sl.py
@@ -15,10 +15,9 @@ description = '''\
</pre>'''
plan = ['''\
-<p><img src="Grandparent-1.png" /></p>
-<p>Loni naj zbriše imena relacij (parent, grandparent) s te slike!</p>
+<p><img src="[%@resource Prolog_grandparent_01.svg%]" alt="Dedek ali babica ima otroka, ki ima otroka." /></p>
''', '''\
-<p><img src="Grandparent-1.png" /></p>
+<p><img src="[%@resource Prolog_grandparent_02.svg%]" alt="Dedek ali babica ima otroka, ki tudi sam ima otroka." /></p>
''', '''\
<p>Če je <code>X</code> starš od starša od <code>Y</code>,
potem je <code>X</code> stari starš od <code>Y</code>.</p>
@@ -27,18 +26,23 @@ potem je <code>X</code> stari starš od <code>Y</code>.</p>
hint = {
'no_common_z': '''\
<p>Si povezal <code>X</code> in <code>Y</code> preko neke skupne (iste!) osebe?</p>
-''', # TODO: Tim, tale namig.. nisem prepričan, da mi je všeč... (kako je izražen)
+''', # TODO: Tim, tale namig.. nisem prepričan, da mi je všeč... (kako je izražen) -- morda nova slika!?
'gender_is_irrelevant': '''\
<p>Iščemo starega starša in vnuka, spol pri tem ni pomemben.</p>
''',
+ 'gender_is_irrelevant_markup': '''\
+<p>Je to res potrebno?</p>
+''',
+
'or_instead_of_and': '''\
<p>Si morda uporabil podpičje (ki pomeni ALI) namesto vejice (ki pomeni IN)?</p>
''',
'x_must_be_parent': '''\
<p>Dedek ali babica ima gotovo kakšnega otroka, kajne? Torej je starš od nekoga...</p>
+<p><img src="[%@resource Prolog_grandparent_03.svg%]" </p>
''',
'x_need_not_have_parent': '''\
@@ -47,6 +51,7 @@ hint = {
'y_must_have_parent': '''\
<p>Vnuk <code>Y</code> mora imeti starša, kajne? Ta starš pa je...</p>
+<p><img src="[%@resource Prolog_grandparent_04.svg%]" </p>
''',
'y_need_not_be_parent': '''\
diff --git a/prolog/problems/family_relations/mother_2/common.py b/prolog/problems/family_relations/mother_2/common.py
index d943b9c..18b3027 100644
--- a/prolog/problems/family_relations/mother_2/common.py
+++ b/prolog/problems/family_relations/mother_2/common.py
@@ -21,6 +21,7 @@ mother(X, Y) :-
hint_type = {
'or_instead_of_and': Hint('or_instead_of_and'),
+ 'or_instead_of_and_two_rules': Hint('or_instead_of_and_two_rules'),
'x_must_be_female': Hint('x_must_be_female'),
'x_must_be_parent': Hint('x_must_be_parent'),
'y_can_be_of_any_gender': Hint('y_can_be_of_any_gender'),