Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
gnumch.EqualityLevelset Class Reference
Inheritance diagram for gnumch.EqualityLevelset:
Inheritance graph
[legend]
Collaboration diagram for gnumch.EqualityLevelset:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def getTitle
def setLevel
def getNumber
def getError
def getNumberWithAnswer
def getPlus
def getMinus
def getTimes
def getDivide

Public Attributes

 answermin
 curlevel
 cur_sublevel
 answer
 numlevels
 num_sublevels
 levelops

Detailed Description

Definition at line 265 of file gnumch.py.


Constructor & Destructor Documentation

Reimplemented from gnumch.ExpressionLevelset.

Definition at line 266 of file gnumch.py.

00266 
00267     def __init__(self):
00268         super(EqualityLevelset, self).__init__()
00269         self.answermin = 5


Member Function Documentation

def gnumch.ExpressionLevelset.getDivide (   self,
  answer 
) [inherited]

Definition at line 261 of file gnumch.py.

00261 
00262     def getDivide(self, answer):
00263         n = random.randint(1, 5)
00264         return Number( _(u'%d \u00f7 %d') % (answer*n, n), 1 )

def gnumch.ExpressionLevelset.getError (   self,
  num 
) [inherited]

Definition at line 237 of file gnumch.py.

00237 
00238     def getError(self, num):
00239         fmt = _('%s = %d')
00240         return fmt % (num.text, num.value)

def gnumch.ExpressionLevelset.getMinus (   self,
  answer 
) [inherited]

Definition at line 252 of file gnumch.py.

00252 
00253     def getMinus(self, answer):
00254         n = random.randint(answer, answer*2)
00255         num = Number( _(u'%d \u2212 %d') % (n, n-answer), 1 )
00256         return num

Reimplemented in gnumch.InequalityLevelset.

Definition at line 278 of file gnumch.py.

00278 
00279     def getNumber(self):
00280         if random.randint(0, 1):
00281             # correct number
00282             num = self.getNumberWithAnswer(self.answer)
00283             num.good = 1
00284         else:
00285             # wrong number
00286             ans = random.choice( range(self.answermin, self.answer) + range(self.answer+1, self.answer*2) )
00287             num = self.getNumberWithAnswer(ans)
00288             num.good = 0
00289         return num

Here is the call graph for this function:

def gnumch.ExpressionLevelset.getNumberWithAnswer (   self,
  answer 
) [inherited]

Definition at line 241 of file gnumch.py.

00241 
00242     def getNumberWithAnswer(self, answer):
00243         fn = random.choice( self.levelops[self.curlevel-1] )
00244         num = fn(answer)
00245         num.value = answer
00246         return num

Here is the caller graph for this function:

def gnumch.ExpressionLevelset.getPlus (   self,
  answer 
) [inherited]

Definition at line 247 of file gnumch.py.

00247 
00248     def getPlus(self, answer):
00249         n = random.randint(0, answer)
00250         num = Number( _(u'%d + %d') % (n, answer-n), 1 )
00251         return num

def gnumch.ExpressionLevelset.getTimes (   self,
  answer 
) [inherited]

Definition at line 257 of file gnumch.py.

00257 
00258     def getTimes(self, answer):
00259         n = random.choice( getFactors(answer) )
00260         return Number( _(u'%d \u00d7 %d') % (n, answer/n), 1 )

Here is the call graph for this function:

Reimplemented in gnumch.InequalityLevelset.

Definition at line 270 of file gnumch.py.

00270 
00271     def getTitle(self):
00272         return _('Equal to %d') % (self.answer,)

def gnumch.EqualityLevelset.setLevel (   self,
  level,
  sublevel 
)

Definition at line 273 of file gnumch.py.

00273 
00274     def setLevel(self, level, sublevel):
00275         self.curlevel = level
00276         self.cur_sublevel = sublevel
00277         self.answer = self.answermin + self.cur_sublevel


Member Data Documentation

Definition at line 276 of file gnumch.py.

Definition at line 268 of file gnumch.py.

Reimplemented from gnumch.ExpressionLevelset.

Definition at line 275 of file gnumch.py.

Reimplemented from gnumch.ExpressionLevelset.

Definition at line 274 of file gnumch.py.

Definition at line 226 of file gnumch.py.

Definition at line 225 of file gnumch.py.

Definition at line 224 of file gnumch.py.


The documentation for this class was generated from the following file: