mathmaker  0.6(alpha)
mamk_misc/doc/mathmaker4doxygen/sheet/S_Model.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 S_Structure import S_Structure
00027 
00028 FONT_SIZE_OFFSET = 0
00029 SHEET_LAYOUT_TYPE = 'std|short_test|mini_test|equations'
00030 SHEET_LAYOUT_UNIT = "cm"
00031 #EXAMPLE OF A SHEET NOT USING ANY LAYOUT
00032 # -----------------------  lines_nb    col_widths   exercises
00033 SHEET_LAYOUT = { 'exc' : [ None,                    'all'
00034                          ],
00035                  'ans' : [ None,                    'all'
00036                          ]
00037                }
00038 #ANOTHER EXAMPLE
00039 # ------------------------  lines_nb    col_widths   exercises
00040 #SHEET_LAYOUT = { 'exc' : [ [1,         6, 15],      (1, 1),
00041 #                            None,                    1
00042 #                         ],
00043 #                 'ans' : [ [1,         6.5, 12],    (1, 1),
00044 #                            'jump',                 'next_page',
00045 #                            None,                    1
00046 #                         ]
00047 #               }
00048 # NOTE THAT FOR SHORT_TEST SHEETS, THE LAYOUT HAS TO BE GIVEN ONLY ONCE
00049 # AND IT WILL BE DUPLICATED FOR THE SECOND SET OF EXERCISES
00050 
00051 # EXPLANATION ABOUT THE EXAMPLE OF SHEET_LAYOUT :
00052 # [1, 6, 15] means a table of 1 line with columns widths 6 and 15.
00053 # (1, 1) means one exercise in each of these two cells.
00054 # This tuple should contains as many numbers as nb of lines × nb of cols.
00055 # To leave one cell empty, just write 0.
00056 # None means no tabular and the following 1 means for the 1 next exercise.
00057 # 'all' and 'all_left' are synonym
00058 # 'jump' and 'next_page' will include a jump to next page before the next ones
00059 
00060 # ------------------------------------------------------------------------------
00061 # --------------------------------------------------------------------------
00062 # ------------------------------------------------------------------------------
00063 ##
00064 # @class S_Model
00065 # @brief Use it as a copy/paste model to create new sheets.
00066 class S_Model(S_Structure):
00067 
00068 
00069 
00070 
00071 
00072     # --------------------------------------------------------------------------
00073     ##
00074     #   @brief Constructor
00075     #   @param embedded_machine The machine to be used
00076     #   @param **options Any options
00077     #   @return One instance of sheet.Model
00078     def __init__(self, embedded_machine, **options):
00079         self.derived = True
00080         S_Structure.__init__(self, embedded_machine, FONT_SIZE_OFFSET,
00081                              SHEET_LAYOUT_UNIT, SHEET_LAYOUT,
00082                              SHEET_LAYOUT_TYPE)
00083 
00084         # BEGINING OF THE ZONE TO REWRITE (see explanations below) ------------
00085         self.header = ""
00086         self.title = _("Training exercises sheet :")
00087         self.subtitle = ""
00088         self.text = ""
00089         self.answers_title = _("Examples of answers")
00090 
00091         # For instance :
00092         # ex1 = exercise.ProductReduction(self.machine, many=30)
00093         # self.exercises_list.append(ex1)
00094 
00095 
00096 
00097 
00098 
00099 
00100         # END -----------------------------------------------------------------
00101         # Instructions for use (creating a new sheet) :
00102         # - Put its name in the header's comment
00103         #   & in the one of the documentation (@class)
00104         # - Write the @brief comment
00105         # - Replace Model by the chosen name
00106         # - Choose the values for the globals
00107         # - In the constructor's comment, replace Model by the chosen name at
00108         #   the @return line
00109         # - Skip to the zone to rewrite and for each exercise, follow the
00110         #   example (i.e. write on two lines :
00111         #   - ex_number_n = exercise.ThmPythagore(self.machine, options...)
00112         #   - self.exercises_list.append(ex_number_n)
00113         #   and so on with ex<n+1>, ex<n+2> as many as desired)