From a451016b9efa919d7564fc75ab812052d1cd25f5 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 7 Oct 2015 08:34:21 +0200 Subject: Added final hints to ballistics and pythagorean. --- python/problems/introduction/ballistics/common.py | 3 +++ python/problems/introduction/ballistics/sl.py | 8 +++++++- python/problems/introduction/pythagorean_theorem/common.py | 9 ++++++--- python/problems/introduction/pythagorean_theorem/sl.py | 9 ++++++++- 4 files changed, 24 insertions(+), 5 deletions(-) (limited to 'python/problems/introduction') diff --git a/python/problems/introduction/ballistics/common.py b/python/problems/introduction/ballistics/common.py index 8773dab..afb84b6 100644 --- a/python/problems/introduction/ballistics/common.py +++ b/python/problems/introduction/ballistics/common.py @@ -29,6 +29,7 @@ hint_type = { 'radians': Hint('radians'), 'printing': Hint('printing'), 'betterg': Hint('betterg'), + 'final_hint': Hint('final_hint') } def contains_negative(s): @@ -88,6 +89,8 @@ def test(python, code): hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}] if tin: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) + if passed: + hints.append({'id': 'final_hint'}) return passed, hints def hint(python, code): diff --git a/python/problems/introduction/ballistics/sl.py b/python/problems/introduction/ballistics/sl.py index 9c0cb36..fa0fe5d 100644 --- a/python/problems/introduction/ballistics/sl.py +++ b/python/problems/introduction/ballistics/sl.py @@ -92,5 +92,11 @@ ki jo moramo najprej pretvoriti v tip float:

 v = float(input(" ...
 
-'''] +'''], + 'final_hint' : [ + '''\ +

Odlično, program deluje pravilno!
+Če želiš še kaj več izvedeti o topologiji ...

'''] + } diff --git a/python/problems/introduction/pythagorean_theorem/common.py b/python/problems/introduction/pythagorean_theorem/common.py index d11dae0..ed49b1a 100644 --- a/python/problems/introduction/pythagorean_theorem/common.py +++ b/python/problems/introduction/pythagorean_theorem/common.py @@ -23,7 +23,8 @@ hint_type = { 'unsupported_operand': Hint('unsupported_operand'), 'no_input_call' : Hint('no_input_call'), 'printing': Hint('printing'), - 'math_functions': Hint('math_functions') + 'math_functions': Hint('math_functions'), + 'final_hint': Hint('final_hint') } def test(python, code): @@ -55,7 +56,7 @@ def test(python, code): n_correct = 0 tin = None for i, (output, correct) in enumerate(zip(outputs, test_out)): - if string_almost_equal(output, float(correct)): + if string_almost_equal(output, float(correct), prec=2): n_correct += 1 else: tin = test_in[i][1] @@ -65,6 +66,8 @@ def test(python, code): hints = [{'id': 'test_results', 'args': {'passed': n_correct, 'total': len(test_in)}}] if tin: hints.append({'id': 'problematic_test_case', 'args': {'testin': str(tin), 'testout': str(tout)}}) + if passed: + hints.append({'id': 'final_hint'}) return passed, hints def hint(python, code): @@ -85,7 +88,7 @@ def hint(python, code): # if input is not present in code, student needs to learn about input if not has_token_sequence(tokens, ['input']) or \ - not has_token_sequence(tokens, ['float']) or \ + (not has_token_sequence(tokens, ['float']) and not has_token_sequence(tokens, ['int'])) or \ not has_token_sequence(tokens, ['=']): return [{'id': 'no_input_call'}] diff --git a/python/problems/introduction/pythagorean_theorem/sl.py b/python/problems/introduction/pythagorean_theorem/sl.py index b3424cb..21aec9a 100644 --- a/python/problems/introduction/pythagorean_theorem/sl.py +++ b/python/problems/introduction/pythagorean_theorem/sl.py @@ -89,6 +89,13 @@ ki jo moramo najprej pretvoriti v tip float, če želimo z njo rač
 v = float(input(" ...
 
-'''] +'''], + + 'final_hint' : [ + '''\ +

Program deluje pravilno!
+To pomeni, da znaš uporabljati matematične funkcije, ki so v modulu +math. +Tekom tega sklopa si bomo pogledali še modula za delo z nakjučnimi števili in za delo s časom.

'''] } -- cgit v1.2.1