Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalther Neuper <neuper@neuper.(none)>2009-12-02 16:20:03 (GMT)
committer Walther Neuper <neuper@neuper.(none)>2009-12-02 16:20:03 (GMT)
commitba12ab9ea4dd06b34ef26bdf1072151c5bfbc3a7 (patch)
tree60f24b51eeea2f8d211bc4ba11782168f1e5d5f6
parent47064f92f7974f88e00f3df644f4129228071562 (diff)
restored a mess with git
-rwxr-xr-xReckonPrimer.activity/Exercise.py4
-rwxr-xr-xReckonPrimer.activity/exaddsimp.py19
-rwxr-xr-xReckonPrimer.activity/expassten.py1
-rwxr-xr-xReckonPrimer.activity/extimesdiv.py9
-rw-r--r--ReckonPrimer.tests/exaddsimp/test_generate_calc.py10
-rw-r--r--ReckonPrimer.tests/expassten/test_generate_calc.py62
-rw-r--r--ReckonPrimer.tests/extimesdiv/test_generate_calc.py19
7 files changed, 91 insertions, 33 deletions
diff --git a/ReckonPrimer.activity/Exercise.py b/ReckonPrimer.activity/Exercise.py
index c481a48..e343cf8 100755
--- a/ReckonPrimer.activity/Exercise.py
+++ b/ReckonPrimer.activity/Exercise.py
@@ -42,6 +42,10 @@ class Exercise:
self._sett = sett
self._calcs = self._generate_calcs()
+ def get_calcs(self):
+ """ Get all calculations generated by the current settings. """
+ return self._calcs
+
def get_next_calc(self):
""" Get the next calculation from the Exercise.
TODO.WN091123: handle exception after last exercise. """
diff --git a/ReckonPrimer.activity/exaddsimp.py b/ReckonPrimer.activity/exaddsimp.py
index 28e8430..5fe4a9f 100755
--- a/ReckonPrimer.activity/exaddsimp.py
+++ b/ReckonPrimer.activity/exaddsimp.py
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
-#(c) Julia Schönhart
-#(c) Daniela Zierler
import gtk
import pygtk
@@ -22,10 +20,10 @@ class ExAddSimp(Exercise):
# Generate fills up by varying input.
'MIN' : 20, # minimum of calcs generated UNUSED
'min' : 0, # minimum in size of a number in a calc
- 'max' : 1, # maximum in size of a number in a calc
+ 'max' : 5, # maximum in size of a number in a calc
# 0 <= min <= max <= 10
'+' : True, # make all additions min..max
- '-' : False, # make all subtactions min..max
+ '-' : True, # make all subtactions min..max
'_+_=_' : True, # = is _right_ from operator, e.g. 1+2=3
'input=' : [1,3,5],# list of positions in calc: 1 | 3 | 5
# where input is possible;
@@ -35,13 +33,11 @@ class ExAddSimp(Exercise):
'shuffle': True, # shuffle _all_ the calcs
'cut-max': True # cut set of all calcs down to MAX
}
- self._calcs = self._generate_calcs()
def _generate_calcs(self):
_dic = self._sett
_calcs = []
if _dic['+']: # '+' or '-' are True
- #_c = self._alladd(7,7, _dic['min'], _dic['max'])
_c = self._alladd(_dic['min'], _dic['max'])
if _dic['_+_=_']: # '_+_=_' or '_=_+_' are True
# choose 1 actual position for input
@@ -83,11 +79,6 @@ class ExAddSimp(Exercise):
#[(0, 10, '3', ' 10 - 7 = _ ', ' 10 - 7 = 3 ',
#[' ', '1', '0', ' ', '-', ' ', '7', ' ', '=', ' ', '3', ' '])])
-# def count(self):
-# """TODO"""
-# print('in Display.count: len=', len(self._calcs))
-# return len(self._calcs)
-
def define_buttons(self):
self.toggle_shuffle = gtk.ToggleButton("@")
self.toggle_label = self.toggle_shuffle.get_child()
@@ -441,19 +432,17 @@ class ExAddSimp(Exercise):
self._display._sett['=input'] = list(set(self._display._sett['=input']) - set([5]))
##### end of public methods ############################################
- #def _alladd(self, min10, max10, min, max):
def _alladd(self, min, max):
"""generate all calcs for +"""
_adds = []
for _i in range(min, max +1):
for _j in range(0, _i +1):
- print("in Generate._alladd i= ",_i," j= ", _j)
- #_c = [to_str_99(min10), to_str_99(_j),'+',to_str_99(_i-_j),'=',to_str_99(min10), to_str_99(_i)]
+ #print("in Generate._alladd i= ",_i," j= ", _j)
_c = [to_str_99(_j),'+',to_str_99(_i-_j),'=',to_str_99(_i)]
_c = flatten(_c)
_c = strip(_c, '#')
_adds.append(_c)
- print("in Generate._alladd adds= ", _adds)
+ #print("in Generate._alladd adds= ", _adds)
return _adds
def _allsub(self, min, max):
diff --git a/ReckonPrimer.activity/expassten.py b/ReckonPrimer.activity/expassten.py
index 4059b2b..364489c 100755
--- a/ReckonPrimer.activity/expassten.py
+++ b/ReckonPrimer.activity/expassten.py
@@ -34,7 +34,6 @@ class ExPassTen(Exercise):
'shuffle_inner': False, # shuffle only 1st (inner) iteration
'cut-max' : True # cut set of all calcs down to MAX
}
- self._calcs = self._generate_calcs()
def format(self, (cs, ms, linepos)):
"""format the calc for display, prepare overlays for input"""
diff --git a/ReckonPrimer.activity/extimesdiv.py b/ReckonPrimer.activity/extimesdiv.py
index acf42e9..1ef6dea 100755
--- a/ReckonPrimer.activity/extimesdiv.py
+++ b/ReckonPrimer.activity/extimesdiv.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-# (c) Martin Neppel 2009
import gtk
import pygtk
@@ -33,7 +32,6 @@ class ExTimesDiv(Exercise):
'shuffle_inner': True, # shuffle only 1st (inner) iteration
'cut-max' : True # cut set of all calcs down to MAX
}
- self._calcs = self._generate_calcs()
def format(self, (calc, linepos)):
"""format the calc for display, prepare overlays for input"""
@@ -70,10 +68,6 @@ class ExTimesDiv(Exercise):
random.shuffle(_calcs)
return _calcs
-# def count(self):
-# """TODO"""
-# return len(self._calcs)
-
def define_buttons(self):
"""buttons for this setting, which is specific for TimesDiv"""
self.label = gtk.Label("2")
@@ -392,9 +386,8 @@ class ExTimesDiv(Exercise):
_calcs.append((_c, 5))
else:
for _i in range(1,11):
- print('in Generate.tim_div, (j,i)=',(_j, _i))
+ #print('in Generate.tim_div, (j,i)=',(_j, _i))
if dic == '*':
- #_c = [to_str_99(_i),'*',str(_j*10),'=',to_str_99(_i*_j*10)]
_c = [to_str_99(_i),'*',str(_j),'=',to_str_99(_i*_j)]
elif dic == '*commute':
_c = [str(_j),'*',to_str_99(_i),'=',to_str_99(_i*_j)]
diff --git a/ReckonPrimer.tests/exaddsimp/test_generate_calc.py b/ReckonPrimer.tests/exaddsimp/test_generate_calc.py
index f953e4d..67051d1 100644
--- a/ReckonPrimer.tests/exaddsimp/test_generate_calc.py
+++ b/ReckonPrimer.tests/exaddsimp/test_generate_calc.py
@@ -3,15 +3,7 @@
print("====================================_____________________=============")
print("===== ReckonPrimer.tests/addsubsimp/test_generate_calc.py ============")
-from exaddsimp import ExAddSimp
-
-_ex = ExAddSimp(None)
-_calc = _ex.get_next_calc()
-print('calc=',_calc)
-_calc = _ex.get_next_calc()
-print('calc=',_calc)
-_calc = _ex.get_next_calc()
-print('calc=',_calc)
+print("......... here will be test_generate_calc test ............")
print("===== ReckonPrimer.tests/addsubsimp/test_generate_calc.py ============")
print("=========================== SUCCESS ~~~~~~~~~~~~~~~~~~~~~ ============")
diff --git a/ReckonPrimer.tests/expassten/test_generate_calc.py b/ReckonPrimer.tests/expassten/test_generate_calc.py
new file mode 100644
index 0000000..460830f
--- /dev/null
+++ b/ReckonPrimer.tests/expassten/test_generate_calc.py
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+
+print("====================================_____________________=============")
+print("===== ReckonPrimer.tests/expassten/test_generate_calc.py =============")
+
+from expassten import ExPassTen
+
+_sett = {'topic' : 'passten',
+ 'calclines' : 1, # or 2 iff 'newline' : True.
+ 'MAX' : 150, # maximum of calcs generated;
+ # TODO: Generate fills up by varying input.
+ 'MIN' : 10, # minimum of calcs generated 090416WN:UNUSED
+ '+' :True, # + crossing the ten barrier!!
+ '-' :False, # - goes below the ten barrier!!!
+ # (i.e. iteration on left arg. is "outer" loop)
+ 'min' : 3, # +: minimum in size of number in left argument
+ #'min' : 5, # +: minimum in size of number in left argument
+ # -: minimum in size of result
+ 'max' : 3, # +: maximum in size of number in left argument
+ # -: maximum in size of result
+ #'max' : 9, # +: maximum in size of number in left argument
+ 'input' :[3], # list of positions in calc 3 | 5
+ # where input is possible;
+ # actual positions chosen by Generate.
+ 'newline' : True, # display 2nd line for intermediate results
+ 'shuffle_all' : False, # shuffle all calcs
+ 'shuffle_inner': False, # shuffle only 1st (inner) iteration
+ 'cut-max' : True # cut set of all calcs down to MAX
+ }
+_ex = ExPassTen(None)
+_ex.update_setting(_sett)
+for _i in range(0, _ex.count()):
+ _calc = _ex.get_next_calc()
+ print('calc=',_calc)
+ _form = _ex.format(_calc)
+ print('form=',_form)
+"""
+('calc=', (['3', '+', '9', '=', '1', '2'], ['7', '2'], 3))
+('form=',
+([# list of lines to be shown before input begins
+ [' ', ' ', ' ', ' ', '3', ' ', '+', ' ', '_', ' ', '=', ' ', '1', '2'],
+ [' ', ' ', ' ', ' ', ' ', ' ', ' ', '_', '+', '_', ' ', ' ', ' ', ' ']],
+ [# list of tuples, each tuple for _one_ input of _one_ digit
+ (0, 8, '9', '3+_=12', '3+9=12',
+ #^ line no.
+ #^ column no.
+ #^ correct input
+ #^ protocol ???
+ #^ protocol ???
+ [' ', ' ', ' ', ' ', '3', ' ', '+', ' ', '9', ' ', '=', ' ', '1', '2']),
+ (1, 9, '2', '3+(7+_)=12', '3+(7+2)=12',
+ [' ', ' ', ' ', ' ', ' ', ' ', ' ', '7', '+', '2', ' ', ' ', ' ', ' ']),
+ (1, 7, '7', '3+(_+_)=12', '3+(7+_)=12',
+ [' ', ' ', ' ', ' ', ' ', ' ', ' ', '7', '+', '_', ' ', ' ', ' ', ' '])]))
+...
+"""
+
+
+print("===== ReckonPrimer.tests/expassten/test_generate_calc.py =============")
+print("=========================== SUCCESS ~~~~~~~~~~~~~~~~~~~~==============")
+
+
diff --git a/ReckonPrimer.tests/extimesdiv/test_generate_calc.py b/ReckonPrimer.tests/extimesdiv/test_generate_calc.py
new file mode 100644
index 0000000..5b83fc4
--- /dev/null
+++ b/ReckonPrimer.tests/extimesdiv/test_generate_calc.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+print("==================================___________________=================")
+print("===== ReckonPrimer.tests/timesdiv/test_generate_calc.py ==============")
+print("-----")
+
+#WN091116 Exercise <10> does not generate calculations with "1+2 <" OFF
+# Error Traceback ends with:
+# File "/home/neuper/Activities/ReckonPrimer.activity/passten.py", line 53, in format
+# return Exercise.format_addsub_simp((cs, linepos))
+# TypeError: unbound method format_addsub_simp() must be called with Exercise instance as first argument (got tuple instance instead)
+
+# _ex = ExTimesDiv(None)
+
+
+print("===== ReckonPrimer.tests/timesdiv/test_generate_calc.py ==============")
+print("========================= SUCCESS ~~~~~~~~~~~~~~~~~~==================")
+
+