summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prolog/common.py2
-rw-r--r--prolog/problems/family_relations/brother_2/common.py13
-rw-r--r--prolog/problems/family_relations/father_2/common.py16
-rw-r--r--prolog/problems/family_relations/mother_2/common.py13
-rw-r--r--prolog/problems/family_relations/sister_2/common.py14
5 files changed, 37 insertions, 21 deletions
diff --git a/prolog/common.py b/prolog/common.py
index 02c74d0..41377bb 100644
--- a/prolog/common.py
+++ b/prolog/common.py
@@ -10,7 +10,7 @@ hint_type = {
'syntax_error': Hint('syntax_error'),
}
-def hint(program):
+def hint(program, solved_problems):
# Check program for syntax errors.
engine_id, output = prolog.engine.create(code=program)
if engine_id is not None:
diff --git a/prolog/problems/family_relations/brother_2/common.py b/prolog/problems/family_relations/brother_2/common.py
index 4c8a4f3..48bc519 100644
--- a/prolog/problems/family_relations/brother_2/common.py
+++ b/prolog/problems/family_relations/brother_2/common.py
@@ -28,7 +28,7 @@ hint_typs = {
'x_y_must_be_different': Hint('x_y_must_be_different'),
}
-def test(session, program):
+def test(program, solved_problems):
# TODO: change queries and answers (these are for sister/2)
# Test queries and expected answers (values of X).
queries = [
@@ -37,7 +37,9 @@ def test(session, program):
('sister(X, _)', set(['michelle', 'daniela', 'patricia', 'luana', 'sally', 'melanie', 'nevia', 'vanessa', 'anna'])),
]
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
engine_id = None
try:
@@ -58,10 +60,13 @@ def test(session, program):
return n_correct, len(queries)
-def hint(session, program):
+def hint(program, solved_problems):
# tokens = prolog.util.tokenize(program)
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
+
engine_id = None
try:
engine_id, output = prolog.engine.create(code=code, timeout=1.0)
diff --git a/prolog/problems/family_relations/father_2/common.py b/prolog/problems/family_relations/father_2/common.py
index ba6a166..dd799e7 100644
--- a/prolog/problems/family_relations/father_2/common.py
+++ b/prolog/problems/family_relations/father_2/common.py
@@ -27,7 +27,7 @@ hint_type = {
'y_need_not_be_parent': Hint('y_need_not_be_parent'),
}
-def test(session, program):
+def test(program, solved_problems):
# TODO: change queries and answers (these are for sister/2)
# Test queries and expected answers (values of X).
queries = [
@@ -36,7 +36,9 @@ def test(session, program):
('sister(X, _)', set(['michelle', 'daniela', 'patricia', 'luana', 'sally', 'melanie', 'nevia', 'vanessa', 'anna'])),
]
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
engine_id = None
try:
@@ -57,13 +59,13 @@ def test(session, program):
return n_correct, len(queries)
-def general_hint():
- pass
-
-def hint(session, program):
+def hint(program, solved_problems):
tokens = prolog.util.tokenize(program)
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
+
engine_id = None
try:
engine_id, output = prolog.engine.create(code=code, timeout=1.0)
diff --git a/prolog/problems/family_relations/mother_2/common.py b/prolog/problems/family_relations/mother_2/common.py
index 42ca248..2b74f08 100644
--- a/prolog/problems/family_relations/mother_2/common.py
+++ b/prolog/problems/family_relations/mother_2/common.py
@@ -27,7 +27,7 @@ hint_type = {
'y_need_not_be_parent': Hint('y_need_not_be_parent'),
}
-def test(session, program):
+def test(program, solved_problems):
# TODO: change queries and answers (these are for sister/2)
# Test queries and expected answers (values of X).
queries = [
@@ -36,7 +36,9 @@ def test(session, program):
('sister(X, _)', set(['michelle', 'daniela', 'patricia', 'luana', 'sally', 'melanie', 'nevia', 'vanessa', 'anna'])),
]
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
engine_id = None
try:
@@ -57,10 +59,13 @@ def test(session, program):
return n_correct, len(queries)
-def hint(session, program):
+def hint(program, solved_problems):
tokens = prolog.util.tokenize(program)
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
+
engine_id = None
try:
engine_id, output = prolog.engine.create(code=code, timeout=1.0)
diff --git a/prolog/problems/family_relations/sister_2/common.py b/prolog/problems/family_relations/sister_2/common.py
index 0dfdc64..9c63b18 100644
--- a/prolog/problems/family_relations/sister_2/common.py
+++ b/prolog/problems/family_relations/sister_2/common.py
@@ -28,7 +28,7 @@ hint_type = {
'x_y_must_be_different': Hint('x_y_must_be_different'),
}
-def test(session, program):
+def test(program, solved_problems):
# Test queries and expected answers (values of X).
queries = [
('sister(melanie, X)', set(['andrew'])),
@@ -36,7 +36,9 @@ def test(session, program):
('sister(X, _)', set(['michelle', 'daniela', 'patricia', 'luana', 'sally', 'melanie', 'nevia', 'vanessa', 'anna'])),
]
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
engine_id = None
try:
@@ -57,7 +59,7 @@ def test(session, program):
return n_correct, len(queries)
-def hint(session, program):
+def hint(program, solved_problems):
# how do I know which general hints were already shown?
# how do I know enough time has elapsed for general hints to be shown?
# how do I know whether the hint button was pressed?
@@ -85,8 +87,10 @@ def hint(session, program):
# to reduce server processor load
tokens = prolog.util.tokenize(program)
- # start the engine to unit-test triggers for hints
- code = program + '\n' + server.problems.load_facts('prolog', facts).facts
+ code = (program + '\n' +
+ server.problems.solutions_for_problems('prolog', solved_problems) + '\n' +
+ server.problems.load_facts('prolog', facts).facts)
+
engine_id = None
try:
engine_id, output = prolog.engine.create(code=code, timeout=1.0)