mathmaker
0.6(alpha)
|
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' : [ [2, 9, 9], (1, 1, 00034 1, 1) 00035 ], 00036 'ans' : [ [2, 9, 9], (1, 1, 00037 1, 1) 00038 ] 00039 } 00040 00041 # ------------------------------------------------------------------------------ 00042 # -------------------------------------------------------------------------- 00043 # ------------------------------------------------------------------------------ 00044 ## 00045 # @class AlgebraBinomialIdentityExpansion 00046 # @brief Expand (a+b)², (a-b)², (a+b)(a-b)... 00047 class AlgebraBinomialIdentityExpansion(S_Structure): 00048 00049 00050 00051 00052 00053 # -------------------------------------------------------------------------- 00054 ## 00055 # @brief Constructor 00056 # @param embedded_machine The machine to be used 00057 # @param **options Any options 00058 # @return One instance of sheet.Model 00059 def __init__(self, embedded_machine, **options): 00060 self.derived = True 00061 S_Structure.__init__(self, embedded_machine, FONT_SIZE_OFFSET, 00062 SHEET_LAYOUT_UNIT, SHEET_LAYOUT, 00063 SHEET_LAYOUT_TYPE) 00064 00065 # BEGINING OF THE ZONE TO REWRITE (see explanations below) ------------ 00066 self.header = "" 00067 self.title = _("Training exercises sheet :") 00068 self.subtitle = _("Expand special identities") 00069 self.text = "" 00070 self.answers_title = _("Examples of answers") 00071 00072 # ex1 00073 ex1 = exercise.X_AlgebraExpressionExpansion(self.machine, 00074 x_kind='bypass', 00075 x_subkind='sum_square', 00076 number_of_questions=5 00077 ) 00078 00079 self.exercises_list.append(ex1) 00080 00081 00082 # ex2 00083 ex2 = exercise.X_AlgebraExpressionExpansion(self.machine, 00084 x_kind='bypass', 00085 x_subkind='difference_square', 00086 number_of_questions=5 00087 ) 00088 00089 self.exercises_list.append(ex2) 00090 00091 # ex3 00092 ex3 = exercise.X_AlgebraExpressionExpansion(self.machine, 00093 x_kind='bypass', 00094 x_subkind='squares_difference', 00095 number_of_questions=5 00096 ) 00097 00098 self.exercises_list.append(ex3) 00099 00100 # ex4 00101 ex4 = exercise.X_AlgebraExpressionExpansion(self.machine, 00102 x_kind='bypass', 00103 x_subkind='any_binomial', 00104 number_of_questions=5 00105 ) 00106 00107 self.exercises_list.append(ex4) 00108 00109 00110 00111 00112 00113 # -------------------------------------------------------------------------- 00114 ## 00115 # @brief Writes to the output all exercises' answers 00116 def write_answers(self): 00117 self.machine.reset_exercises_counter() 00118 self.machine.write_set_font_size_to('large') 00119 00120 #for e in self.exercises_list: 00121 # self.machine.write_exercise_number() 00122 # e.write_answer() 00123 # self.machine.write_new_line() 00124 00125 self.machine.write_tabular_begins("p{9 cm} p{9 cm}") 00126 00127 self.machine.write_exercise_number() 00128 self.exercises_list[0].write_answer() 00129 00130 self.machine.write_separator_tabular_columns() 00131 00132 self.machine.write_exercise_number() 00133 self.exercises_list[1].write_answer() 00134 00135 self.machine.write_tabular_ends() 00136 00137 self.machine.write_tabular_begins("p{9 cm} p{9 cm}") 00138 00139 self.machine.write_exercise_number() 00140 self.exercises_list[2].write_answer() 00141 00142 self.machine.write_separator_tabular_columns() 00143 00144 self.machine.write_exercise_number() 00145 self.exercises_list[3].write_answer() 00146 00147 self.machine.write_tabular_ends() 00148 00149 00150 # END ---------------------------------------------------------------------