Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalther Neuper <wneuper@localhost.(none)>2010-01-20 18:05:11 (GMT)
committer Walther Neuper <wneuper@localhost.(none)>2010-01-20 18:05:11 (GMT)
commit756eec8d8acd0a22245d9261d2b5b3137501fefc (patch)
tree00c3fa2cc23211f0e452b88c2a80b48126f1e1d1
parent0b266b8b6430922ed0544ee56b2450397d460c2f (diff)
error handling without journal
-rwxr-xr-xReckonPrimer.activity/coach.py18
-rw-r--r--ReckonPrimer.activity/data/learnmode.cfg8
-rwxr-xr-xReckonPrimer.activity/display.py1
-rwxr-xr-xReckonPrimer.activity/exercises/exercise.py49
-rw-r--r--ReckonPrimer.activity/learner.py30
-rwxr-xr-xReckonPrimer.activity/settings.py17
6 files changed, 110 insertions, 13 deletions
diff --git a/ReckonPrimer.activity/coach.py b/ReckonPrimer.activity/coach.py
index 310538d..861bb0b 100755
--- a/ReckonPrimer.activity/coach.py
+++ b/ReckonPrimer.activity/coach.py
@@ -6,12 +6,24 @@ import pickle
from display import Display
class Coach:
- """ The coach supervises the selection of exercises. """
+ """ The coach supervises the Learner. Presently he only
+ manages the selection of Exercises. """
print('in coach, class definition')
+ _learnmode = None
+
def __init__(self):
#print("in coach.__init__")
self._ex = None # the learner can change the settings of _this_ exerc
+ self.load_configuration_file()
+
+ def load_configuration_file(self):
+ try:
+ configuration_file = open('data/learnmode.cfg', 'rb')
+ self._learnmode = pickle.load(configuration_file)
+ configuration_file.close()
+ except:
+ configuration_file = []
def register(self, sess, dis, collect, learner):
self._sess = sess
@@ -31,9 +43,13 @@ class Coach:
self._dis.offer_coll_to_learner(self._collect)
# calls back with notify('exerc-selected'... OR 'switch-to-setts'
+ def get_learnmode(self):
+ return(self._learnmode)
+
def exercise_selected(self, key):
self._dis.init_calc()
self._ex = self._collect.select(key)
+
self._learner.start_calcs(self._ex)
def switch_to_settings(self, key):
diff --git a/ReckonPrimer.activity/data/learnmode.cfg b/ReckonPrimer.activity/data/learnmode.cfg
new file mode 100644
index 0000000..5aa9344
--- /dev/null
+++ b/ReckonPrimer.activity/data/learnmode.cfg
@@ -0,0 +1,8 @@
+(dp0
+S'intermediate_repetitions'
+p1
+I2
+sS'delayed_repetitions'
+p2
+I2
+s.
diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py
index a5390b4..a0b3eb4 100755
--- a/ReckonPrimer.activity/display.py
+++ b/ReckonPrimer.activity/display.py
@@ -337,6 +337,7 @@ class Display:
self.errors = self.errors + 1
widget.set_text("")
self.protocol(proterr, self.errors, 'XXX')
+ self._learner.calculation_error()
#WN090518
diff --git a/ReckonPrimer.activity/exercises/exercise.py b/ReckonPrimer.activity/exercises/exercise.py
index 3049a4e..ced4e22 100755
--- a/ReckonPrimer.activity/exercises/exercise.py
+++ b/ReckonPrimer.activity/exercises/exercise.py
@@ -5,7 +5,17 @@ from functions import make_line_remainder, make_input_remainder
class Exercise:
EXERCISES = {}
-
+
+ _intermediate_repetitions = 0
+ _intermediate_count = 0
+
+ _delayed_repetitions = 0
+ _delayed_count = 0
+
+ _error_list = []
+ _current_calc = None
+ _eval = {}
+
"""This is the base class for the individual exercises.
An exercise is characterized by a topic. A topic determines the
fields of the settings self._sett and public methods of Exercise.
@@ -20,7 +30,7 @@ class Exercise:
The list allows to append the current errors to the previous ones,
and even to do an Exercise subsequently several times;
thus the most recent errors are at the end of the list. """
- self._eval = []
+ #self._eval = {} this statement does nothing
""" The settings determine the generation of calculations.
The fields of the settings are determined by self._sett['topic'];
the values of the settings are different for different Exercises.
@@ -48,13 +58,46 @@ class Exercise:
def get_next_calc(self):
""" Get the next calculation from the Exercise.
TODO.WN091123: handle exception after last exercise. """
- return (self._calcs).pop()
+ if self.count() == 0 and self._delayed_count > 0:
+ self._delayed_count = self._delayed_count - 1
+ self._calcs.extend(self._error_list)
+ self._error_list = []
+ self._current_calc = (self._calcs).pop()
+ return self._current_calc
def count(self):
""" Return the number of calculations generated by
the current settings """
return len(self._calcs)
+ def handle_calculation_error(self):
+ if self._intermediate_count == self._intermediate_repetitions:
+ self._error_list.insert(0, self._current_calc)
+ try: self._eval[str(self._sett)].append(self._current_calc)
+ except Exception: self._eval[str(self._sett)] = self._current_calc
+ if self._intermediate_count > 0:
+ self._intermediate_count = self._intermediate_count - 1
+ self._calcs.append(self._current_calc)
+ else:
+ self._intermediate_count = self._intermediate_repetitions
+
+ def reset_evaluation_data(self):
+ self._eval = {}
+
+ def get_evaluation_data(self):
+ return self._eval
+
+ def set_num_intermediate_repetitions(self, num_repetitions):
+ self._intermediate_repetitions = num_repetitions
+ self._intermediate_count = num_repetitions
+
+
+ def set_num_delayed_repetitions(self, num_repetitions):
+ self._delayed_repetitions = num_repetitions
+ self._delayed_count = num_repetitions
+
+ #END CHANGE
+
#===== methods of subclasses different for topic-specific settings
def format(self, calc):
""" Prepare the representation of a calculation for Display.
diff --git a/ReckonPrimer.activity/learner.py b/ReckonPrimer.activity/learner.py
index 5df67e2..4c12e29 100644
--- a/ReckonPrimer.activity/learner.py
+++ b/ReckonPrimer.activity/learner.py
@@ -3,13 +3,16 @@
class Learner:
""" All functionality within the learners rights. """
+ _learnmode = None
+
def __init__(self, display, coach):
self._display = display
self._coach = coach
+ self._learnmode = self._coach.get_learnmode()
self._ex = None
self._curr_in = None
pass
-
+
def run(self):
""" As long as user does exercises.
Doing Exercises is terminated by another choice in the menu
@@ -20,6 +23,12 @@ class Learner:
def start_calcs(self, exercise):
self._ex = exercise
+
+ try: self._ex.set_num_intermediate_repetitions(self._learnmode['intermediate_repetitions'])
+ except Exception: self._ex.set_num_intermediate_repetitions(0)
+ try: self._ex.set_num_delayed_repetitions(self._learnmode['delayed_repetitions'])
+ except Exception: self._ex.set_num_delayed_repetitions(0)
+
self._display.set_curr_exerc(exercise)
_calc = self._ex.get_next_calc()
_lines, self._input = exercise.format(_calc)
@@ -45,4 +54,21 @@ class Learner:
# create_entryline sets the callback from gtk to Display
except IndexError:
self._display.finish_calc()
- \ No newline at end of file
+
+ def calculation_error(self):
+ self._ex.handle_calculation_error()
+ #print('in learner.notify, digit-done: _input=', self._input)
+ (lino, pos, dig, proterr, protok, li) = self._curr_in
+ self._display.create_entryline((lino, -1, dig, proterr, protok, li))
+ self._display.show_progress()
+ try: # get_next_calc
+ _calc = self._ex.get_next_calc()
+ print('in learner.notify: calc=', _calc)
+ _lines, self._input = self._ex.format(_calc)
+ self._display.display_calc(_lines)
+ self._curr_in = self._input.pop() #need _curr_in in notify
+ self._display.create_entryline(self._curr_in)
+ # create_entryline sets the callback from gtk to Display
+ except IndexError:
+ self._display.finish_calc()
+
diff --git a/ReckonPrimer.activity/settings.py b/ReckonPrimer.activity/settings.py
index b91e927..ab1dbd9 100755
--- a/ReckonPrimer.activity/settings.py
+++ b/ReckonPrimer.activity/settings.py
@@ -20,19 +20,20 @@ class Settings:
'MAX' : 30, # maximum of calcs generated.
# Generate fills up by varying input.
'MIN' : 20, # minimum of calcs generated UNUSED
- 'min' : 0, # minimum in size of a number in a calc
+ 'min' : 1, # minimum in size of a number in a calc
'max' : 1, # maximum in size of a number in a calc
# 0 <= min <= max <= 10
'+' : True, # make all additions min..max
- '-' : True, # make all subtactions min..max
+ '-' : False, # 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
+ 'input=' : [5],# list of positions in calc: 1 | 3 | 5
# where input is possible;
# actual positions chosen by Generate.
'_=_+_' : False, # = is _left_ from operator, e.g. 3=1+2
'=input' : [1,3,5],# analogous to '_+_=_'
- 'shuffle': True, # shuffle _all_ the calcs
- 'cut-max': True # cut set of all calcs down to MAX
+ 'shuffle': False, # shuffle _all_ the calcs
+ 'cut-max': True, # cut set of all calcs down to MAX
+
}
self._default_passten = \
@@ -60,7 +61,8 @@ class Settings:
'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
+ 'cut-max' : True, # cut set of all calcs down to MAX
+
}
self._default_times_div = \
@@ -84,7 +86,8 @@ class Settings:
# -: maximum result
'shuffle_all' : False, # shuffle all calcs
'shuffle_inner': True, # shuffle only 1st (inner) iteration
- 'cut-max' : True # cut set of all calcs down to MAX
+ 'cut-max' : True, # cut set of all calcs down to MAX
+
}
#!!!extend here with additional topic!!!