diff options
author | pmoxhay <pmoxhay@earthlink.net> | 2009-06-02 23:25:52 (GMT) |
---|---|---|
committer | pmoxhay <pmoxhay@earthlink.net> | 2009-06-02 23:25:52 (GMT) |
commit | 92999db805438b80fb505038dc65c55af00cd484 (patch) | |
tree | 724f7578c22add5f5bf547235ac789350847df70 | |
parent | 7d111ae007beac783658e900596ae9d7cae0c6c4 (diff) |
Shapes don't disappear (except for masses, amounts).
Letters don't repeat from problem to problem.
Start registering errors and regulating going from one
problem type to another.
-rw-r--r-- | TODO | 8 | ||||
-rw-r--r-- | amountproblem.py | 11 | ||||
-rw-r--r-- | areaproblem.py | 23 | ||||
-rw-r--r-- | compare3lesson.py | 77 | ||||
-rw-r--r-- | cuttingproblem.py | 19 | ||||
-rw-r--r-- | lengthproblem.py | 27 | ||||
-rw-r--r-- | linesegmentdroptarget.py | 1 | ||||
-rw-r--r-- | massproblem.py | 29 | ||||
-rw-r--r-- | signsdroptarget.py | 3 | ||||
-rw-r--r-- | volumeproblem.py | 23 |
10 files changed, 144 insertions, 77 deletions
@@ -3,7 +3,7 @@ Math General + Improve overall performance. + Improve user feedback for Drag & Drop via keyboard. -+ Progress only when right answer is given. +- Progress only when right answer is given (detect errors). + Fix bug: line segment drop area sometimes stays highlighted. + Add sound effects. + Improve images of faucet, balance, scissors @@ -11,12 +11,12 @@ General + Tools (scissors, balance, faucet) selectable from a menu. Compare3 Lesson -+ Control movement from one problem type to another. -+ Don't repeat colors or letters from one problem to the next. +- Control movement from one problem type to another. +- Don't repeat colors or letters from one problem to the next. + Don't repeat recently used problems. - Add more problems for some comparisons. + Make something happen when progress is completed successfully. -+ Display intersection between Shapes in a different color. IntersectionObject maybe? ++ Display intersection between Shapes in a different color? IntersectionObject maybe? - Mass comparison: fit into answer box. - Fix drawing of mass parallelopipeds (ThreeDObjects). + Fix behavior of line segments (drops getting rejected). diff --git a/amountproblem.py b/amountproblem.py index 413b53b..f2327dc 100644 --- a/amountproblem.py +++ b/amountproblem.py @@ -31,10 +31,13 @@ class AmountProblem(Problem): Generates a problem in which two amounts of discrete objects are compared. """ - def __init__(self, container, color_scheme): + def __init__(self, container, color_scheme, (letter1, letter2) ): self.container = container self.color_scheme = color_scheme + self.letter1 = letter1 + self.letter2 = letter2 + self.generate_problem() self.show_problem() @@ -59,12 +62,6 @@ class AmountProblem(Problem): TRIANGLE = [ Vector(0, 0), Vector(triangle_side/2, -triangle_side * math.sqrt(3)/2), Vector(triangle_side, 0) ] CIRCLE = [ Vector(0, 0), Vector(square_side, 0), Vector(square_side, square_side), Vector(0, square_side) ] - # Choose two random letter to represent the two quantities - self.letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - self.letter2 = self.letter1 - while self.letter2 == self.letter1: - self.letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - # Standard initial positions for the shapes. upper_left_position = Vector(150, 150) lower_right_position = Vector(250, 600) diff --git a/areaproblem.py b/areaproblem.py index 3e4cd89..ca03632 100644 --- a/areaproblem.py +++ b/areaproblem.py @@ -28,10 +28,13 @@ class AreaProblem(Problem): Generates a problem in which two areas are compared. """ - def __init__(self, container, color_scheme): + def __init__(self, container, color_scheme, (letter1, letter2) ): self.container = container self.color_scheme = color_scheme + self.letter1 = letter1 + self.letter2 = letter2 + self.generate_problem() self.show_problem() @@ -100,11 +103,11 @@ class AreaProblem(Problem): SMALL_IRREG_PENTAGON_SHAPE_2 = self.smaller(IRREG_PENTAGON_SHAPE_2) LARGE_IRREG_PENTAGON_SHAPE_2 = self.larger(IRREG_PENTAGON_SHAPE_2) - # Choose two random letter to represent the two quantities - letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - letter2 = letter1 - while letter2 == letter1: - letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + ## Choose two random letter to represent the two quantities + #letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + #letter2 = letter1 + #while letter2 == letter1: + # letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) # Standard initial positions for the shapes. upper_left_position = Vector(300, 300) @@ -238,11 +241,11 @@ class AreaProblem(Problem): # Switch the shapes half the time (so we get > as well as < problems). if random.choice([0,1]) == 0: - self.shape1 = ShapeObject(color1, letter1, object1, original_position1, original_angle1) - self.shape2 = ShapeObject(color2, letter2, object2, original_position2, original_angle2) + self.shape1 = ShapeObject(color1, self.letter1, object1, original_position1, original_angle1) + self.shape2 = ShapeObject(color2, self.letter2, object2, original_position2, original_angle2) else: - self.shape1 = ShapeObject(color1, letter1, object2, original_position1, original_angle1) - self.shape2 = ShapeObject(color2, letter2, object1, original_position2, original_angle2) + self.shape1 = ShapeObject(color1, self.letter1, object2, original_position1, original_angle1) + self.shape2 = ShapeObject(color2, self.letter2, object1, original_position2, original_angle2) return diff --git a/compare3lesson.py b/compare3lesson.py index b83730a..5e4bb87 100644 --- a/compare3lesson.py +++ b/compare3lesson.py @@ -55,10 +55,17 @@ class Compare3Lesson(ObjectArea): ObjectArea.__init__(self, activity) self.problem = 0 + self.level = 0 + self.problem_type = 'none' self.color_scheme = 'no_colors' self.last_color_scheme = 'no_colors' + self.alphabetical_letter1 = 'A' + self.alphabetical_letter2 = 'A' + self.last_alphabetical_letter1 = 'A' + self.last_alphabetical_letter2 = 'A' + self.progress = ProgressObject(Vector(10, 700), 30) self.add_object(self.progress) @@ -70,7 +77,8 @@ class Compare3Lesson(ObjectArea): self.drop_origin = None self.moons_visible = False - + + self.n_errors = 0 #TODO- Put this code in the ShapeObjects themselves. def check_problem_solved(self): @@ -81,34 +89,71 @@ class Compare3Lesson(ObjectArea): #print "Stage 1 Complete" self.finish_problem_stage1() self.pose_problem_stage2() + + def register_error(self): + print '\a' + self.n_errors += 1 + print "number of errors is now:", self.n_errors def pose_problem_stage1(self): #print "pose_problem_stage1: problem_type =", self.problem_type self.stage = 1 + self.n_errors = 0 + # Randomly choose between a length problem and an area problem. - self.problem_type = random.choice(PROBLEM_TYPES) + #self.problem_type = random.choice(PROBLEM_TYPES) self.last_color_scheme = self.color_scheme while (self.color_scheme == self.last_color_scheme): self.color_scheme = random.choice(COLOR_SCHEMES) - + + self.last_alphabetical_letter1 = self.alphabetical_letter1 + self.last_alphabetical_letter2 = self.alphabetical_letter2 + + # Choose two random letter to represent the two quantities + while (self.alphabetical_letter1 == self.last_alphabetical_letter1 or self.alphabetical_letter1 == self.last_alphabetical_letter2 \ + or self.alphabetical_letter2 == self.last_alphabetical_letter1 or self.alphabetical_letter2 == self.last_alphabetical_letter2 ): + self.alphabetical_letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + self.alphabetical_letter2 = self.alphabetical_letter1 + while self.alphabetical_letter2 == self.alphabetical_letter1: + self.alphabetical_letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + + print "new problem: self.level is: ", self.level + + if self.level == 0: + self.problem_type = 'length' + elif self.level == 1: + self.problem_type = 'area' + elif self.level == 2: + self.problem_type = 'volume' + elif self.level == 3: + self.problem_type = 'amount' + elif self.level == 4: + self.problem_type = 'mass' + elif self.level == 5: + self.problem_type = 'cutting' + else: + self.problem_type ='cutting' + + print "... so self.problem_type is now: ", self.problem_type + # Uncomment this to choose a particular problem type. - #self.problem_type = 'cutting' - + #self.problem_type = 'mass' + if self.problem_type == 'length': - self.problem = LengthProblem(self, self.color_scheme) + self.problem = LengthProblem(self, self.color_scheme, (self.alphabetical_letter1, self.alphabetical_letter2) ) elif self.problem_type == 'amount': - self.problem = AmountProblem(self, self.color_scheme) + self.problem = AmountProblem(self, self.color_scheme, (self.alphabetical_letter1, self.alphabetical_letter2) ) elif self.problem_type == 'mass': - self.problem = MassProblem(self, self.color_scheme) + self.problem = MassProblem(self, self.color_scheme, (self.alphabetical_letter1, self.alphabetical_letter2) ) elif self.problem_type == 'volume': - self.problem = VolumeProblem(self) + self.problem = VolumeProblem(self, (self.alphabetical_letter1, self.alphabetical_letter2) ) elif self.problem_type == 'cutting': - self.problem = CuttingProblem(self, self.color_scheme) + self.problem = CuttingProblem(self, self.color_scheme, (self.alphabetical_letter1, self.alphabetical_letter2) ) else: - self.problem = AreaProblem(self, self.color_scheme) + self.problem = AreaProblem(self, self.color_scheme, (self.alphabetical_letter1, self.alphabetical_letter2) ) self.answer = self.problem.find_answer() self.problem_solved_stage1() @@ -150,11 +195,14 @@ class Compare3Lesson(ObjectArea): v = Vector(275 + 100, 350 + 75) - self.problem.shape1.pos self.problem.shape1.pos += v self.problem.shape2.pos += v + self.problem.shape1.calculate_bounds() + self.problem.shape2.calculate_bounds() elif self.problem_type == 'amount': self.problem.finish_problem_stage1() elif self.problem_type == 'mass': self.problem.finish_problem_stage1() - + self.problem.calculate_bounds() + def pose_problem_stage2(self): self.stage = 2 self.instructions.text = 'Show the result using line segments' @@ -292,7 +340,10 @@ class Compare3Lesson(ObjectArea): self.instructions.text = 'The ' + quantity_name + ' ' + self.letter1.symbol + ' is ' \ + text + ' the ' + quantity_name + ' ' + self.letter2.symbol - self.progress.take_a_step(); + if (self.n_errors == 0): + self.level += 1 + print "self.level is now:", self.level + self.progress.take_a_step() self.pose_next_problem_arrow() diff --git a/cuttingproblem.py b/cuttingproblem.py index a6cc4ce..2185c78 100644 --- a/cuttingproblem.py +++ b/cuttingproblem.py @@ -55,10 +55,13 @@ class CuttingProblem(Problem): Generates a problem in which two areas are compared by cutting. """ - def __init__(self, container, color_scheme): + def __init__(self, container, color_scheme, (letter1, letter2) ): self.container = container self.color_scheme = color_scheme + self.letter1 = letter1 + self.letter2 = letter2 + self.generate_problem() self.show_problem() @@ -102,11 +105,11 @@ class CuttingProblem(Problem): SMALL_RECTANGLE_2_SHAPE = [ Vector(0, 0), Vector(250, 0), Vector(250, 125), Vector(0, 125) ] - # Choose two random letter to represent the two quantities - letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - letter2 = letter1 - while letter2 == letter1: - letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + ## Choose two random letter to represent the two quantities + #letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + #letter2 = letter1 + #while letter2 == letter1: + # letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) # Standard initial positions for the shapes. upper_left_position = Vector(300, 300) @@ -226,8 +229,8 @@ class CuttingProblem(Problem): # self.shape1 = ShapeObject(color1, letter1, object2, original_position1, original_angle1) # self.shape2 = ShapeObject(color2, letter2, object1, original_position2, original_angle2) - self.shape1 = ShapeObject(color1, letter1, object1, original_position1, original_angle1) - self.shape2 = ShapeObject(color2, letter2, object2, original_position2, original_angle2) + self.shape1 = ShapeObject(color1, self.letter1, object1, original_position1, original_angle1) + self.shape2 = ShapeObject(color2, self.letter2, object2, original_position2, original_angle2) self.scissors_object = ScissorsObject(Vector(750, 100)) self.container.add_object(self.scissors_object) diff --git a/lengthproblem.py b/lengthproblem.py index bb8c400..9965233 100644 --- a/lengthproblem.py +++ b/lengthproblem.py @@ -28,10 +28,13 @@ class LengthProblem(Problem): Generates a problem in which two lengths are compared. """ - def __init__(self, container, color_scheme): + def __init__(self, container, color_scheme, (letter1, letter2) ): self.container = container self.color_scheme = color_scheme + self.letter1 = letter1 + self.letter2 = letter2 + self.generate_problem() self.show_problem() @@ -40,7 +43,7 @@ class LengthProblem(Problem): self.container.moons_visible = False def generate_problem(self): - # Choose two random colors. + # Set the colors. if self.color_scheme == 'red_green': (color1, color2) = random.choice([(Color.RED, Color.GREEN), (Color.GREEN, Color.RED)]) elif self.color_scheme == 'green_blue': @@ -66,11 +69,11 @@ class LengthProblem(Problem): LENGTH_14 = [ Vector(0, 0), Vector(50, 0), Vector(50, 525), Vector(0, 525) ] LENGTH_15 = [ Vector(0, 0), Vector(50, 0), Vector(50, 550), Vector(0, 550) ] - # Choose two random letter to represent the two quantities - letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - letter2 = letter1 - while letter2 == letter1: - letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + ## Choose two random letter to represent the two quantities + #letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + #letter2 = letter1 + #while letter2 == letter1: + # letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) # Standard initial positions for the shapes. upper_left_position = Vector(300, 300) @@ -92,7 +95,7 @@ class LengthProblem(Problem): n_problems = 18 # Choose a random problem. - problem_number = random.randrange(0,n_problems) + problem_number = random.randrange(0, n_problems) # Uncomment to test a particular problem. #problem_number = 0 @@ -167,11 +170,11 @@ class LengthProblem(Problem): # Switch the shapes half the time (so we get > as well as < problems). if random.choice([0,1]) == 0: - self.shape1 = ShapeObject(color1, letter1, object1, original_position1, original_angle1) - self.shape2 = ShapeObject(color2, letter2, object2, original_position2, original_angle2) + self.shape1 = ShapeObject(color1, self.letter1, object1, original_position1, original_angle1) + self.shape2 = ShapeObject(color2, self.letter2, object2, original_position2, original_angle2) else: - self.shape1 = ShapeObject(color1, letter1, object2, original_position1, original_angle1) - self.shape2 = ShapeObject(color2, letter2, object1, original_position2, original_angle2) + self.shape1 = ShapeObject(color1, self.letter1, object2, original_position1, original_angle1) + self.shape2 = ShapeObject(color2, self.letter2, object1, original_position2, original_angle2) return diff --git a/linesegmentdroptarget.py b/linesegmentdroptarget.py index 8c75d84..82d6dfc 100644 --- a/linesegmentdroptarget.py +++ b/linesegmentdroptarget.py @@ -154,6 +154,7 @@ class LineSegmentDropTarget(DropTargetObject): if not self.answer_correct() and self.all_drop_targets_full():
self.reset_all_drop_targets()
+ self.container.register_error()
elif self.answer_correct():
self.container.selected_object = None
self.freeze_drop_targets()
diff --git a/massproblem.py b/massproblem.py index 014c58b..a3840c1 100644 --- a/massproblem.py +++ b/massproblem.py @@ -30,10 +30,13 @@ class MassProblem(Problem): Generates a problem in which two lengths are compared. """ - def __init__(self, container, color_scheme): + def __init__(self, container, color_scheme, (letter1, letter2) ): self.container = container self.color_scheme = color_scheme + self.letter1 = letter1 + self.letter2 = letter2 + self.generate_problem() self.show_problem() @@ -42,19 +45,13 @@ class MassProblem(Problem): self.container.moons_visible = False def generate_problem(self): - # Choose two random colors. + # Set the colors. if self.color_scheme == 'red_green': (color1, color2) = random.choice([(Color.RED, Color.GREEN), (Color.GREEN, Color.RED)]) elif self.color_scheme == 'green_blue': (color1, color2) = random.choice([(Color.GREEN, Color.BLUE), (Color.BLUE, Color.GREEN)]) else: (color1, color2) = random.choice([(Color.RED, Color.BLUE), (Color.BLUE, Color.RED)]) - - # Choose two random letter to represent the two quantities - letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - letter2 = letter1 - while letter2 == letter1: - letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) # The total number of problems. n_problems = 9 @@ -129,11 +126,11 @@ class MassProblem(Problem): # Switch the shapes half the time (so we get > as well as < problems). if random.choice([0,1]) == 0: - self.shape1 = ThreeDObject(color1, letter1, size1, original_position1, mass=self.mass1) - self.shape2 = ThreeDObject(color2, letter2, size2, original_position2, mass=self.mass2) + self.shape1 = ThreeDObject(color1, self.letter1, size1, original_position1, mass=self.mass1) + self.shape2 = ThreeDObject(color2, self.letter2, size2, original_position2, mass=self.mass2) else: - self.shape1 = ThreeDObject(color1, letter2, size1, original_position1, mass=self.mass1) - self.shape2 = ThreeDObject(color2, letter1, size2, original_position2, mass=self.mass2) + self.shape1 = ThreeDObject(color1, self.letter2, size1, original_position1, mass=self.mass1) + self.shape2 = ThreeDObject(color2, self.letter1, size2, original_position2, mass=self.mass2) #self.balance_object = BalanceObject(Vector(100, 100), self.container) self.balance_object = BalanceObject(Vector(36, 207), self.container) @@ -196,6 +193,8 @@ class MassProblem(Problem): if isinstance(o, ThreeDObject): o.scale = 0.65 #o.move(Vector(x_final, y_final)) + + self.calculate_bounds() def finish_problem_stage1(self): #print "MassProblem: finish_problem_stage1 called" @@ -292,6 +291,12 @@ class MassProblem(Problem): self.balance_object.pos = Vector(36, 207) self.balance_object.adjust_balance_state() + + self.calculate_bounds() + + def calculate_bounds(self): + self.shape1.calculate_bounds() + self.shape2.calculate_bounds() def find_answer(self): if self.shape1.mass > self.shape2.mass: diff --git a/signsdroptarget.py b/signsdroptarget.py index 969adad..938366c 100644 --- a/signsdroptarget.py +++ b/signsdroptarget.py @@ -138,7 +138,8 @@ class SignsDropTarget(DropTargetObject): if not self.answer_correct() and self.all_drop_targets_full():
self.container.show_hint()
- self.reset_all_drop_targets()
+ self.reset_all_drop_targets()
+ self.container.register_error()
elif self.answer_correct():
self.container.selected_object = None
self.freeze_drop_targets()
diff --git a/volumeproblem.py b/volumeproblem.py index d6a54ed..3299a2a 100644 --- a/volumeproblem.py +++ b/volumeproblem.py @@ -30,9 +30,12 @@ class VolumeProblem(Problem): Generates a problem in which two volumes are compared. """ - def __init__(self, container): + def __init__(self, container, (letter1, letter2) ): self.container = container + self.letter1 = letter1 + self.letter2 = letter2 + self.generate_problem() self.show_problem() @@ -51,11 +54,11 @@ class VolumeProblem(Problem): (Color.RED, Color.GREEN), (Color.GREEN, Color.RED), \ (Color.BLUE, Color.GREEN), (Color.GREEN, Color.BLUE)]) - # Choose two random letter to represent the two quantities - letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) - letter2 = letter1 - while letter2 == letter1: - letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + ## Choose two random letter to represent the two quantities + #letter1 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) + #letter2 = letter1 + #while letter2 == letter1: + # letter2 = random.choice(['A', 'B', 'C', 'D', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'S', 'T']) # The total number of problems. n_problems = 3 @@ -246,11 +249,11 @@ class VolumeProblem(Problem): # Switch the shapes half the time (so we get > as well as < problems). if random.choice([0,1]) == 0: - self.shape1 = VolumeObject(color1, letter1, original_position1, self.height1, self.lower_radius1, self.upper_radius1) - self.shape2 = VolumeObject(color2, letter2, original_position2, self.height2, self.lower_radius2, self.upper_radius2) + self.shape1 = VolumeObject(color1, self.letter1, original_position1, self.height1, self.lower_radius1, self.upper_radius1) + self.shape2 = VolumeObject(color2, self.letter2, original_position2, self.height2, self.lower_radius2, self.upper_radius2) else: - self.shape1 = VolumeObject(color1, letter2, original_position1, self.height1, self.lower_radius1, self.upper_radius1) - self.shape2 = VolumeObject(color2, letter1, original_position2, self.height2, self.lower_radius2, self.upper_radius2) + self.shape1 = VolumeObject(color1, self.letter2, original_position1, self.height1, self.lower_radius1, self.upper_radius1) + self.shape2 = VolumeObject(color2, self.letter1, original_position2, self.height2, self.lower_radius2, self.upper_radius2) self.faucet_object = FaucetObject(Vector(0, 100)) self.container.add_object(self.faucet_object) |