Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.activity/exercises/exercise.py
diff options
context:
space:
mode:
Diffstat (limited to 'ReckonPrimer.activity/exercises/exercise.py')
-rwxr-xr-xReckonPrimer.activity/exercises/exercise.py49
1 files changed, 46 insertions, 3 deletions
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.