mathmaker  0.4(alpha)
mathmaker_dev/sheet/AlgebraExpressionExpansion.py
00001 # -*- coding: utf-8 -*-
00002 
00003 # Mathmaker creates automatically maths exercises sheets
00004 # with their answers
00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net>
00006 
00007 # This file is part of Mathmaker.
00008 
00009 # Mathmaker is free software; you can redistribute it and/or modify
00010 # it under the terms of the GNU General Public License as published by
00011 # the Free Software Foundation; either version 3 of the License, or
00012 # any later version.
00013 
00014 # Mathmaker is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 
00019 # You should have received a copy of the GNU General Public License
00020 # along with Mathmaker; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 import machine
00024 import exercise
00025 
00026 from lib.common import cst
00027 from S_Structure import S_Structure
00028 
00029 FONT_SIZE_OFFSET = -1
00030 SHEET_LAYOUT_TYPE = 'std'
00031 SHEET_LAYOUT_UNIT = "cm"
00032 # -----------------------  lines_nb    col_widths   exercises
00033 SHEET_LAYOUT = { 'exc' : [ None,                    'all'
00034                          ],
00035                  'ans' : [ [1,         7.5, 10.5],      (1, 1)
00036                          ]
00037                }
00038 
00039 # ------------------------------------------------------------------------------
00040 # --------------------------------------------------------------------------
00041 # ------------------------------------------------------------------------------
00042 ##
00043 # @class AlgebraExpressionExpansion
00044 # @brief One exercise with 3x(2-7x) & 5(3+x) objects, another with (2+x)(3-x)
00045 class AlgebraExpressionExpansion(S_Structure):
00046 
00047 
00048 
00049 
00050 
00051     # --------------------------------------------------------------------------
00052     ##
00053     #   @brief Constructor
00054     #   @param embedded_machine The machine to be used
00055     #   @param **options Any options
00056     #   @return One instance of sheet.ExpressionExpansion
00057     def __init__(self, embedded_machine, **options):
00058         self.derived = True
00059         S_Structure.__init__(self, embedded_machine, FONT_SIZE_OFFSET,
00060                              SHEET_LAYOUT_UNIT, SHEET_LAYOUT,
00061                              SHEET_LAYOUT_TYPE)
00062 
00063         # BEGINING OF THE ZONE TO REWRITE (see explanations below) ------------
00064         self.header = ""
00065         self.title = _("Training exercises sheet :")
00066         self.subtitle = _("Expand an algebraic expression")
00067         self.text = ""
00068         self.answers_title = _("Examples of answers")
00069 
00070         ex1 = exercise.X_AlgebraExpressionExpansion(self.machine,
00071                                                   x_kind='preformatted',
00072                                                   x_subkind='mixed_monom_polyn1',
00073                                                   ratio_mmp=0.4,
00074                                                   number_of_questions=5,
00075                                                   randomly_reversed=0.25)
00076 
00077 
00078         ex2 = exercise.X_AlgebraExpressionExpansion(self.machine,
00079                                                   x_kind='bypass',
00080                                                   x_subkind='polyn1_polyn1',
00081                                                   number_of_questions=5)
00082 
00083 
00084         self.exercises_list.append(ex1)
00085         self.exercises_list.append(ex2)
00086 
00087 
00088 
00089 
00090